private static async Task <LSP.VSReferenceItem?> GenerateVSReferenceItemAsync( int id, int?definitionId, Document document, int position, DocumentSpan documentSpan, ImmutableDictionary <string, string> properties, IMetadataAsSourceFileService metadataAsSourceFileService, string?definitionText, SymbolUsageInfo?symbolUsageInfo, CancellationToken cancellationToken) { var location = await ComputeLocationAsync(document, position, documentSpan, metadataAsSourceFileService, cancellationToken).ConfigureAwait(false); if (location == null) { return(null); } // Getting the text for the Text property. If we somehow can't compute the text, that means we're probably dealing with a metadata // reference, and those don't show up in the results list in Roslyn FAR anyway. var text = await ComputeTextAsync(id, definitionId, documentSpan, definitionText, cancellationToken).ConfigureAwait(false); if (text == null) { return(null); } // TO-DO: The Origin property should be added once Rich-Nav is completed. // https://github.com/dotnet/roslyn/issues/42847 var result = new LSP.VSReferenceItem { ContainingMember = properties.TryGetValue( AbstractReferenceFinder.ContainingMemberInfoPropertyName, out var referenceContainingMember) ? referenceContainingMember : null, ContainingType = properties.TryGetValue( AbstractReferenceFinder.ContainingTypeInfoPropertyName, out var referenceContainingType) ? referenceContainingType : null, DefinitionId = definitionId, DefinitionText = definitionText, // Only definitions should have a non-null DefinitionText DisplayPath = location.Uri.LocalPath, DocumentName = documentSpan == default ? null : documentSpan.Document.Name, Id = id, Kind = symbolUsageInfo.HasValue ? ProtocolConversions.SymbolUsageInfoToReferenceKinds(symbolUsageInfo.Value) : new ReferenceKind[] { }, Location = location, ProjectName = documentSpan == default ? null : documentSpan.Document.Project.Name, ResolutionStatus = ResolutionStatusKind.ConfirmedAsReference, Text = text, }; return(result);
private static async Task <LSP.VSReferenceItem?> GenerateVSReferenceItemAsync( int id, int?definitionId, Document document, int position, DocumentSpan documentSpan, ImmutableDictionary <string, string> properties, IMetadataAsSourceFileService metadataAsSourceFileService, ClassifiedTextElement?definitionText, Glyph definitionGlyph, SymbolUsageInfo?symbolUsageInfo, bool isWrittenTo, CancellationToken cancellationToken) { var location = await ComputeLocationAsync(document, position, documentSpan, metadataAsSourceFileService, cancellationToken).ConfigureAwait(false); // Getting the text for the Text property. If we somehow can't compute the text, that means we're probably dealing with a metadata // reference, and those don't show up in the results list in Roslyn FAR anyway. var text = await ComputeTextAsync(id, definitionId, documentSpan, definitionText, isWrittenTo, cancellationToken).ConfigureAwait(false); if (text == null) { return(null); } // TO-DO: The Origin property should be added once Rich-Nav is completed. // https://github.com/dotnet/roslyn/issues/42847 var result = new LSP.VSReferenceItem { DefinitionId = definitionId, DefinitionText = definitionText, // Only definitions should have a non-null DefinitionText DefinitionIcon = definitionGlyph.GetImageElement(), DisplayPath = location?.Uri.LocalPath, Id = id, Kind = symbolUsageInfo.HasValue ? ProtocolConversions.SymbolUsageInfoToReferenceKinds(symbolUsageInfo.Value) : Array.Empty <ReferenceKind>(), ResolutionStatus = ResolutionStatusKind.ConfirmedAsReference, Text = text, }; // There are certain items that may not have locations, such as namespace definitions. if (location != null) { result.Location = location; } if (documentSpan.Document != null) { result.DocumentName = documentSpan.Document.Name; result.ProjectName = documentSpan.Document.Project.Name; } if (properties.TryGetValue(AbstractReferenceFinder.ContainingMemberInfoPropertyName, out var referenceContainingMember)) { result.ContainingMember = referenceContainingMember; } if (properties.TryGetValue(AbstractReferenceFinder.ContainingTypeInfoPropertyName, out var referenceContainingType)) { result.ContainingType = referenceContainingType; } return(result);