/// <summary> /// Gets all the matching symbols in the scope, and then from any outer scopes. /// </summary> public void GetSymbols(string name, SymbolMatch match, List <Symbol> symbols) { if (_symbols != null) { if (name != null) { if (_symbols.TryGetValue(name, out var decl) && decl.Matches(name, match)) { symbols.Add(decl); return; } } else { foreach (var symbol in _symbols.Values) { if (symbol.Matches(name, match)) { symbols.Add(symbol); } } } } if (_sharedScope != null) { _sharedScope.GetSymbols(name, match, symbols); } if (_outerScope != null) { _outerScope.GetSymbols(name, match, symbols); } }
/// <summary> /// Gets all the matching members. /// </summary> public virtual void GetMembers(string name, SymbolMatch match, List <Symbol> symbols, bool ignoreCase = false) { foreach (var symbol in this.Members) { if (symbol.Matches(name, match, ignoreCase)) { symbols.Add(symbol); } } }
/// <summary> /// Gets a list of all the symbols in the scope related to the specified text position. /// </summary> public IReadOnlyList <Symbol> GetSymbolsInScope(int position, SymbolMatch match = SymbolMatch.Any, IncludeFunctionKind include = IncludeFunctionKind.All, CancellationToken cancellationToken = default(CancellationToken)) { var symbols = new List <Symbol>(); if (this.HasSemantics) { Binder.GetSymbolsInScope(this.Syntax, position, this.Globals, match, include, symbols, cancellationToken); } return(symbols.ToReadOnly()); }
/// <summary> /// Returns the first member that matches or null. /// </summary> public Symbol GetFirstMember(string name, SymbolMatch match = SymbolMatch.Any, bool ignoreCase = false) { foreach (var symbol in this.Members) { if (symbol.Matches(name, match, ignoreCase)) { return(symbol); } } return(null); }
public override void GetMembers(string name, SymbolMatch match, List <Symbol> symbols, bool ignoreCase = false) { if (this.Columns.Count > 0) { if (name != null) { if (this.ColumnMap.TryGetValue(name, out var column) && column.Matches(name, match, ignoreCase)) { symbols.Add(column); } } else { base.GetMembers(name, match, symbols); } } }
/// <summary> /// Gets all the matching members. /// </summary> public void GetMembers(SymbolMatch match, List <Symbol> symbols, bool ignoreCase = false) { this.GetMembers(null, match, symbols, ignoreCase); }
public static bool Matches(this Symbol symbol, string name, SymbolMatch match, bool ignoreCase = false) { if (name != null) { if (ignoreCase) { if (string.Compare(symbol.Name, name, ignoreCase) != 0) { return(false); } } else { // compare first character before calling string.Compare (perf) var sn = symbol.Name; if (name.Length == 0 || sn.Length == 0 || name[0] != sn[0] || string.Compare(sn, name) != 0) { return(false); } } } if ((match & SymbolMatch.Column) != 0 && symbol.Kind == SymbolKind.Column) { return(true); } if ((match & SymbolMatch.Table) != 0 && symbol.Kind == SymbolKind.Table) { return(true); } if ((match & SymbolMatch.Database) != 0 && symbol.Kind == SymbolKind.Database) { return(true); } if ((match & SymbolMatch.Cluster) != 0 && symbol.Kind == SymbolKind.Cluster) { return(true); } if ((match & SymbolMatch.Scalar) != 0 && (match & SymbolMatch.Tabular) == 0 && !symbol.IsScalar) { return(false); } if ((match & SymbolMatch.Tabular) != 0 && (match & SymbolMatch.Scalar) == 0 && !symbol.IsTabular) { return(false); } if ((match & SymbolMatch.Function) != 0 && (symbol.Kind == SymbolKind.Function || symbol.Kind == SymbolKind.Pattern)) { return(true); } if ((match & SymbolMatch.Local) != 0 && (symbol.Kind == SymbolKind.Variable || symbol.Kind == SymbolKind.Parameter)) { return(true); } return(false); }
public static bool Matches(this Symbol symbol, SymbolMatch match) { return(Matches(symbol, null, match)); }
/// <summary> /// Gets all the matching symbols in the scope. /// </summary> public void GetSymbols(SymbolMatch match, List <Symbol> symbols) { GetSymbols(null, match, symbols); }
/// <summary> /// Gets all symbols in the scope with the specified name and kind. /// </summary> public abstract void GetSymbols(string name, SymbolMatch match, List <Symbol> symbols);
public override void GetSymbols(string name, SymbolMatch match, List <Symbol> symbols) { // do nothing }