|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.expr.Expression
org.codehaus.groovy.ast.expr.VariableExpression
public class VariableExpression
Represents a local variable name, the simplest form of expression. e.g. "foo".
| Field Summary | |
|---|---|
static VariableExpression |
SUPER_EXPRESSION
|
static VariableExpression |
THIS_EXPRESSION
|
| Constructor Summary | |
|---|---|
VariableExpression(java.lang.String variable)
|
|
VariableExpression(java.lang.String variable,
ClassNode type)
|
|
VariableExpression(Variable variable)
|
|
| Method Summary | |
|---|---|
Variable |
getAccessedVariable()
|
Expression |
getInitialExpression()
expression used to initialize the variable or null of there is no initialization. |
int |
getModifiers()
|
java.lang.String |
getName()
the name of the variable |
ClassNode |
getOriginType()
Returns the type which was used when this variable expression was created. |
java.lang.String |
getText()
|
ClassNode |
getType()
the type of the variable |
boolean |
hasInitialExpression()
returns true if there is an initialization expression |
boolean |
isClosureSharedVariable()
Tells if this variable or the accessed variable is used in a closure context, like in the following example : def str = 'Hello' def cl = { println str } The "str" variable is closure shared. |
boolean |
isDynamicTyped()
|
boolean |
isInStaticContext()
returns true if this variable is used in a static context. |
boolean |
isSuperExpression()
|
boolean |
isThisExpression()
|
boolean |
isUseReferenceDirectly()
For internal use only. |
void |
setAccessedVariable(Variable origin)
|
void |
setClosureSharedVariable(boolean inClosure)
Use this method to tell if a variable is used in a closure, like in the following example: def str = 'Hello' def cl = { println str } The "str" variable is closure shared. |
void |
setInStaticContext(boolean inStaticContext)
|
void |
setModifiers(int modifiers)
|
void |
setType(ClassNode cn)
Set the type of this variable. |
void |
setUseReferenceDirectly(boolean useRef)
For internal use only. |
java.lang.String |
toString()
|
Expression |
transformExpression(ExpressionTransformer transformer)
Return a copy of the expression calling the transformer on any nested expressions |
void |
visit(GroovyCodeVisitor visitor)
|
| Methods inherited from class org.codehaus.groovy.ast.expr.Expression |
|---|
transformExpressions, transformExpressions |
| Methods inherited from class org.codehaus.groovy.ast.AnnotatedNode |
|---|
addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic |
| Methods inherited from class org.codehaus.groovy.ast.ASTNode |
|---|
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getNodeMetaData, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePosition |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final VariableExpression THIS_EXPRESSION
public static final VariableExpression SUPER_EXPRESSION
| Constructor Detail |
|---|
public VariableExpression(java.lang.String variable,
ClassNode type)
public VariableExpression(java.lang.String variable)
public VariableExpression(Variable variable)
| Method Detail |
|---|
public Variable getAccessedVariable()
public void setAccessedVariable(Variable origin)
public void visit(GroovyCodeVisitor visitor)
visit in class ASTNodepublic Expression transformExpression(ExpressionTransformer transformer)
Expression
transformExpression in class Expressionpublic java.lang.String getText()
getText in class ASTNodepublic java.lang.String getName()
Variable
getName in interface Variablepublic java.lang.String toString()
toString in class java.lang.Objectpublic Expression getInitialExpression()
Variable
getInitialExpression in interface Variablepublic boolean hasInitialExpression()
Variable
hasInitialExpression in interface Variablepublic boolean isInStaticContext()
Variable
isInStaticContext in interface Variablepublic void setInStaticContext(boolean inStaticContext)
public void setType(ClassNode cn)
accessed variable is (shared,
this operation is unsafe and may lead to a verify error at compile time. Instead, set the type of
the accessed variable
setType in class Expressioncn - the type to be set on this variablepublic boolean isDynamicTyped()
isDynamicTyped in interface Variablepublic boolean isClosureSharedVariable()
def str = 'Hello'
def cl = { println str }
The "str" variable is closure shared.
isClosureSharedVariable in interface Variablepublic void setClosureSharedVariable(boolean inClosure)
def str = 'Hello'
def cl = { println str }
The "str" variable is closure shared. The variable expression inside the closure references an
accessed variable "str" which must have the closure shared flag set.
setClosureSharedVariable in interface VariableinClosure - tells if this variable is later referenced in a closurepublic int getModifiers()
getModifiers in interface Variablepublic void setUseReferenceDirectly(boolean useRef)
useRef - public boolean isUseReferenceDirectly()
public ClassNode getType()
Variable
getType in interface VariablegetType in class Expressionpublic ClassNode getOriginType()
getType() may return a boxed type while this method would return the primitive type.
getOriginType in interface Variablepublic boolean isThisExpression()
public boolean isSuperExpression()
public void setModifiers(int modifiers)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||