private bool TryExecuteCommand(int caretPosition, Document document, IFindUsagesServiceRenameOnceTypeScriptMovesToExternalAccess findUsagesService) { // See if we're running on a host that can provide streaming results. // We'll both need a FAR service that can stream results to us, and // a presenter that can accept streamed results. if (findUsagesService != null && _streamingPresenter != null) { _ = StreamingFindReferencesAsync(document, caretPosition, findUsagesService, _streamingPresenter); return(true); } return(false); }
private async Task StreamingFindReferencesAsync( Document document, int caretPosition, IFindUsagesServiceRenameOnceTypeScriptMovesToExternalAccess findUsagesService, IStreamingFindUsagesPresenter presenter) { try { using var token = _asyncListener.BeginAsyncOperation(nameof(StreamingFindReferencesAsync)); // Let the presented know we're starting a search. It will give us back the context object that the FAR // service will push results into. This operation is not externally cancellable. Instead, the find refs // window will cancel it if another request is made to use it. var context = presenter.StartSearchWithCustomColumns( EditorFeaturesResources.Find_References, supportsReferences: true, includeContainingTypeAndMemberColumns: document.Project.SupportsCompilation, includeKindColumn: document.Project.Language != LanguageNames.FSharp, CancellationToken.None); using (Logger.LogBlock( FunctionId.CommandHandler_FindAllReference, KeyValueLogMessage.Create(LogType.UserAction, m => m["type"] = "streaming"), context.CancellationToken)) { try { await findUsagesService.FindReferencesAsync(document, caretPosition, context).ConfigureAwait(false); } finally { await context.OnCompletedAsync().ConfigureAwait(false); } } } catch (OperationCanceledException) { } catch (Exception e) when(FatalError.ReportAndCatch(e)) { } }
protected virtual Task FindImplementationsAsync(IFindUsagesServiceRenameOnceTypeScriptMovesToExternalAccess findUsagesService, Document document, int position, SimpleFindUsagesContext context) => findUsagesService.FindImplementationsAsync(document, position, context);