Package org.codehaus.groovy.ast.expr
Class PrefixExpression
java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.expr.Expression
org.codehaus.groovy.ast.expr.PrefixExpression
- All Implemented Interfaces:
GroovydocHolder<AnnotatedNode>,NodeMetaDataHandler
Represents a prefix unary expression like
++i or --value.
The operation is applied to the expression before the value is used.
Examples:
++counter- increment counter and return new value--index- decrement index and return new value
-
Field Summary
Fields inherited from class org.codehaus.groovy.ast.expr.Expression
EMPTY_ARRAYFields inherited from interface groovy.lang.groovydoc.GroovydocHolder
DOC_COMMENT -
Constructor Summary
ConstructorsConstructorDescriptionPrefixExpression(Token operation, Expression expression) Creates a prefix expression. -
Method Summary
Modifier and TypeMethodDescriptionReturns the expression being modified by the prefix operation.Returns the operator token.getText()Returns a string representation of this prefix expression.getType()Returns the type of this prefix expression, which is the type of the operand.voidsetExpression(Expression expression) Sets the expression to apply the prefix operation to.toString()Returns a debug string representation.transformExpression(ExpressionTransformer transformer) Transforms this expression by applying the given transformer to the inner expression, creating a new prefix expression with the transformed operand.voidvisit(GroovyCodeVisitor visitor) Accepts aGroovyCodeVisitorusing the visitor pattern.Methods inherited from class org.codehaus.groovy.ast.expr.Expression
setType, transformExpressions, transformExpressionsMethods inherited from class org.codehaus.groovy.ast.AnnotatedNode
addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSyntheticMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
PrefixExpression
Creates a prefix expression.- Parameters:
operation- the operator token (++or--)expression- the expression to apply the operation to
-
-
Method Details
-
setExpression
Sets the expression to apply the prefix operation to.- Parameters:
expression- the expression, typically a variable or property
-
getExpression
Returns the expression being modified by the prefix operation.- Returns:
- the expression
-
getOperation
Returns the operator token.- Returns:
- the
++or--token
-
getText
Returns a string representation of this prefix expression. -
getType
Returns the type of this prefix expression, which is the type of the operand.- Overrides:
getTypein classExpression- Returns:
- the type of the inner expression
-
toString
Returns a debug string representation. -
transformExpression
Transforms this expression by applying the given transformer to the inner expression, creating a new prefix expression with the transformed operand.- Specified by:
transformExpressionin classExpression- Parameters:
transformer- theExpressionTransformerto apply- Returns:
- a new prefix expression with transformed inner expression
-
visit
Accepts aGroovyCodeVisitorusing the visitor pattern.
-