Ejemplo n.º 1
0
        private async void StreamingFindReferences(
            Document document, int caretPosition,
            IFindUsagesService findUsagesService,
            IStreamingFindUsagesPresenter presenter)
        {
            try
            {
                using (var token = _asyncListener.BeginAsyncOperation(nameof(StreamingFindReferences)))
                {
                    // Let the presented know we're starging a search.  It will give us back
                    // the context object that the FAR service will push results into.
                    var context = presenter.StartSearch(
                        EditorFeaturesResources.Find_References, alwaysShowDeclarations: false);
                    await findUsagesService.FindReferencesAsync(document, caretPosition, context).ConfigureAwait(false);

                    // Note: we don't need to put this in a finally.  The only time we might not hit
                    // this is if cancellation or another error gets thrown.  In the former case,
                    // that means that a new search has started.  We don't care about telling the
                    // context it has completed.  In the latter case somethign wrong has happened
                    // and we don't want to run any more code code in this particular context.
                    await context.OnCompletedAsync().ConfigureAwait(false);
                }
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception e) when(FatalError.ReportWithoutCrash(e))
            {
            }
        }
Ejemplo n.º 2
0
        private async Task StreamingFindReferencesAsync(
            Document document,
            int caretPosition,
            IFindUsagesService 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))
            {
            }
        }
        private async Task StreamingFindReferencesAsync(
            Document document, int caretPosition,
            IFindUsagesService 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.
                var context = presenter.StartSearchWithCustomColumns(
                    EditorFeaturesResources.Find_References,
                    supportsReferences: true,
                    includeContainingTypeAndMemberColumns: document.Project.SupportsCompilation,
                    includeKindColumn: document.Project.Language != LanguageNames.FSharp);

                using (Logger.LogBlock(
                           FunctionId.CommandHandler_FindAllReference,
                           KeyValueLogMessage.Create(LogType.UserAction, m => m["type"] = "streaming"),
                           context.CancellationToken))
                {
                    await findUsagesService.FindReferencesAsync(document, caretPosition, context).ConfigureAwait(false);

                    // Note: we don't need to put this in a finally.  The only time we might not hit
                    // this is if cancellation or another error gets thrown.  In the former case,
                    // that means that a new search has started.  We don't care about telling the
                    // context it has completed.  In the latter case something wrong has happened
                    // and we don't want to run any more code in this particular context.
                    await context.OnCompletedAsync().ConfigureAwait(false);
                }
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception e) when(FatalError.ReportWithoutCrash(e))
            {
            }
        }
Ejemplo n.º 4
0
 public Task FindReferencesAsync(Document document, int position, IFindUsagesContext context)
 => _legacyService.FindReferencesAsync(document, position, context);