Open
Description
Consider the following (taken from https://docs.groovy-lang.org/latest/html/documentation/#_macro_methods):
src/main/macros/MacroMethod.groovy
package macros
import groovy.transform.*
import org.codehaus.groovy.ast.expr.*
import org.codehaus.groovy.macro.runtime.*
import static org.codehaus.groovy.ast.tools.GeneralUtils.*
@AutoFinal @CompileStatic
class MacroMethod {
@Macro
static Expression safe(MacroContext ctxt, MethodCallExpression call) {
ternaryX(notNullX(call.objectExpression), call, nullX())
}
}
META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule
moduleName=whatever
moduleVersion=1.0.0-SNAPSHOT
extensionClasses=macros.MacroMethod
script.groovy (in another project)
def objExp = null
def hashCode = safe(objExp.hashCode())
assert safe(hashCode.toString()) == null
Calls to macro method "safe" have default highlighting and make reference to MacroStub
. It would be nice to have similar coloration to extension methods (DGMs) and have code navigation back to the actual macro method.