Custom macro

Is it possible to create (a plugin that that provides) a custom macro in File > Settings > Tools > External Tools > Create Tool > Insert Macro ?

I see that all macros there extend com.intellij.ide.macro.Macro and I already created myne to extend it as well. However there should be a way to register it to be displayed in the UI.
The problem is that the default macros are registered within MacroManager.registerMacro() which is a private method and I can not use it. Perhaps I have to use plugin.xml somehow?

3 comments
Comment actions Permalink

Add a line to plugin.xml:
<macro implementation="Full class name of your implementation"/>

0
Comment actions Permalink

Hi Vassiliy,

thanks, but I already tried that without success. The problem is that IDEA tries to register my macro with internal call to MacroManager.registerMacro(), which first has a check if the macro is one of several predefined once:

assert PathMacrosImpl.getToolMacroNames().contains(macro.getName()) : "Macro '" + macro.getName() + "' should be registered in PathMacros!";


(see details here: https://github.com/JetBrains/intellij-community/blob/210e0ed138627926e10094bb9c76026319cec178/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java#L106)

So far the only way I found to overcome this is to name my macro as one of the macros predefined in PathMacrosImpl.getToolMacroNames(), which is actually a hack.
So looking at this assert statement, it looks like creating custom macros is not currently supported. I was curious if anyone in the forum has achived this.



0
Comment actions Permalink

I've logged an issue regarding this topic. Please feel free to vote for it.

 

https://youtrack.jetbrains.com/issue/IDEA-153788

 

0

Please sign in to leave a comment.