|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Scope
A scope is a region within variables and other declarations are visible. Scopes can be nested and form a tree. This is expressed through "parent scopes". Each scope manages its own declarations.
AbstractScope as a base class,
Java Language Specification, 6.3: Scope of a Declaration| 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 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 |
|
| Method Detail |
|---|
Scope getParent()
void setParent(Scope parent)
<T extends Scope> T getEnclosingScope(Class<T> clazz)
clazz - the type of the Scope to search for
null if no
such scope was found.Map<NameDeclaration,List<NameOccurrence>> getDeclarations()
<T extends NameDeclaration> Map<T,List<NameOccurrence>> getDeclarations(Class<T> clazz)
getDeclarations().
clazz - the type of name declarations to use
boolean contains(NameOccurrence occ)
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.
void addDeclaration(NameDeclaration declaration)
contains(NameOccurrence) and addNameOccurrence(NameOccurrence) can
be used correctly.
declaration - the declaration to addNameDeclaration addNameOccurrence(NameOccurrence occurrence)
NameOccurrence to this scope - only call this after getting
a true back from contains(NameOccurrence).
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 | |||||||||