public class VariableExpression extends Expression
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Modifiers | Name | Description |
---|---|---|
static VariableExpression |
SUPER_EXPRESSION |
|
static VariableExpression |
THIS_EXPRESSION |
Constructor and description |
---|
VariableExpression
(String variable, ClassNode type) |
VariableExpression
(String variable) |
VariableExpression
(Variable variable) |
Type | Name and description |
---|---|
Variable |
getAccessedVariable() |
Expression |
getInitialExpression() |
int |
getModifiers() |
String |
getName() |
ClassNode |
getOriginType() Returns the type which was used when this variable expression was created. |
String |
getText() |
ClassNode |
getType() |
boolean |
hasInitialExpression() |
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() |
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. |
String |
toString() |
Expression |
transformExpression(ExpressionTransformer transformer) |
void |
visit(GroovyCodeVisitor visitor) |
Methods inherited from class | Name |
---|---|
class Expression |
getType, setType, transformExpression, transformExpressions, transformExpressions |
class AnnotatedNode |
addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic |
class ASTNode |
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getNodeMetaData, getNodeMetaData, getText, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePosition, visit |
class Object |
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Returns 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.
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.
For internal use only. This flag is used by compiler internals and should probably be converted to a node metadata in future.
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. The variable expression inside the closure references an accessed variable "str" which must have the closure shared flag set.
inClosure
- tells if this variable is later referenced in a closureSet the type of this variable. If you call this method from an AST transformation and that the 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
cn
- the type to be set on this variableFor internal use only. This flag is used by compiler internals and should probably be converted to a node metadata in future.
Copyright © 2003-2015 The Apache Software Foundation. All rights reserved.