Package org.codehaus.groovy.ast
Class VariableScope
java.lang.Object
org.codehaus.groovy.ast.VariableScope
public class VariableScope
extends java.lang.Object
Records declared and referenced variabes for a given scope. Helps determine
variable sharing across closure and method boundaries.
-
Constructor Summary
Constructors Constructor Description VariableScope()VariableScope(VariableScope parent) -
Method Summary
Modifier and Type Method Description VariableScopecopy()ClassNodegetClassScope()Non-null iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.VariablegetDeclaredVariable(java.lang.String name)java.util.Map<java.lang.String,Variable>getDeclaredVariables()Gets a map containing the variables declared in this scope.java.util.Iterator<Variable>getDeclaredVariablesIterator()Gets an iterator for the declared class variables.VariableScopegetParent()VariablegetReferencedClassVariable(java.lang.String name)java.util.Map<java.lang.String,Variable>getReferencedClassVariables()Gets a map containing the class variables referenced by this scope.java.util.Iterator<Variable>getReferencedClassVariablesIterator()Gets an iterator for the referenced class variables.VariablegetReferencedLocalVariable(java.lang.String name)intgetReferencedLocalVariablesCount()java.util.Iterator<Variable>getReferencedLocalVariablesIterator()Gets an iterator for the referenced local variables.booleanisClassScope()Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.booleanisInStaticContext()booleanisReferencedClassVariable(java.lang.String name)booleanisReferencedLocalVariable(java.lang.String name)booleanisRoot()voidputDeclaredVariable(Variable var)voidputReferencedClassVariable(Variable var)voidputReferencedLocalVariable(Variable var)java.lang.ObjectremoveReferencedClassVariable(java.lang.String name)voidsetClassScope(ClassNode classScope)voidsetInStaticContext(boolean inStaticContext)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
VariableScope
public VariableScope() -
VariableScope
-
-
Method Details
-
getParent
-
isRoot
public boolean isRoot() -
getClassScope
Non-null iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc. -
isClassScope
public boolean isClassScope()Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc. -
setClassScope
-
isInStaticContext
public boolean isInStaticContext() -
setInStaticContext
public void setInStaticContext(boolean inStaticContext) -
getDeclaredVariable
-
getReferencedLocalVariable
-
getReferencedClassVariable
-
isReferencedLocalVariable
public boolean isReferencedLocalVariable(java.lang.String name) -
isReferencedClassVariable
public boolean isReferencedClassVariable(java.lang.String name) -
getDeclaredVariables
Gets a map containing the variables declared in this scope. This map cannot be modified.- Returns:
- a map containing the declared variable references
-
getReferencedClassVariables
Gets a map containing the class variables referenced by this scope. This not can not be modified.- Returns:
- a map containing the class variable references
-
getReferencedLocalVariablesCount
public int getReferencedLocalVariablesCount() -
getDeclaredVariablesIterator
Gets an iterator for the declared class variables. The remove operation is not supported.- Returns:
- an iterator for the declared variables
-
getReferencedLocalVariablesIterator
Gets an iterator for the referenced local variables. The remove operation *is* supported.- Returns:
- an iterator for the referenced local variables
-
getReferencedClassVariablesIterator
Gets an iterator for the referenced class variables. The remove operation is not supported.- Returns:
- an iterator for the referenced class variables
-
putDeclaredVariable
-
putReferencedLocalVariable
-
putReferencedClassVariable
-
removeReferencedClassVariable
public java.lang.Object removeReferencedClassVariable(java.lang.String name) -
copy
-