public override async Task <LSP.ReferenceItem[]?> HandleRequestAsync(ReferenceParams referenceParams, RequestContext context, CancellationToken cancellationToken) { Debug.Assert(context.ClientCapabilities.HasVisualStudioLspCapability()); var document = context.Document; if (document == null) { return(Array.Empty <LSP.VSReferenceItem>()); } using var progress = BufferedProgress.Create <VSReferenceItem>(referenceParams.PartialResultToken); var findUsagesService = document.GetRequiredLanguageService <IFindUsagesLSPService>(); var position = await document.GetPositionFromLinePositionAsync( ProtocolConversions.PositionToLinePosition(referenceParams.Position), cancellationToken).ConfigureAwait(false); var findUsagesContext = new FindUsagesLSPContext( progress, 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, findUsagesContext).ConfigureAwait(false); await findUsagesContext.OnCompletedAsync().ConfigureAwait(false); return(progress.GetValues()); }
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, RequestContext context, CancellationToken cancellationToken) { Debug.Assert(context.ClientCapabilities.HasVisualStudioLspCapability()); var document = SolutionProvider.GetDocument(referenceParams.TextDocument, context.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 findUsagesContext = 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, findUsagesContext).ConfigureAwait(false); await findUsagesContext.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>()); }