java.lang.Object
de.grogra.suggest.scope.BaseScope
- Direct Known Subclasses:
LambdaScope,LocalScopeSymbol,SymbolWithScope
A scope where one key can be several symbols: e.g. one method name can be several
method in the scope. Each having different parameters and possibly return type.
The method are not differentiated with their parameters in the name to be
easier to match with auto completion - in the case some parameters are not filed yet
the method name can still match.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ScopeAll directly contained scopes, typically LocalScopes within a LocalScope or a LocalScope within a FunctionSymbol.All symbols defined in this scope; can include classes, functions, variables, or anything else that is a Symbol impl.Fields inherited from interface de.grogra.suggest.scope.Member
ABSTRACT, ALL_VISIBILITY, CLASS, COMPLETE_NAME, CONSTRUCTOR, DECLARED, FIELD, FINAL, INTERFACE, JAVA_TYPE, METHOD, NATIVE, NEW, NODE, PACKAGE, PRIVATE, PROTECTED, PUBLIC, SCOPE, STATIC, STATIC_ONLY, STRICT, SUPER, SYNCHRONIZED, TRANSIENT, VOLATILE, XL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidDefine a symbol in this scope, throw IllegalArgumentException if sym already defined in this scope.Collection<? extends Symbol> getAllSymbols(int flags) Return all symbols found in all nested scopes.Return (inclusive) list of all scopes on path to root scope.Scope in which this scope defined. null if no enclosing scopegetEnclosingScopeOfType(Class<?> type) Walk up enclosingScope until we find an object of a specific type.Return all immediately enclosed scoped symbols in insertion order.Return a list of scopes nested within this scope.intgetNumberOfSymbols(int flags) Number of symbols in this specific scopeWalk up enclosingScope until we find topmost.Get symbol if name defined within this specific scope The symbol must have the flags bits.getSymbolNames(int flags) Return the set of names associated with all symbols in the scope.Collection<? extends Symbol> getSymbols(int flags) Return the symbols defined within this scope.voidAdd a nested scope to this scope; could also be a FunctionSymbol if your language allows nested functions.Look up name in this scope or recursively in parent scope if not here.resolveFirst(String name, int flags) voidsetEnclosingScope(Scope enclosingScope) What scope encloses this scope.toQualifierString(String separator) Return scopes from to current with separator in betweentoScopeStackString(String separator) toString()toTestString(String separator, String scopePathSeparator)
-
Field Details
-
enclosingScope
-
symbols
All symbols defined in this scope; can include classes, functions, variables, or anything else that is a Symbol impl. It does NOT include non-Symbol-based things like LocalScope. See nestedScopes. -
nestedScopesNotSymbols
All directly contained scopes, typically LocalScopes within a LocalScope or a LocalScope within a FunctionSymbol. This does not include SymbolWithScope objects.
-
-
Constructor Details
-
BaseScope
public BaseScope() -
BaseScope
-
-
Method Details
-
getMembers
-
getSymbol
Description copied from interface:ScopeGet symbol if name defined within this specific scope The symbol must have the flags bits. -
setEnclosingScope
Description copied from interface:ScopeWhat scope encloses this scope. E.g., if this scope is a function, the enclosing scope could be a class. The BaseScope class automatically adds this to nested scope list of s.- Specified by:
setEnclosingScopein interfaceScope
-
getAllNestedScopedSymbols
-
getNestedScopedSymbols
Description copied from interface:ScopeReturn all immediately enclosed scoped symbols in insertion order. E.g., a class would return all nested classes and any methods. There does not have to be an explicit pointer to the nested scopes. This method generally searches the list of symbols looking for symbols that implement Scope. Gets only those scopes that are in the symbols list of "this" scope. E.g., does not get local scopes within a function. This returns a subset or same set asScope.getNestedScopes().- Specified by:
getNestedScopedSymbolsin interfaceScope
-
getNestedScopes
Description copied from interface:ScopeReturn a list of scopes nested within this scope. It has both ScopedSymbols and scopes without symbols, such as LocalScopes. This returns a superset or same set asScope.getNestedScopedSymbols(). ScopedSymbols come first then all non-ScopedSymbols Scope objects. Insertion order is used within each sublist.- Specified by:
getNestedScopesin interfaceScope
-
nest
Add a nested scope to this scope; could also be a FunctionSymbol if your language allows nested functions.- Specified by:
nestin interfaceScope- Throws:
IllegalArgumentException- if you pass in a SymbolWithScope.
-
resolve
Description copied from interface:ScopeLook up name in this scope or recursively in parent scope if not here. Use the flags to reduce the space of symbol -
resolveFirst
- Specified by:
resolveFirstin interfaceScope
-
define
Description copied from interface:ScopeDefine a symbol in this scope, throw IllegalArgumentException if sym already defined in this scope. This alters sym: 1. Set insertion order number of sym 2. Set sym's scope to be the scope. The order in which symbols are defined must be preserved so thatreturns the list in definition order.invalid reference
#getSymbols()- Specified by:
definein interfaceScope- Throws:
IllegalArgumentException
-
define
- Specified by:
definein interfaceScope- Throws:
ParseException
-
getEnclosingScope
Description copied from interface:ScopeScope in which this scope defined. null if no enclosing scope- Specified by:
getEnclosingScopein interfaceScope
-
getOuterMostEnclosingScope
Walk up enclosingScope until we find topmost. Note this is enclosing scope not necessarily parent. This will usually be a global scope or something, depending on your scope tree. -
getEnclosingScopeOfType
Walk up enclosingScope until we find an object of a specific type. E.g., if you want to get enclosing method, you would pass in MethodSymbol.class, unless of course you have created a subclass for your language implementation. -
getEnclosingPathToRoot
Description copied from interface:ScopeReturn (inclusive) list of all scopes on path to root scope. The first element is the current scope and the last is the root scope.- Specified by:
getEnclosingPathToRootin interfaceScope
-
getSymbols
Description copied from interface:ScopeReturn the symbols defined within this scope. The order of insertion into the scope is the order returned in this list. Only symbol that match the flags are returned- Specified by:
getSymbolsin interfaceScope
-
getAllSymbols
Description copied from interface:ScopeReturn all symbols found in all nested scopes. The order of insertion into the scope is the order returned in this list for each scope. The scopes are traversed in the order in which they are encountered in the input.- Specified by:
getAllSymbolsin interfaceScope
-
getNumberOfSymbols
public int getNumberOfSymbols(int flags) Description copied from interface:ScopeNumber of symbols in this specific scope- Specified by:
getNumberOfSymbolsin interfaceScope
-
getSymbolNames
Description copied from interface:ScopeReturn the set of names associated with all symbols in the scope.- Specified by:
getSymbolNamesin interfaceScope
-
toString
-
toScopeStackString
-
toQualifierString
Description copied from interface:ScopeReturn scopes from to current with separator in between- Specified by:
toQualifierStringin interfaceScope
-
toTestString
-
toTestString
-