001package gudusoft.gsqlparser.resolver2.scope; 002 003import gudusoft.gsqlparser.nodes.TParseTreeNode; 004import gudusoft.gsqlparser.resolver2.ScopeType; 005import gudusoft.gsqlparser.resolver2.matcher.INameMatcher; 006import gudusoft.gsqlparser.resolver2.model.QualifiedName; 007import gudusoft.gsqlparser.resolver2.model.ScopeChild; 008import gudusoft.gsqlparser.resolver2.namespace.INamespace; 009 010import java.util.Collections; 011import java.util.List; 012 013/** 014 * Empty scope - terminates the scope chain. 015 * This is the parent of GlobalScope, providing base-case behavior. 016 * 017 * All resolution methods do nothing or return empty/null. 018 */ 019public class EmptyScope implements IScope { 020 021 /** Singleton instance */ 022 public static final EmptyScope INSTANCE = new EmptyScope(); 023 024 private EmptyScope() { 025 // Private constructor for singleton 026 } 027 028 @Override 029 public IScope getParent() { 030 return this; // EmptyScope is its own parent 031 } 032 033 @Override 034 public TParseTreeNode getNode() { 035 return null; 036 } 037 038 @Override 039 public ScopeType getScopeType() { 040 return ScopeType.EMPTY; 041 } 042 043 @Override 044 public void resolve(List<String> names, 045 INameMatcher matcher, 046 boolean deep, 047 IResolved resolved) { 048 // Do nothing - name not found 049 } 050 051 @Override 052 public INamespace resolveTable(String tableName) { 053 return null; // Not found 054 } 055 056 @Override 057 public void addChild(INamespace namespace, String alias, boolean nullable) { 058 throw new UnsupportedOperationException("Cannot add children to EmptyScope"); 059 } 060 061 @Override 062 public List<ScopeChild> getChildren() { 063 return Collections.emptyList(); 064 } 065 066 @Override 067 public List<INamespace> getVisibleNamespaces() { 068 return Collections.emptyList(); 069 } 070 071 @Override 072 public QualifiedName fullyQualify(String name) { 073 return new QualifiedName(name); 074 } 075 076 @Override 077 public boolean isWithin(IScope ancestorScope) { 078 return this == ancestorScope; 079 } 080 081 @Override 082 public String toString() { 083 return "EmptyScope"; 084 } 085}