Пример #1
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            var callback = new ProgressionNavigateToSearchCallback(context, graphBuilder);
            var searcher = NavigateToSearcher.Create(
                solution,
                _asyncListener,
                callback,
                _searchPattern,
                NavigateToUtilities.GetKindsProvided(solution),
                _threadingContext.DisposalToken);

            await searcher.SearchAsync(searchCurrentDocument : false, cancellationToken).ConfigureAwait(false);

            return(graphBuilder);
        }
        private ReadOnlyCollection <DescriptionItem> CreateDescriptionItems()
        {
            var document = _searchResult.NavigableItem.Document;

            if (document == null)
            {
                return(new List <DescriptionItem>().AsReadOnly());
            }

            var sourceText = document.GetTextSynchronously(CancellationToken.None);
            var span       = NavigateToUtilities.GetBoundedSpan(_searchResult.NavigableItem, sourceText);

            var items = new List <DescriptionItem>
            {
                new DescriptionItem(
                    new ReadOnlyCollection <DescriptionRun>(
                        new[] { new DescriptionRun("Project:", bold: true) }),
                    new ReadOnlyCollection <DescriptionRun>(
                        new[] { new DescriptionRun(document.Project.Name) })),
                new DescriptionItem(
                    new ReadOnlyCollection <DescriptionRun>(
                        new[] { new DescriptionRun("File:", bold: true) }),
                    new ReadOnlyCollection <DescriptionRun>(
                        new[] { new DescriptionRun(document.FilePath ?? document.Name) })),
                new DescriptionItem(
                    new ReadOnlyCollection <DescriptionRun>(
                        new[] { new DescriptionRun("Line:", bold: true) }),
                    new ReadOnlyCollection <DescriptionRun>(
                        new[] { new DescriptionRun((sourceText.Lines.IndexOf(span.Start) + 1).ToString()) }))
            };

            var summary = _searchResult.Summary;

            if (!string.IsNullOrWhiteSpace(summary))
            {
                items.Add(
                    new DescriptionItem(
                        new ReadOnlyCollection <DescriptionRun>(
                            new[] { new DescriptionRun("Summary:", bold: true) }),
                        new ReadOnlyCollection <DescriptionRun>(
                            new[] { new DescriptionRun(summary) })));
            }

            return(items.AsReadOnly());
        }