private async Task<ProgressAdapter> FindReferencesWorkerAsync( Document document, int position, IFindUsagesContext context) { var cancellationToken = context.CancellationToken; cancellationToken.ThrowIfCancellationRequested(); // Find the symbol we want to search and the solution we want to search in. var symbolAndProject = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); if (symbolAndProject == null) { return null; } var symbol = symbolAndProject?.symbol; var project = symbolAndProject?.project; context.SetSearchTitle(string.Format(EditorFeaturesResources._0_references, FindUsagesHelpers.GetDisplayName(symbol))); var progressAdapter = new ProgressAdapter(project.Solution, context); // Now call into the underlying FAR engine to find reference. The FAR // engine will push results into the 'progress' instance passed into it. // We'll take those results, massage them, and forward them along to the // FindReferencesContext instance we were given. await SymbolFinder.FindReferencesAsync( SymbolAndProjectId.Create(symbol, project.Id), project.Solution, progressAdapter, documents: null, cancellationToken: cancellationToken).ConfigureAwait(false); return progressAdapter; }
public static Session StartWaitDialog(this WaitDialogFactory factory, string waitCatption, WaitDialogProgressData initialProgress = null, TimeSpan delayToShow = default) { var instance = factory.CreateInstance(); var cancellationSource = new CancellationTokenSource(); var progress = new ProgressAdapter(instance, cancellationSource); var callback = new CancellationCallback(cancellationSource); instance.StartWaitDialogWithCallback(waitCatption, initialProgress?.WaitMessage, initialProgress?.ProgressText, initialProgress != null && initialProgress.IsCancelable, (int)delayToShow.TotalSeconds, true, initialProgress?.TotalSteps ?? 0, initialProgress?.CurrentStep ?? 0, callback); return(new Session(instance, progress, cancellationSource.Token, callback)); }
public async Task FindReferencesAsync( Document document, int position, FindReferencesContext context) { var cancellationToken = context.CancellationToken; cancellationToken.ThrowIfCancellationRequested(); // Find the symbol we want to search and the solution we want to search in. var symbolAndSolution = await GetRelevantSymbolAndSolutionAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); if (symbolAndSolution == null) { return; } var symbol = symbolAndSolution.Item1; var solution = symbolAndSolution.Item2; var displayName = GetDisplayName(symbol); context.SetSearchLabel(displayName); var progressAdapter = new ProgressAdapter(solution, context); // Now call into the underlying FAR engine to find reference. The FAR // engine will push results into the 'progress' instance passed into it. // We'll take those results, massage them, and forward them along to the // FindReferencesContext instance we were given. // // Note: we pass along ConfigureAwait(true) because we need to come back // to the UI thread. There's more work we need to do once the FAR engine // is done. await SymbolFinder.FindReferencesAsync( symbol, solution, progressAdapter, documents : null, cancellationToken : cancellationToken).ConfigureAwait(true); // After the FAR engine is done call into any third party extensions to see // if they want to add results. progressAdapter.CallThirdPartyExtensions(); }
public static DownloadSession BeginDownload(this PSCmdlet cmdlet, ISearchResult searchResult) { UpdateSession session = new UpdateSession(); UpdateDownloader downloader = session.CreateDownloader(); downloader.Updates = searchResult.Updates; downloader.Priority = DownloadPriority.dpExtraHigh; ProgressAdapter adapter = new ProgressAdapter(cmdlet, downloader); DownloadProgressChangedCallback progressCallback = new DownloadProgressChangedCallback(adapter); DownloadCompletedCallback completedCallback = new DownloadCompletedCallback(downloader); object state = new object(); downloader.BeginDownload(progressCallback, completedCallback, state); return(DownloadSession.From(completedCallback)); }
private async Task <ProgressAdapter> FindReferencesWorkerAsync( Document document, int position, IFindUsagesContext context) { var cancellationToken = context.CancellationToken; cancellationToken.ThrowIfCancellationRequested(); // Find the symbol we want to search and the solution we want to search in. var symbolAndProject = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); if (symbolAndProject == null) { return(null); } var symbol = symbolAndProject?.symbol; var project = symbolAndProject?.project; var displayName = AbstractFindReferencesService.GetDisplayName(symbol); context.SetSearchLabel(displayName); var progressAdapter = new ProgressAdapter(project.Solution, context); // Now call into the underlying FAR engine to find reference. The FAR // engine will push results into the 'progress' instance passed into it. // We'll take those results, massage them, and forward them along to the // FindReferencesContext instance we were given. await SymbolFinder.FindReferencesAsync( SymbolAndProjectId.Create(symbol, project.Id), project.Solution, progressAdapter, documents : null, cancellationToken : cancellationToken).ConfigureAwait(false); return(progressAdapter); }
public async Task FindReferencesAsync( Document document, int position, FindReferencesContext context) { var cancellationToken = context.CancellationToken; cancellationToken.ThrowIfCancellationRequested(); // Find the symbol we want to search and the solution we want to search in. var symbolAndSolution = await GetRelevantSymbolAndSolutionAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); if (symbolAndSolution == null) { return; } var symbol = symbolAndSolution.Item1; var solution = symbolAndSolution.Item2; var displayName = GetDisplayName(symbol); context.SetSearchLabel(displayName); var progressAdapter = new ProgressAdapter(solution, context); // Now call into the underlying FAR engine to find reference. The FAR // engine will push results into the 'progress' instance passed into it. // We'll take those results, massage them, and forward them along to the // FindReferencesContext instance we were given. // // Note: we pass along ConfigureAwait(true) because we need to come back // to the UI thread. There's more work we need to do once the FAR engine // is done. await SymbolFinder.FindReferencesAsync( symbol, solution, progressAdapter, documents: null, cancellationToken: cancellationToken).ConfigureAwait(true); // After the FAR engine is done call into any third party extensions to see // if they want to add results. progressAdapter.CallThirdPartyExtensions(); }