How to insert a dynamically generated "live template"?

Hi everybody

I love the IntelliJ IDEs and just started to write my first IntelliJ plugin. Everything is fine so far. I have only one question:

My plugin has the intention to automatically (after pressing a keystroke) insert a dynamically generated code snippet.

I can't embedded my code snppets as a live template inside the plugin because, it is completely generated at runtime.


The generated code snippet does also include various placeholers (like a placeholder in live templates).

I also want the same user experience (auto cursor positioning on the first placeholder, switching to the next placeholder via tab key) as the user already knows from using live templates.


So the final question is: How can I insert a dynamically generated Java code snippet into a Java class file and make usage of live template features like "auto cursor positoning on the first placeholder variable", "switching to the next placeholder variable via tab" and so on?

Please please ask if my question is not clear.


I really appreciate any kind of help!!


Many thanks




1 comment
Comment actions Permalink

Use Template, see com.intellij.codeInsight.daemon.quickFix.CreateFieldOrPropertyFix#generateMembers for sample.


Please sign in to leave a comment.