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.
Please sign in to leave a comment.
On a mote general note, how do I expand a template programmatically?
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