Package org.codehaus.groovy.ast.expr
Interface ExpressionTransformer
- All Known Implementing Classes:
ClassCodeExpressionTransformer,FieldASTTransformation,JavaAwareResolveVisitor,NewifyASTTransformation,OperatorRenameASTTransformation,OptimizerVisitor,ResolveVisitor,StaticCompilationTransformer,StaticImportVisitor,VariableExpressionTransformer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for transforming
Expression nodes during AST traversal and manipulation.
This transformer interface enables expression-level transformations in AST processing. Implementations typically take an input expression and return a (possibly modified) expression. This can be used for:
- Code generation and transformation passes
- Expression normalization or optimization
- Type-driven transformation in static type checking
- Custom DSL implementation and metaprogramming
Transformers may return:
- The same expression instance unchanged
- A new expression of the same type with modified properties
- A completely different expression type
- Null if the expression should be removed (usage-dependent)
This is a functional interface and can be implemented as a lambda expression.
-
Method Summary
Modifier and TypeMethodDescriptiontransform(Expression expression) Transforms the given expression.
-
Method Details
-
transform
Transforms the given expression.- Parameters:
expression- the expression to transform, may be null- Returns:
- the transformed expression, may be the same instance, a new instance, or null
-