I'm working on an "introduce variable" refactoring. What I have in mind is to use the template framework. From a selected text, I could search for the next "Module" where a variable can be introduced. So what I want is to turn this
after pressing Ctrl+Alt+V into an editable live template that looks like this
This shouldn't be hard, but I'm stumbling upon how to set up the placeholders for the template. My idea is to walk the tree upwards from the selection until I have to whole "Module" element. How can I use the text of the "Module" element and turn it into an appropriate template? Are there any good examples out there since documentation is not really existent.