Recommended way to handle imports (Java/Kotlin) when adding an annotation to a class from a quick fix

Answered

If a plugin adds an annotation to a Java/Kotlin class or method in a quick fix, is it recommended that it also adds the import for the annotation type? Or should the user use the "Import class" quick fix as a separate step?

Both are possible, but I'm wondering what the recommended or preferred way is.

1 comment
Comment actions Permalink

It should add all required imports and other "setup code" automatically usually. Code should always be in compilable state, unless it clearly requires user input/steps. See com.intellij.codeInsight.intention.AddAnnotationPsiFix as reference.

0

Please sign in to leave a comment.