private static async Task FindImplementationsInCurrentProcessAsync( ISymbol symbol, Project project, IFindUsagesContext context) { var cancellationToken = context.CancellationToken; var solution = project.Solution; var(implementations, message) = await FindSourceImplementationsAsync( solution, symbol, cancellationToken).ConfigureAwait(false); if (message != null) { await context.ReportMessageAsync(message).ConfigureAwait(false); return; } await context.SetSearchTitleAsync( string.Format(EditorFeaturesResources._0_implementations, FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false); foreach (var implementation in implementations) { var definitionItem = await implementation.ToClassifiedDefinitionItemAsync( solution, isPrimary : true, includeHiddenLocations : false, FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); } }
public async Task FindImplementationsAsync(Document document, int position, IFindUsagesContext context) { var tuple = await FindUsagesHelpers.FindImplementationsAsync( document, position, context.CancellationToken).ConfigureAwait(false); if (tuple == null) { context.ReportMessage(EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret); return; } var message = tuple.Value.message; if (message != null) { context.ReportMessage(message); return; } context.SetSearchTitle(string.Format(EditorFeaturesResources._0_implementations, FindUsagesHelpers.GetDisplayName(tuple.Value.symbol))); var project = tuple.Value.project; foreach (var implementation in tuple.Value.implementations) { var definitionItem = implementation.ToDefinitionItem( project.Solution, includeHiddenLocations: false); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); } }
/// <summary> /// Public helper that we use from features like ObjectBrowser which start with a symbol /// and want to push all the references to it into the Streaming-Find-References window. /// </summary> public static async Task FindSymbolReferencesAsync( IFindUsagesContext context, ISymbol symbol, Project project) { await context.SetSearchTitleAsync(string.Format(EditorFeaturesResources._0_references, FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false); var options = FindReferencesSearchOptions.GetFeatureOptionsForStartingSymbol(symbol); // 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 FindReferencesAsync(context, symbol, project, options).ConfigureAwait(false); }
/// <summary> /// Public helper that we use from features like ObjectBrowser which start with a symbol /// and want to push all the references to it into the Streaming-Find-References window. /// </summary> public static async Task FindSymbolReferencesAsync( IFindUsagesContext context, ISymbol symbol, Project project, CancellationToken cancellationToken) { await context.SetSearchTitleAsync(string.Format(EditorFeaturesResources._0_references, FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false); var progressAdapter = new FindReferencesProgressAdapter(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); }
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 async Task FindSymbolReferencesAsync( IFindUsagesContext context, ISymbol symbol, Project project) { var solution = project.Solution; var monikerUsagesService = solution.Workspace.Services.GetRequiredService <IFindSymbolMonikerUsagesService>(); await context.SetSearchTitleAsync(string.Format(EditorFeaturesResources._0_references, FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false); var options = FindReferencesSearchOptions.GetFeatureOptionsForStartingSymbol(symbol); // 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. // // Kick off work to search the online code index system in parallel. // // Do both in parallel so we can get all the results as soon as possible. await Task.WhenAll( FindReferencesAsync(context, symbol, project, options), FindSymbolMonikerReferencesAsync(monikerUsagesService, symbol, context)).ConfigureAwait(false); }