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:

  1. What did I do wrong, and how can I get it to expand to something? A hardcoded string is fine for start.

  2. 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.

5 comments
Comment actions Permalink

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?

0
Comment actions Permalink

E.g. ]]> in
extensions tag of plugin.xml

Alexander Strotzky wrote:

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?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

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.

0
Comment actions Permalink

E.g. Extensions.getRootArea().getExtensionPoint(...).registerExtension(...);
Open source JavaScript macro implementation should have been easing your
open api exploring pain :(

Alexander Strotzky wrote:

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()?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

thank you.

The initial pain is almost over now :)

0

Please sign in to leave a comment.