예제 #1
0
        private static async Task <VSSymbolInformation[]> ConvertAsync(
            ImmutableArray <INavigateToSearchResult> results, CancellationToken cancellationToken)
        {
            var symbols = new VSSymbolInformation[results.Length];

            for (var i = 0; i < results.Length; i++)
            {
                var result = results[i];
                var text   = await result.NavigableItem.Document.GetTextAsync(cancellationToken).ConfigureAwait(false);

                symbols[i] = new VSSymbolInformation()
                {
                    Name          = result.Name,
                    ContainerName = result.AdditionalInformation,
                    Kind          = ProtocolConversions.NavigateToKindToSymbolKind(result.Kind),
                    Location      = new LSP.Location()
                    {
                        Uri   = result.NavigableItem.Document.GetURI(),
                        Range = ProtocolConversions.TextSpanToRange(result.NavigableItem.SourceSpan, text)
                    },
                    Icon = new VisualStudio.Text.Adornments.ImageElement(result.NavigableItem.Glyph.GetImageId())
                };
            }

            return(symbols);
        }
예제 #2
0
        private static async Task <ImmutableArray <SymbolInformation> > ConvertAsync(
            ImmutableArray <INavigateToSearchResult> results, CancellationToken cancellationToken)
        {
            var symbols = ImmutableArray.CreateBuilder <SymbolInformation>();

            foreach (var result in results)
            {
                var text = await result.NavigableItem.Document.GetTextAsync(cancellationToken).ConfigureAwait(false);

                symbols.Add(new VSSymbolInformation()
                {
                    Name          = result.Name,
                    ContainerName = result.AdditionalInformation,
                    Kind          = ProtocolConversions.NavigateToKindToSymbolKind(result.Kind),
                    Location      = new LSP.Location()
                    {
                        Uri   = result.NavigableItem.Document.GetURI(),
                        Range = ProtocolConversions.TextSpanToRange(result.NavigableItem.SourceSpan, text)
                    },
                    Icon = new VisualStudio.Text.Adornments.ImageElement(result.NavigableItem.Glyph.GetImageId())
                });
            }

            return(symbols.ToImmutableArray());
        }
예제 #3
0
            private async Task ReportSymbolInformationAsync(
                INavigateToSearchResult result,
                CancellationToken cancellationToken
                )
            {
                var location = await ProtocolConversions
                               .TextSpanToLocationAsync(
                    result.NavigableItem.Document,
                    result.NavigableItem.SourceSpan,
                    cancellationToken
                    )
                               .ConfigureAwait(false);

                Contract.ThrowIfNull(location);
                _progress.Report(
                    new VSSymbolInformation
                {
                    Name          = result.Name,
                    ContainerName = result.AdditionalInformation,
                    Kind          = ProtocolConversions.NavigateToKindToSymbolKind(result.Kind),
                    Location      = location,
                    Icon          = new ImageElement(result.NavigableItem.Glyph.GetImageId())
                }
                    );
            }
 static async Task <SymbolInformation> CreateSymbolInformation(INavigateToSearchResult result, CancellationToken cancellationToken)
 {
     return(new SymbolInformation
     {
         Name = result.Name,
         Kind = ProtocolConversions.NavigateToKindToSymbolKind(result.Kind),
         Location = await ProtocolConversions.TextSpanToLocationAsync(result.NavigableItem.Document, result.NavigableItem.SourceSpan, cancellationToken).ConfigureAwait(false),
     });
 }
                static async Task ReportSymbolInformation(IProgress <SymbolInformation> progress, INavigateToSearchResult result, CancellationToken cancellationToken)
                {
                    var location = await ProtocolConversions.TextSpanToLocationAsync(result.NavigableItem.Document, result.NavigableItem.SourceSpan, cancellationToken).ConfigureAwait(false);

                    Contract.ThrowIfNull(location);
                    progress.Report(new SymbolInformation
                    {
                        Name     = result.Name,
                        Kind     = ProtocolConversions.NavigateToKindToSymbolKind(result.Kind),
                        Location = location,
                    });
                }
예제 #6
0
            public async Task AddItemAsync(Project project, INavigateToSearchResult result, CancellationToken cancellationToken)
            {
                var location = await ProtocolConversions.TextSpanToLocationAsync(
                    result.NavigableItem.Document, result.NavigableItem.SourceSpan, result.NavigableItem.IsStale, _context, cancellationToken).ConfigureAwait(false);

                if (location == null)
                {
                    return;
                }

                _progress.Report(new VSSymbolInformation
                {
                    Name          = result.Name,
                    ContainerName = result.AdditionalInformation,
                    Kind          = ProtocolConversions.NavigateToKindToSymbolKind(result.Kind),
                    Location      = location,
                    Icon          = VSLspExtensionConversions.GetImageIdFromGlyph(result.NavigableItem.Glyph)
                });
            }