Hi all,
I'm quite interested on the @Macro possibilities described here:
https://groovy-lang.org/releasenotes/groovy-2.5.html
But I'm having some troubles in understanding how to use it.
My final goal is some check functions, that write in a file some pair
(expression, value).
And from what I found, this seems to be quite perfect.
I prepared this initial test:
--------------------
package alberto.test;
import org.codehaus.groovy.macro.runtime.Macro;
import org.codehaus.groovy.macro.runtime.MacroContext;
import org.codehaus.groovy.ast.expr.Expression;
import org.codehaus.groovy.ast.expr.EmptyExpression;
class Test {
@Macro
static Expression softCheck(MacroContext ctx, Expression exp,
Expression msg) {
return new EmptyExpression();
}
}
--------------------
And created the file
META-INF/groovy/org.codehaus.groovy.runtime.ExtensionMethods
With the content: extensionClasses= alberto.test.Test
Then I tried: softCheck()
Expecting it to go trough without any effect.
Instead I got a complaint that softCheck in not applicable for empty list
arguments.
Trying to use Test.softChek() gave me similar results, proposing (ctx,
exp, msg) as arguments.
Am I missing something to activate the @Macro behaviour?
Thank you and Best Regards,
Alberto