how to use the new live templates API?
Hello,
I tried to use the new API for live templates, but I can't get it to work.
Here's what I tried:
Plugin name here short description of the plugin 1.0 YourCompany ]]>
When I run a plugin run configuration I see the macro in the list ("some description"), but when used, it expands to the empty string.
Questions:
What did I do wrong, and how can I get it to expand to something? A hardcoded string is fine for start.
Is it possible to register an extension at runtime, something like ExtensionsRegistry.registerNewExtension("com.intellij.liveTemplateMacro", net.mycompany.stuff.MyMacro.class) ?
And now a question regarding a painfull issue. Javadocs.
I understand the OpenAPI has grown large and would take a long time to document it all, but can you, please, add javadocs for new stuff?
Basic info to get someone started wouldn't take a lot of time (for new APIs) and would be great.
Missing javadocs is especially a problem in closed-source applications, because I can't find out what's expected from an interface without reading the code using it, which I can't.
By the way, liveTemplateMacro is unrecognized in plugin.xml. Probably the resources.jar!/META-INF/plugin.xml needs to be updated.
Thank you,
Alexander Strotzky
EDIT: forgot to add: during expansion (press Tab), none of the methods in MyMacro are being called which seems a little strange to me - verified with the debugger.
The only method that is being called is getDescription() and that's only when I open the Live Templates configuration dialog.
Please sign in to leave a comment.
Nothing?
If you don't provide javadocs at least answer the forum questions... :(
Decompiling is not my ideea of fun.
For the second question:
- would a com.intellij.codeInsight.template.macro.MacroFactory.register() be enough?
- is this (closed) API stable enough? Can I base a plugin on it?
E.g. ]]> in
extensions tag of plugin.xml
Alexander Strotzky wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
If you look at the example above, I already did that.
The actual problem (after a lot of trial & error) was that getDescription() should return something like "myMacro(VAR)" - if I want one param to my macro.
What about the question concerning MacroFactory.register()?
And sorry to bug you again... when will calculateQuickResult() be called? Because in my tests only calculateResult() got called.
E.g. Extensions.getRootArea().getExtensionPoint(...).registerExtension(...);
Open source JavaScript macro implementation should have been easing your
open api exploring pain :(
Alexander Strotzky wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
thank you.
The initial pain is almost over now :)