public abstract class Expression
extends AnnotatedNode
Base class for all expression nodes in the Groovy AST. Expressions represent values and computations that can be evaluated at runtime, supporting type information and transformation operations. All concrete expression types inherit from this abstract class and must implement the transformExpression(ExpressionTransformer) method for AST transformation support.
| Modifiers | Name | Description |
|---|---|---|
static Expression[] |
EMPTY_ARRAY |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public ClassNode |
getType()Returns the type of this expression. |
|
public void |
setType(ClassNode type)Sets the type information for this expression. |
|
public abstract Expression |
transformExpression(ExpressionTransformer transformer)Transforms this expression and any nested expressions according to the provided transformer. |
|
protected List<Expression> |
transformExpressions(List<? extends Expression> expressions, ExpressionTransformer transformer)Transforms a list of expressions by applying the provided transformer to each element. |
<T extends Expression> |
protected List<T> |
transformExpressions(List<? extends Expression> expressions, ExpressionTransformer transformer, Class<T> targetType)Transforms a list of expressions and verifies that all transformed expressions have a specific type. |
| Methods inherited from class | Name |
|---|---|
class AnnotatedNode |
addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic |
class ASTNode |
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit |
Returns the type of this expression. If the type has not been explicitly set, this method returns a dynamic type to support dynamic typing.
Sets the type information for this expression. Used during type checking and compilation phases to associate a specific type with this expression result.
type - the ClassNode representing this expression's typeTransforms this expression and any nested expressions according to the provided transformer. This method is called during AST transformation phases and must recursively transform any nested expressions to support full AST tree transformation.
transformer - the ExpressionTransformer to applyTransforms a list of expressions by applying the provided transformer to each element. Handles null expressions gracefully by including them in the result.
expressions - the list of Expressions to transformtransformer - the ExpressionTransformer to applyTransforms a list of expressions and verifies that all transformed expressions have a specific type. This variant provides type safety during transformations by enforcing that transformed expressions conform to a target type. Throws GroovyBugError if any expression has an incompatible type.
expressions - the list of Expressions to transformtransformer - the ExpressionTransformer to applytargetType - the expected type of all transformed expressionsT - the target expression type parameter