net.sourceforge.pmd.symboltable

Interface Scope

public interface Scope

Provides methods which all scopes must implement

See JLS 6.3 for a description of scopes

Method Summary
voidaddDeclaration(ClassNameDeclaration decl)
Add a class declaration to this scope
voidaddDeclaration(VariableNameDeclaration decl)
Add a variable declaration to this scope
voidaddDeclaration(MethodNameDeclaration decl)
Add a method declaration to this scope
NameDeclarationaddVariableNameOccurrence(NameOccurrence occ)
Adds a NameOccurrence to this scope - only call this after getting a true back from contains()
booleancontains(NameOccurrence occ)
Tests whether or not a NameOccurrence is directly contained in the scope Note that this search is just for this scope - it doesn't go diving into any child scopes.
Map<ClassNameDeclaration,List<NameOccurrence>>getClassDeclarations()
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope
ClassScopegetEnclosingClassScope()
Goes searching up the tree for this scope's enclosing ClassScope This is handy if you're buried down in a LocalScope and need to hop up to the ClassScope to find a method name.
MethodScopegetEnclosingMethodScope()
Goes searching up the tree for this scope's enclosing MethodScope This is handy if you're buried down in a LocalScope and need to hop up to the MethodScope to find a method parameter.
SourceFileScopegetEnclosingSourceFileScope()
Goes searching up the tree for this scope's enclosing SourceFileScope This is handy if you're buried down in a LocalScope and need to hop up to the SourceFileScope to find a class name.
ScopegetParent()
Retrieves this scope's parent
Map<VariableNameDeclaration,List<NameOccurrence>>getVariableDeclarations()
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope
voidsetParent(Scope parent)
Points this scope to its parent

Method Detail

addDeclaration

public void addDeclaration(ClassNameDeclaration decl)
Add a class declaration to this scope

addDeclaration

public void addDeclaration(VariableNameDeclaration decl)
Add a variable declaration to this scope

addDeclaration

public void addDeclaration(MethodNameDeclaration decl)
Add a method declaration to this scope

addVariableNameOccurrence

public NameDeclaration addVariableNameOccurrence(NameOccurrence occ)
Adds a NameOccurrence to this scope - only call this after getting a true back from contains()

contains

public boolean contains(NameOccurrence occ)
Tests whether or not a NameOccurrence is directly contained in the scope Note that this search is just for this scope - it doesn't go diving into any child scopes.

getClassDeclarations

public Map<ClassNameDeclaration,List<NameOccurrence>> getClassDeclarations()
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope

getEnclosingClassScope

public ClassScope getEnclosingClassScope()
Goes searching up the tree for this scope's enclosing ClassScope This is handy if you're buried down in a LocalScope and need to hop up to the ClassScope to find a method name.

getEnclosingMethodScope

public MethodScope getEnclosingMethodScope()
Goes searching up the tree for this scope's enclosing MethodScope This is handy if you're buried down in a LocalScope and need to hop up to the MethodScope to find a method parameter.

getEnclosingSourceFileScope

public SourceFileScope getEnclosingSourceFileScope()
Goes searching up the tree for this scope's enclosing SourceFileScope This is handy if you're buried down in a LocalScope and need to hop up to the SourceFileScope to find a class name.

getParent

public Scope getParent()
Retrieves this scope's parent

getVariableDeclarations

public Map<VariableNameDeclaration,List<NameOccurrence>> getVariableDeclarations()
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope

setParent

public void setParent(Scope parent)
Points this scope to its parent