static async Task <Hover> GetHoverAsync(QuickInfoItem info, Document document, ClientCapabilities clientCapabilities, CancellationToken cancellationToken) { var supportsVSExtensions = clientCapabilities.HasVisualStudioLspCapability(); var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); if (supportsVSExtensions) { return(new VSHover { Range = ProtocolConversions.TextSpanToRange(info.Span, text), Contents = new SumType <SumType <string, MarkedString>, SumType <string, MarkedString>[], MarkupContent>(string.Empty), // Build the classified text without navigation actions - they are not serializable. // TODO - Switch to markup content once it supports classifications. // https://devdiv.visualstudio.com/DevDiv/_workitems/edit/918138 RawContent = await IntellisenseQuickInfoBuilder.BuildContentWithoutNavigationActionsAsync(info, document, cancellationToken).ConfigureAwait(false) }); } else { return(new Hover { Range = ProtocolConversions.TextSpanToRange(info.Span, text), Contents = GetContents(info, document, clientCapabilities), }); } }
public override async Task <LSP.VSReferenceItem[]> HandleRequestAsync( ReferenceParams referenceParams, ClientCapabilities clientCapabilities, string?clientName, CancellationToken cancellationToken) { Debug.Assert(clientCapabilities.HasVisualStudioLspCapability()); var document = SolutionProvider.GetDocument(referenceParams.TextDocument, clientName); if (document == null) { return(Array.Empty <LSP.VSReferenceItem>()); } var findUsagesService = document.GetRequiredLanguageService <IFindUsagesLSPService>(); var position = await document.GetPositionFromLinePositionAsync( ProtocolConversions.PositionToLinePosition(referenceParams.Position), cancellationToken).ConfigureAwait(false); var context = new FindUsagesLSPContext(document, position, _metadataAsSourceFileService, cancellationToken); // Finds the references for the symbol at the specific position in the document, reporting them via streaming to the LSP client. // TODO: Change back FAR to use streaming once the following LSP bug is fixed: // https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1094786/ await findUsagesService.FindReferencesAsync(document, position, context).ConfigureAwait(false); return(context.GetReferences().ToArray()); }
public override async Task <LSP.VSReferenceItem[]> HandleRequestAsync( ReferenceParams referenceParams, ClientCapabilities clientCapabilities, string?clientName, CancellationToken cancellationToken) { Debug.Assert(clientCapabilities.HasVisualStudioLspCapability()); var document = SolutionProvider.GetDocument(referenceParams.TextDocument, clientName); if (document == null) { return(Array.Empty <LSP.VSReferenceItem>()); } var findUsagesService = document.GetRequiredLanguageService <IFindUsagesLSPService>(); var position = await document.GetPositionFromLinePositionAsync( ProtocolConversions.PositionToLinePosition(referenceParams.Position), cancellationToken).ConfigureAwait(false); var context = new FindUsagesLSPContext( referenceParams.PartialResultToken, document, position, _metadataAsSourceFileService, cancellationToken); // Finds the references for the symbol at the specific position in the document, reporting them via streaming to the LSP client. await findUsagesService.FindReferencesAsync(document, position, context).ConfigureAwait(false); await context.OnCompletedAsync().ConfigureAwait(false); // The results have already been reported to the client, so we don't need to return anything here. return(Array.Empty <LSP.VSReferenceItem>()); }