Implementing a 'quick fix' import option plugin

Answered

Where can I start to implement something that provides an autocomplete option for an unresolved reference?

So far I've found com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider, which I imagine is the starting point for me to provide the option I'm looking for. Hopefully I'm on the right path.

In case anyone is interested in the specifics, I'm working in a JS/TS project where we make heavy use of import * as someService from '../services/someService'. I'm interested in implementing a little personal plugin to provide autocomplete of imports for these files, since IntelliJ doesn't seem to register them as possible imports. So in other words ideally I would start typing someService, and then a quick fix would be available to add the aforementioned import to the file.

1
1 comment

Hi,

Yes, it seems like a proper extension point for adding missing imports for unresolved references. You can see example implementations of this EP in open source plugins:
https://plugins.jetbrains.com/intellij-platform-explorer/extensions?extensions=com.intellij.codeInsight.unresolvedReferenceQuickFixProvider

You can also consider adding imports on the fly. For this, you can implement a completion contributor which will complete your service names, and insert the import statement in the insert handler. For details see:
https://plugins.jetbrains.com/docs/intellij/code-completion.html

0

Please sign in to leave a comment.