org.codehaus.groovy.ast.expr
public class DeclarationExpression extends BinaryExpression
| Constructor and Description |
|---|
DeclarationExpression(Expression left,
Token operation,
Expression right)
Creates a DeclarationExpression for Expressions like "def (x, y) = [1, 2]"
|
DeclarationExpression(VariableExpression left,
Token operation,
Expression right)
Creates a DeclarationExpression for VariableExpressions like "def x" or "String y = 'foo'".
|
| Modifier and Type | Method and Description |
|---|---|
TupleExpression |
getTupleExpression()
This method returns the left hand side of the declaration cast to the TupleExpression type.
|
VariableExpression |
getVariableExpression()
This method returns the left hand side of the declaration cast to the VariableExpression type.
|
boolean |
isMultipleAssignmentDeclaration()
This method tells you if this declaration is a multiple assignment declaration, which
has the form "def (x, y) = ..." in Groovy.
|
void |
setLeftExpression(Expression leftExpression)
This method sets the leftExpression for this BinaryExpression.
|
void |
setRightExpression(Expression rightExpression) |
Expression |
transformExpression(ExpressionTransformer transformer)
Return a copy of the expression calling the transformer on any nested expressions
|
void |
visit(GroovyCodeVisitor visitor) |
getLeftExpression, getOperation, getRightExpression, getText, newAssignmentExpression, newInitializationExpression, toStringgetType, setType, transformExpressions, transformExpressionsaddAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSyntheticcopyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePositionpublic DeclarationExpression(VariableExpression left, Token operation, Expression right)
left - the left hand side of a variable declarationoperation - the operation, typically an assignment operatorright - the right hand side of a declarationpublic DeclarationExpression(Expression left, Token operation, Expression right)
left - the left hand side of a declaration. Must be either a VariableExpression or
a TupleExpression with at least one element.operation - the operation, typically an assignment operatorright - the right hand side of a declarationpublic void visit(GroovyCodeVisitor visitor)
visit in class BinaryExpressionpublic VariableExpression getVariableExpression()
ClassCastException - if the left hand side is not a VariableExpression (and is probably a multiple assignment statement).public TupleExpression getTupleExpression()
ClassCastException - if the left hand side is not a TupleExpression (and is probably a VariableExpression).public void setLeftExpression(Expression leftExpression)
setLeftExpression in class BinaryExpressionleftExpression - either a VariableExpression or a TupleExpression with one or more elements.public void setRightExpression(Expression rightExpression)
setRightExpression in class BinaryExpressionpublic Expression transformExpression(ExpressionTransformer transformer)
ExpressiontransformExpression in class BinaryExpressionpublic boolean isMultipleAssignmentDeclaration()