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?

Comment actions Permalink

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

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:

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.

Comment actions Permalink

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



Please sign in to leave a comment.