Class VariableScope

java.lang.Object
org.codehaus.groovy.ast.VariableScope

public class VariableScope
extends Object
Records declared and referenced variabes for a given scope. Helps determine variable sharing across closure and method boundaries.
  • Constructor Details

    • VariableScope

      public VariableScope()
    • VariableScope

      public VariableScope​(VariableScope parent)
  • Method Details

    • getParent

      public VariableScope getParent()
    • isRoot

      public boolean isRoot()
    • getClassScope

      public ClassNode 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

      public void setClassScope​(ClassNode classScope)
    • isInStaticContext

      public boolean isInStaticContext()
    • setInStaticContext

      public void setInStaticContext​(boolean inStaticContext)
    • getDeclaredVariable

      public Variable getDeclaredVariable​(String name)
    • getReferencedLocalVariable

      public Variable getReferencedLocalVariable​(String name)
    • getReferencedClassVariable

      public Variable getReferencedClassVariable​(String name)
    • isReferencedLocalVariable

      public boolean isReferencedLocalVariable​(String name)
    • isReferencedClassVariable

      public boolean isReferencedClassVariable​(String name)
    • getDeclaredVariables

      public Map<String,​Variable> 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

      public Map<String,​Variable> 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

      public Iterator<Variable> getDeclaredVariablesIterator()
      Gets an iterator for the declared class variables. The remove operation is not supported.
      Returns:
      an iterator for the declared variables
    • getReferencedLocalVariablesIterator

      public Iterator<Variable> getReferencedLocalVariablesIterator()
      Gets an iterator for the referenced local variables. The remove operation *is* supported.
      Returns:
      an iterator for the referenced local variables
    • getReferencedClassVariablesIterator

      public Iterator<Variable> getReferencedClassVariablesIterator()
      Gets an iterator for the referenced class variables. The remove operation is not supported.
      Returns:
      an iterator for the referenced class variables
    • putDeclaredVariable

      public void putDeclaredVariable​(Variable var)
    • putReferencedLocalVariable

      public void putReferencedLocalVariable​(Variable var)
    • putReferencedClassVariable

      public void putReferencedClassVariable​(Variable var)
    • removeReferencedClassVariable

      public Object removeReferencedClassVariable​(String name)
    • copy

      public VariableScope copy()