|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.pmd.lang.symboltable.AbstractScope
public abstract class AbstractScope
Base class for any Scope
.
Provides useful default implementations.
Constructor Summary | |
---|---|
AbstractScope()
|
Method Summary | ||
---|---|---|
void |
addDeclaration(NameDeclaration declaration)
Adds a new declaration to this scope. |
|
NameDeclaration |
addNameOccurrence(NameOccurrence occurrence)
Adds a NameOccurrence to this scope - only call this after getting
a true back from Scope.contains(NameOccurrence) . |
|
boolean |
contains(NameOccurrence occ)
Tests whether or not a NameOccurrence is directly contained in the scope. |
|
Map<NameDeclaration,List<NameOccurrence>> |
getDeclarations()
Gets all the declaration with the occurrences in this scope. |
|
|
getDeclarations(Class<T> clazz)
Helper method to get only a specific type of name declarations. |
|
|
getEnclosingScope(Class<T> clazz)
Helper method that goes up the parent scopes to find a scope of the specified type |
|
Scope |
getParent()
Retrieves this scope's parent |
|
void |
setParent(Scope parent)
Points this scope to its parent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractScope()
Method Detail |
---|
public Scope getParent()
Scope
getParent
in interface Scope
public void setParent(Scope parent)
Scope
setParent
in interface Scope
public Map<NameDeclaration,List<NameOccurrence>> getDeclarations()
Scope
getDeclarations
in interface Scope
public <T extends NameDeclaration> Map<T,List<NameOccurrence>> getDeclarations(Class<T> clazz)
Scope
Scope.getDeclarations()
.
getDeclarations
in interface Scope
clazz
- the type of name declarations to use
public boolean contains(NameOccurrence occ)
Scope
NameOccurrence
is directly contained in the scope.
This means, whether the given NameOccurrence
references a declaration, that has been
declared within this scope.
Note that this search is just for this scope - it doesn't go diving into any
parent scopes.
contains
in interface Scope
public void addDeclaration(NameDeclaration declaration)
Scope
Scope.contains(NameOccurrence)
and Scope.addNameOccurrence(NameOccurrence)
can
be used correctly.
addDeclaration
in interface Scope
declaration
- the declaration to addpublic <T extends Scope> T getEnclosingScope(Class<T> clazz)
Scope
getEnclosingScope
in interface Scope
clazz
- the type of the Scope to search for
null
if no
such scope was found.public NameDeclaration addNameOccurrence(NameOccurrence occurrence)
Scope
NameOccurrence
to this scope - only call this after getting
a true back from Scope.contains(NameOccurrence)
.
addNameOccurrence
in interface Scope
NameDeclaration
that is references by the given NameOccurrence
,
if the NameOccurrence
could be added. Otherwise null
is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |