static async Task UpdateDocument(ConcurrentDictionary <DocumentId, Dictionary <DeclaredSymbolInfoKind, List <DeclaredSymbolInfoWrapper> > > result, Microsoft.CodeAnalysis.Document document, CancellationToken cancellationToken)
            {
                var syntaxFactsService = document.GetLanguageService <ISyntaxFactsService> ();
                var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

                var infos = new Dictionary <DeclaredSymbolInfoKind, List <DeclaredSymbolInfoWrapper> > ();

                foreach (var kind in AllKinds)
                {
                    infos [kind] = new List <DeclaredSymbolInfoWrapper> ();
                }
                foreach (var current in root.DescendantNodesAndSelf(n => !(n is BlockSyntax)))
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    var kind = current.Kind();
                    if (kind == SyntaxKind.ConstructorDeclaration ||
                        kind == SyntaxKind.IndexerDeclaration)
                    {
                        continue;
                    }
                    if (syntaxFactsService.TryGetDeclaredSymbolInfo(current, out DeclaredSymbolInfo info))
                    {
                        var declaredSymbolInfo = new DeclaredSymbolInfoWrapper(current, document.Id, info);
                        infos[info.Kind].Add(declaredSymbolInfo);
                    }
                }
                RemoveDocument(result, document.Id);
                result.TryAdd(document.Id, infos);
            }
Exemple #2
0
        internal static IconId GetStockIconForSymbolInfo(this DeclaredSymbolInfoWrapper symbol)
        {
            switch (symbol.SymbolInfo.Kind)
            {
            case DeclaredSymbolInfoKind.Class:
                return(AstStockIcons.Class);

            case DeclaredSymbolInfoKind.Constant:
                return(AstStockIcons.Field);

            case DeclaredSymbolInfoKind.Constructor:
                return(AstStockIcons.Method);

            case DeclaredSymbolInfoKind.Delegate:
                return(AstStockIcons.Delegate);

            case DeclaredSymbolInfoKind.Enum:
                return(AstStockIcons.Enum);

            case DeclaredSymbolInfoKind.EnumMember:
                return(AstStockIcons.Field);

            case DeclaredSymbolInfoKind.Event:
                return(AstStockIcons.Event);

            case DeclaredSymbolInfoKind.ExtensionMethod:
                return(AstStockIcons.Method);

            case DeclaredSymbolInfoKind.Field:
                return(AstStockIcons.Field);

            case DeclaredSymbolInfoKind.Indexer:
                return(AstStockIcons.Method);

            case DeclaredSymbolInfoKind.Interface:
                return(AstStockIcons.Interface);

            case DeclaredSymbolInfoKind.Method:
                return(AstStockIcons.Method);

            case DeclaredSymbolInfoKind.Module:
                return(AstStockIcons.Method);

            case DeclaredSymbolInfoKind.Property:
                return(AstStockIcons.Property);

            case DeclaredSymbolInfoKind.Struct:
                return(AstStockIcons.Struct);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
            internal SearchResult CheckType(DeclaredSymbolInfoWrapper symbol)
            {
                int rank;
                var name = symbol.SymbolInfo.Name;

                if (MatchName(name, out rank))
                {
//					if (type.ContainerDisplayName != null)
//						rank--;
                    return(new DeclaredSymbolInfoResult(pattern, name, rank, symbol, false));
                }
                if (!FullSearch)
                {
                    return(null);
                }
                name = symbol.SymbolInfo.FullyQualifiedContainerName;
                if (MatchName(name, out rank))
                {
//					if (type.ContainingType != null)
//						rank--;
                    return(new DeclaredSymbolInfoResult(pattern, name, rank, symbol, true));
                }
                return(null);
            }
Exemple #4
0
 public DeclaredSymbolInfoResult(string match, string matchedString, int rank, DeclaredSymbolInfoWrapper type, bool useFullName)  : base(match, matchedString, rank)
 {
     this.useFullName = useFullName;
     this.type        = type;
 }