Package org.codehaus.groovy.ast.expr
Class VariableExpression
java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.expr.Expression
org.codehaus.groovy.ast.expr.VariableExpression
- All Implemented Interfaces:
- GroovydocHolder<AnnotatedNode>,- Cloneable,- NodeMetaDataHandler,- Variable
Represents a local variable, the simplest form of expression. e.g. "foo".
- 
Field SummaryFieldsFields inherited from class org.codehaus.groovy.ast.expr.ExpressionEMPTY_ARRAYFields inherited from interface groovy.lang.groovydoc.GroovydocHolderDOC_COMMENT
- 
Constructor SummaryConstructorsConstructorDescriptionVariableExpression(String name) VariableExpression(String name, ClassNode type) 
- 
Method SummaryModifier and TypeMethodDescriptionclone()Returns the expression used to initialize the variable or null of there is no initialization.intgetName()Returns the name of the variable.Returns the type which was used when this variable expression was created.getText()getType()Returns the type of the variable.booleanReturns true if there is an initialization expression.booleanTells if this variable or the accessed variable is used in a closure context, like in the following example :booleanbooleanReturns true if this variable is used in a static context.booleanbooleanbooleanFor internal use only.voidsetAccessedVariable(Variable variable) voidsetClosureSharedVariable(boolean inClosure) Use this method to tell if a variable is used in a closure, like in the following example:voidsetInStaticContext(boolean inStaticContext) voidsetModifiers(int modifiers) voidSet the type of this variable.voidsetUseReferenceDirectly(boolean useRef) For internal use only.toString()transformExpression(ExpressionTransformer transformer) Transforms this expression and any nested expressions.voidvisit(GroovyCodeVisitor visitor) Methods inherited from class org.codehaus.groovy.ast.expr.ExpressiontransformExpressions, transformExpressionsMethods inherited from class org.codehaus.groovy.ast.AnnotatedNodeaddAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSyntheticMethods inherited from class org.codehaus.groovy.ast.ASTNodecopyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandlercopyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaDataMethods inherited from interface org.codehaus.groovy.ast.VariableisFinal, isPrivate, isProtected, isPublic, isStatic, isVolatile
- 
Field Details- 
THIS_EXPRESSION
- 
SUPER_EXPRESSION
 
- 
- 
Constructor Details- 
VariableExpression
- 
VariableExpression
- 
VariableExpression
 
- 
- 
Method Details- 
clone
- 
setAccessedVariable
- 
setInStaticContextpublic void setInStaticContext(boolean inStaticContext) 
- 
setModifierspublic void setModifiers(int modifiers) 
- 
setTypeSet the type of this variable. If you call this method from an AST transformation and that theaccessed variableis (shared, this operation is unsafe and may lead to a verify error at compile time. Instead, set the type of theaccessed variable- Overrides:
- setTypein class- Expression
 
- 
setUseReferenceDirectlypublic void setUseReferenceDirectly(boolean useRef) For internal use only. This flag is used by compiler internals and should probably be converted to a node metadata in the future.
- 
getAccessedVariable
- 
getInitialExpressionDescription copied from interface:VariableReturns the expression used to initialize the variable or null of there is no initialization.- Specified by:
- getInitialExpressionin interface- Variable
 
- 
hasInitialExpressionpublic boolean hasInitialExpression()Description copied from interface:VariableReturns true if there is an initialization expression.- Specified by:
- hasInitialExpressionin interface- Variable
 
- 
getModifierspublic int getModifiers()- Specified by:
- getModifiersin interface- Variable
 
- 
getNameDescription copied from interface:VariableReturns the name of the variable.
- 
getText
- 
getTypeDescription copied from interface:VariableReturns the type of the variable.- Specified by:
- getTypein interface- Variable
- Overrides:
- getTypein class- Expression
 
- 
getOriginTypeReturns the type which was used when this variable expression was created. For example,getType()may return a boxed type while this method would return the primitive type.- Specified by:
- getOriginTypein interface- Variable
- Returns:
- the type which was used to define this variable expression
 
- 
isDynamicTypedpublic boolean isDynamicTyped()- Specified by:
- isDynamicTypedin interface- Variable
 
- 
isInStaticContextpublic boolean isInStaticContext()Description copied from interface:VariableReturns true if this variable is used in a static context. A static context is any static initializer block, when this variable is declared as static or when this variable is used in a static method- Specified by:
- isInStaticContextin interface- Variable
 
- 
isSuperExpressionpublic boolean isSuperExpression()
- 
isThisExpressionpublic boolean isThisExpression()
- 
isUseReferenceDirectlypublic boolean isUseReferenceDirectly()For internal use only. This flag is used by compiler internals and should probably be converted to a node metadata in the future.
- 
toString
- 
transformExpressionDescription copied from class:ExpressionTransforms this expression and any nested expressions.- Specified by:
- transformExpressionin class- Expression
 
- 
visit
 
-