Package spoon.reflect.visitor
Interface LexicalScope
public interface LexicalScope
Represents that a lexical scope in the language
Note that scopes are changing after variable declaration. For example:
void draw() {
//scope1
int a;
//scope2
int b;
//scope3
}
See https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexical_scoping
-
Method Summary
Modifier and TypeMethodDescriptionaddNamedElement(CtNamedElement element)
adds an element to the scope<T> T
forEachElementByName(String name, Function<? super CtNamedElement,T> fnc)
-
Method Details
-
addNamedElement
adds an element to the scope -
getScopeElement
CtElement getScopeElement()- Returns:
- the
CtElement
which represents the current scope
-
forEachElementByName
- Parameters:
name
- to be searched simple namefnc
- is called for each named element with same simple name, which is defined in this or parentLexicalScope
. Function `fnc` is called as long as there are some matching elements and `fnc` returns null. If `fnc` returns not null value then searching is stopped and that value is a returned- Returns:
- the value returned by `fnc` or null
-