Running simple template through API
1) My action creates (among other things) a namespace declaration on the root element. I want to run a live template to let the user select the namespace prefix from a list of candidates (or enter one manually).
Is the code below OK, or does it "work by accident"?
() { public LookupItem fun(final String suggestion) { return LookupItemUtil.objectToLookupItem(suggestion); } }, LookupItem.EMPTY_ARRAY); } }; } ----------------------------- ]]>
2) For the action above, I'm interested in the value that was the result of the template (either one of the suggestions, or a manually entered prefix).
I assume that the proper approach is to register a TemplateEditingListener to get notified when the template has stopped running. However, it's not clear how to retrieve the selected/typed variable value. Am I supposed to just walk PSI?
3) When is TemplateEditingListener#editingCancelled() fired? Using ESC during live template fires templateFinished().
4) After I record a manually entered value (and validate it?), I want to persist it, and add it to the list of suggestions to use when the action is run next time. Is there some generic services to register/query naming proposals, or am I supposed to implement this myself? I'm asking because the Java editor seems to remember used variable names for a type..
5) Last but not least, it would be nice if Templates were in OpenAPI. Perhaps just a subset of the features, and in the "source-but-no-javadoc" style?
Please sign in to leave a comment.