Expanding live template in a QuickFix

I am writing a code inspection, where one of the quick fixes is used to annotate certain fields. I would like to be able to ask for user input for annotation parameters, like this:

@MyAnnotation("<$USER_INPUT_HERE$>")
public static String s = "Hello World!";

Is Live templates right tool for this? If so, how do I incorporate them into my quick fix? Thanks.

2 comments
Comment actions Permalink

On a mote general note, how do I expand a template programmatically?

0
Comment actions Permalink

Hi Mihail,

Yes, live template might be a solution. To expand template you can use `com.intellij.codeInsight.template.TemplateManager#startTemplate`.

Also it's often handy to use `com.intellij.codeInsight.template.TemplateBuilder` for that. For examples just take a look on its usages in intellij-community and intellij-plugins repos, e.g. this one

0

Please sign in to leave a comment.