public async TPL.Task <IEnumerable <INavigableItem> > FindDefinitionsAsync(Document document, int position, CancellationToken cancellationToken)
        {
            var definitionItems = await GetDefinitionItemsAsync(document, position, cancellationToken).ConfigureAwait(false);

            if (definitionItems.IsDefaultOrEmpty)
            {
                return(ImmutableArray <INavigableItem> .Empty);
            }

            var navigableItems = ImmutableArray.CreateBuilder <INavigableItem>();

            foreach (var documentSpan in definitionItems.SelectMany(di => di.SourceSpans))
            {
                var declaredSymbolInfo = new DeclaredSymbolInfo(Roslyn.Utilities.StringTable.GetInstance(),
                                                                string.Empty,
                                                                string.Empty,
                                                                string.Empty,
                                                                string.Empty,
                                                                DeclaredSymbolInfoKind.Class,
                                                                Accessibility.NotApplicable,
                                                                documentSpan.SourceSpan,
                                                                ImmutableArray <string> .Empty);

                navigableItems.Add(NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, documentSpan.Document));
            }

            return(navigableItems.ToArray());
        }
        private static INavigateToSearchResult ConvertResult(
            bool containsDots, DeclaredSymbolInfo declaredSymbolInfo, Document document,
            PatternMatches matches)
        {
            var matchKind = GetNavigateToMatchKind(containsDots, matches);

            // A match is considered to be case sensitive if all its constituent pattern matches are
            // case sensitive.
            var isCaseSensitive = matches.All(m => m.IsCaseSensitive);
            var kind            = GetItemKind(declaredSymbolInfo);
            var navigableItem   = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document);

            return(new SearchResult(document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem));
        }
        private INavigateToSearchResult ConvertResult(bool containsDots, ValueTuple <DeclaredSymbolInfo, Document, IEnumerable <PatternMatch> > result)
        {
            var declaredSymbolInfo = result.Item1;
            var document           = result.Item2;
            var matches            = result.Item3;
            var matchKind          = GetNavigateToMatchKind(containsDots, matches);

            // A match is considered to be case sensitive if all its constituent pattern matches are
            // case sensitive.
            var isCaseSensitive = matches.All(m => m.IsCaseSensitive);
            var kind            = GetItemKind(declaredSymbolInfo);
            var navigableItem   = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document);

            return(new SearchResult(document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem));
        }
Example #4
0
        private static INavigateToSearchResult ConvertResult(
            DeclaredSymbolInfo declaredSymbolInfo, Document document,
            ArrayBuilder <PatternMatch> nameMatches, ArrayBuilder <PatternMatch> containerMatches)
        {
            var matchKind = GetNavigateToMatchKind(nameMatches);

            // A match is considered to be case sensitive if all its constituent pattern matches are
            // case sensitive.
            var isCaseSensitive = nameMatches.All(m => m.IsCaseSensitive) && containerMatches.All(m => m.IsCaseSensitive);
            var kind            = GetItemKind(declaredSymbolInfo);
            var navigableItem   = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document);

            return(new SearchResult(
                       document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem,
                       nameMatches.SelectMany(m => m.MatchedSpans).ToImmutableArray()));
        }
Example #5
0
        private INavigateToSearchResult ConvertResult(ValueTuple <DeclaredSymbolInfo, Document, IEnumerable <PatternMatch> > result, CancellationToken cancellationToken)
        {
            var declaredSymbolInfo = result.Item1;
            var document           = result.Item2;
            var matches            = result.Item3;
            var matchKind          = GetNavigateToMatchKind(matches);
            var kind          = GetItemKind(declaredSymbolInfo);
            var navigableItem = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document, cancellationToken);

            return(new SearchResult(
                       document,
                       declaredSymbolInfo,
                       kind,
                       matchKind,
                       navigableItem));
        }
        private static SearchResult ConvertResult(
            DeclaredSymbolInfo declaredSymbolInfo, Document document,
            ArrayBuilder <PatternMatch> nameMatches, ArrayBuilder <PatternMatch> containerMatches)
        {
            var matchKind = GetNavigateToMatchKind(nameMatches);

            // A match is considered to be case sensitive if all its constituent pattern matches are
            // case sensitive.
            var isCaseSensitive = nameMatches.All(m => m.IsCaseSensitive) && containerMatches.All(m => m.IsCaseSensitive);
            var kind            = GetItemKind(declaredSymbolInfo);
            var navigableItem   = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document);

            var matchedSpans = ArrayBuilder <TextSpan> .GetInstance();

            foreach (var match in nameMatches)
            {
                matchedSpans.AddRange(match.MatchedSpans);
            }

            return(new SearchResult(
                       document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem,
                       matchedSpans.ToImmutableAndFree()));
        }