Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Information Provided
-
None
-
None
-
None
-
None
Description
E.g.
class SomeClass { def someClosureField = { // Expressions are NOT visited by ClassCodeExpressionTransformer.transform(Expression) } def someMethod() { // Expressions are visited by ClassCodeExpressionTransformer.transform(Expression) 3.times { // Expressions are NOT visited by ClassCodeExpressionTransformer.transform(Expression) } def someClosureVar = { // Expressions are NOT visited by ClassCodeExpressionTransformer.transform(Expression) } } }
Is this current behaviour by design or is it a bug? If it is by design, it seems to be quite a gotcha (also caused GROOVY-6932 & GROOVY-6434) - probably should be noted in the doc?
Below is my current workaround(??) - is this the expected way to work with ClassCodeExpressionTransformer?
class MyAstTransformer extends ClassCodeExpressionTransformer { Expression transform(Expression expression) { // Some code to deal with specific expression classes... ... if (expression instanceof ClosureExpression) { expression.visit(this) } super.transform(expression); } }
Attachments
Issue Links
- is related to
-
GROOVY-6434 @Newify AST transformation doesn't work for closure
- Closed
-
GROOVY-6932 @Log annotation does not check logging enablement inside closures
- Closed
- links to