Top Description Fields Constructors Methods
org.codehaus.groovy.ast

public Class VariableScope

extends Object
Class Inheritance
Imports
java.util.Collections, .Iterator, .LinkedHashMap, .Map

Records declared and referenced variabes for a given scope. Helps determine variable sharing across closure and method boundaries.

Field Summary

Modifier and TypeField and Description
private ClassNode
private Map<String, Variable>
private boolean
private VariableScope
private Map<String, Variable>
private Map<String, Variable>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public VariableScope
copy()

public ClassNode
getClassScope()

Non-null iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.

public Variable
public Map<String, Variable>

Returns:

a map containing the declared variable references
getDeclaredVariables
()

Gets a map containing the variables declared in this scope.

public Iterator<Variable>

Returns:

an iterator for the declared variables
getDeclaredVariablesIterator
()

Gets an iterator for the declared class variables.

public VariableScope
public Variable
public Map<String, Variable>

Returns:

a map containing the class variable references
getReferencedClassVariables
()

Gets a map containing the class variables referenced by this scope.

public Iterator<Variable>

Returns:

an iterator for the referenced class variables
getReferencedClassVariablesIterator
()

Gets an iterator for the referenced class variables.

public Variable
public int
public Iterator<Variable>

Returns:

an iterator for the referenced local variables
getReferencedLocalVariablesIterator
()

Gets an iterator for the referenced local variables.

public boolean
isClassScope()

Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.

public boolean
public boolean
public boolean
public boolean
public void
public void
public void
public Object
public void
setClassScope(final ClassNode classScope)

public void
setInStaticContext(final boolean inStaticContext)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classScopeback to summary
private ClassNode classScope
declaredVariablesback to summary
private Map<String, Variable> declaredVariables
inStaticContextback to summary
private boolean inStaticContext
parentback to summary
private VariableScope parent
referencedClassVariablesback to summary
private Map<String, Variable> referencedClassVariables
referencedLocalVariablesback to summary
private Map<String, Variable> referencedLocalVariables

Constructor Detail

VariableScopeback to summary
public VariableScope()
VariableScopeback to summary
public VariableScope(final VariableScope parent)

Method Detail

copyback to summary
public VariableScope copy()
getClassScopeback to summary
public ClassNode getClassScope()

Non-null iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.

getDeclaredVariableback to summary
public Variable getDeclaredVariable(final String name)
getDeclaredVariablesback to summary
public Map<String, Variable> getDeclaredVariables()

Gets a map containing the variables declared in this scope. This map cannot be modified.

Returns:Map<String, Variable>

a map containing the declared variable references

getDeclaredVariablesIteratorback to summary
public Iterator<Variable> getDeclaredVariablesIterator()

Gets an iterator for the declared class variables. The remove operation is not supported.

Returns:Iterator<Variable>

an iterator for the declared variables

getParentback to summary
public VariableScope getParent()
getReferencedClassVariableback to summary
public Variable getReferencedClassVariable(final String name)
getReferencedClassVariablesback to summary
public Map<String, Variable> getReferencedClassVariables()

Gets a map containing the class variables referenced by this scope. This not can not be modified.

Returns:Map<String, Variable>

a map containing the class variable references

getReferencedClassVariablesIteratorback to summary
public Iterator<Variable> getReferencedClassVariablesIterator()

Gets an iterator for the referenced class variables. The remove operation is not supported.

Returns:Iterator<Variable>

an iterator for the referenced class variables

getReferencedLocalVariableback to summary
public Variable getReferencedLocalVariable(final String name)
getReferencedLocalVariablesCountback to summary
public int getReferencedLocalVariablesCount()
getReferencedLocalVariablesIteratorback to summary
public Iterator<Variable> getReferencedLocalVariablesIterator()

Gets an iterator for the referenced local variables. The remove operation *is* supported.

Returns:Iterator<Variable>

an iterator for the referenced local variables

isClassScopeback to summary
public boolean isClassScope()

Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.

isInStaticContextback to summary
public boolean isInStaticContext()
isReferencedClassVariableback to summary
public boolean isReferencedClassVariable(final String name)
isReferencedLocalVariableback to summary
public boolean isReferencedLocalVariable(final String name)
isRootback to summary
public boolean isRoot()
putDeclaredVariableback to summary
public void putDeclaredVariable(final Variable var)
putReferencedClassVariableback to summary
public void putReferencedClassVariable(final Variable var)
putReferencedLocalVariableback to summary
public void putReferencedLocalVariable(final Variable var)
removeReferencedClassVariableback to summary
public Object removeReferencedClassVariable(final String name)
setClassScopeback to summary
public void setClassScope(final ClassNode classScope)
setInStaticContextback to summary
public void setInStaticContext(final boolean inStaticContext)