ShaderTools.Hlsl.Compilation.SemanticModel.LookupSymbols C# (CSharp) Method

LookupSymbols() private static method

private static LookupSymbols ( Binder binder ) : IEnumerable
binder ShaderTools.Hlsl.Binding.Binder
return IEnumerable
        private static IEnumerable<Symbol> LookupSymbols(Binder binder)
        {
            // NOTE: We want to only show the *available* symbols. That means, we need to
            //       hide symbols from the parent binder that have same name as the ones
            //       from a nested binder.
            //
            //       We do this by simply recording which names we've already seen.
            //       Please note that we *do* want to see duplicate names within the
            //       *same* binder.

            var allNames = new HashSet<string>();

            while (binder != null)
            {
                var localNames = new HashSet<string>();
                var localSymbols = binder.LocalSymbols
                    .SelectMany(x => x.Value)
                    .Where(s => !string.IsNullOrEmpty(s.Name));

                foreach (var symbol in localSymbols)
                {
                    if (!allNames.Contains(symbol.Name))
                    {
                        localNames.Add(symbol.Name);
                        yield return symbol;
                    }
                }

                allNames.UnionWith(localNames);
                binder = binder.Parent;
            }
        }

Same methods

SemanticModel::LookupSymbols ( SourceLocation position ) : IEnumerable

Usage Example

Exemplo n.º 1
0
        private static IEnumerable<CompletionItem> GetGlobalCompletions(SemanticModel semanticModel, SourceLocation position)
        {
            var symbols = semanticModel.LookupSymbols(position)
                .Where(x => !(x is SemanticSymbol))
                .Where(x => !(x is AttributeSymbol));

            if (!semanticModel.SyntaxTree.PossiblyInTypeName(position))
                symbols = symbols.Where(x => !(x is TypeSymbol));

            return CreateSymbolCompletions(symbols);
        }
All Usage Examples Of ShaderTools.Hlsl.Compilation.SemanticModel::LookupSymbols