Expanding Macros

You can expand macros in a string in conjunction with a Context. Use the MacroRegistry.expand(String,oracle.ide.Context,boolean) method to perform an expansion. Any recognized escaped macro strings in the specified string will be expanded using the relevant MacroExpander.expand(Context ) method. For example, if the string "This is a ${macro.expansion} test" is passed as the first parameter, and there is a MacroExpander instance registered with the MacroRegistry with a getMacro() method that returns "macro.expansion", then that portion of the original string will be replaced with the return value of expand() on the MacroExpander instance.

Registering Custom Macros

Extensions can easily plug additional macros into external tools. Write a class that implements the MacroExpander interface, then register it in extension.xml. The following example code demonstrates a simple MacroExpander implementation and the registration code.