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) }); }
/// <summary> /// Get a symbol information from a specified nav bar item. /// </summary> private static SymbolInformation?GetSymbolInformation( RoslynNavigationBarItem item, Document document, SourceText text, string?containerName = null) { if (item is not RoslynNavigationBarItem.SymbolItem symbolItem || symbolItem.Location.InDocumentInfo == null) { return(null); } return(new VSSymbolInformation { Name = item.Text, Location = new LSP.Location { Uri = document.GetURI(), Range = ProtocolConversions.TextSpanToRange(symbolItem.Location.InDocumentInfo.Value.navigationSpan, text), }, Kind = ProtocolConversions.GlyphToSymbolKind(item.Glyph), ContainerName = containerName, Icon = VSLspExtensionConversions.GetImageIdFromGlyph(item.Glyph), }); }