예제 #1
0
        /// <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);
            }
        }
예제 #2
0
 /// <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);
         }
     }
 }
예제 #3
0
        /// <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());
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
 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);
         }
     }
 }
예제 #6
0
 /// <summary>
 /// Gets all the matching members.
 /// </summary>
 public void GetMembers(SymbolMatch match, List <Symbol> symbols, bool ignoreCase = false)
 {
     this.GetMembers(null, match, symbols, ignoreCase);
 }
예제 #7
0
        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);
        }
예제 #8
0
 public static bool Matches(this Symbol symbol, SymbolMatch match)
 {
     return(Matches(symbol, null, match));
 }
예제 #9
0
 /// <summary>
 /// Gets all the matching symbols in the scope.
 /// </summary>
 public void GetSymbols(SymbolMatch match, List <Symbol> symbols)
 {
     GetSymbols(null, match, symbols);
 }
예제 #10
0
 /// <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
 }