Dear all,
I'm trying to write a global transformation for my DSL to apply a custom
logic on binary expression. For example:
@GroovyASTTransformation(phase = CompilePhase.CONVERSION)
class FooXformImpl implements ASTTransformation {
SourceUnit unit
@Override
void visit(ASTNode[] nodes, SourceUnit source) {
this.unit = unit
createVisitor().visitClass((ClassNode)nodes[1])
}
protected ClassCodeExpressionTransformer createVisitor() {
new ClassCodeExpressionTransformer() {
protected SourceUnit getSourceUnit() { unit }
Expression transform(Expression expr) {
if( expr.class == BinaryExpression ) {
return .. // my replacement where
}
super.transform(expr)
}
}
}
}
The transformation is correctly applied, however it turns out the
expressions nested in a closure definition are *not* visited. Therefore the
above transformation is not applied to binary expressions inside a closure.
Is that expected? How to manage this use case ?
Cheers,
Paolo