public abstract class AbstractScope extends Object implements IScope
| Modifier and Type | Field and Description |
|---|---|
protected TParseTreeNode |
node
Associated AST node
|
protected IScope |
parent
Parent scope (never null - root has EmptyScope parent)
|
protected ScopeType |
scopeType
Scope type
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractScope(IScope parent,
TParseTreeNode node,
ScopeType scopeType) |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addAllDistinct(List<INamespace> out,
List<INamespace> more)
Appends every namespace of
more that out does not already hold (by identity). |
void |
addChild(INamespace namespace,
String alias,
boolean nullable)
Default implementation: not supported (most scopes don't have children)
|
protected static void |
addOwnNamespaces(List<INamespace> out,
IScope scope)
Adds the namespaces
scope itself declares (its IScope.getChildren()), each once. |
QualifiedName |
fullyQualify(String name)
Default implementation: delegate to parent
|
List<ScopeChild> |
getChildren()
Default implementation: empty list
|
IScope |
getLookupParent()
The scope an unresolved name climbs to: the parent, unless the search must skip it.
|
TParseTreeNode |
getNode()
Get the associated AST node
|
IScope |
getParent()
Get the parent scope.
|
ScopeType |
getScopeType()
Get the scope type
|
List<INamespace> |
getVisibleNamespaces()
The namespaces a name in this scope can see: the scope's own, then those of its lookup parent, as
resolve(java.util.List<java.lang.String>, gudusoft.gsqlparser.resolver2.matcher.INameMatcher, boolean, gudusoft.gsqlparser.resolver2.scope.IResolved) walks them. |
boolean |
isWithin(IScope ancestorScope)
Default implementation: check ancestry
|
void |
resolve(List<String> names,
INameMatcher matcher,
boolean deep,
IResolved resolved)
Default implementation: delegate to parent
|
INamespace |
resolveTable(String tableName)
Default implementation: delegate to parent
|
void |
setLookupParent(IScope lookupParent)
Make an unresolved name skip the parent and continue at
lookupParent. |
String |
toString() |
protected final TParseTreeNode node
protected AbstractScope(IScope parent, TParseTreeNode node, ScopeType scopeType)
public IScope getParent()
IScopepublic IScope getLookupParent()
public void setLookupParent(IScope lookupParent)
lookupParent.
A derived-table body and a CTE body cannot see the FROM clause that contains
them: in SELECT ... FROM (SELECT x FROM a) d JOIN t9 ... the x can
never be a column of t9 or of d itself, only of a or of a
query enclosing the whole statement. Only name lookup skips; getParent()
still returns the structural parent.
public TParseTreeNode getNode()
IScopepublic ScopeType getScopeType()
IScopegetScopeType in interface IScopepublic void resolve(List<String> names, INameMatcher matcher, boolean deep, IResolved resolved)
public INamespace resolveTable(String tableName)
resolveTable in interface IScopetableName - Table name or aliaspublic void addChild(INamespace namespace, String alias, boolean nullable)
public List<ScopeChild> getChildren()
getChildren in interface IScopepublic List<INamespace> getVisibleNamespaces()
resolve(java.util.List<java.lang.String>, gudusoft.gsqlparser.resolver2.matcher.INameMatcher, boolean, gudusoft.gsqlparser.resolver2.scope.IResolved) walks them. A non-lateral derived table or CTE body hides its owner's FROM scope by a
lookup parent (ScopeBuilder.setLookupParent), so the structural parent is not followed here either
(Mantis 4820, Codex review).getVisibleNamespaces in interface IScopeprotected static void addOwnNamespaces(List<INamespace> out, IScope scope)
scope itself declares (its IScope.getChildren()), each once. Used by the
scopes that own a FROM scope: the FROM scope's parent is the owner, so the owner must read the FROM scope's own
children instead of calling fromScope.getVisibleNamespaces(), which would re-enter the owner and recurse
until the stack overflows (Mantis 4820).protected static void addAllDistinct(List<INamespace> out, List<INamespace> more)
more that out does not already hold (by identity).public QualifiedName fullyQualify(String name)
fullyQualify in interface IScopename - Name to qualify