private static async Task FindReferencesInServiceProcessAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, CancellationToken cancellationToken) { var client = await solution.Workspace.GetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); if (client == null) { await FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); return; } // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then upate the UI. var serverCallback = new ServerCallback(solution, progress, cancellationToken); using (var session = await client.CreateCodeAnalysisServiceSessionAsync( solution, serverCallback, cancellationToken).ConfigureAwait(false)) { await session.InvokeAsync( nameof(IRemoteSymbolFinder.FindReferencesAsync), SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId), documents?.Select(d => d.Id).ToArray()).ConfigureAwait(false); } }
private static async Task FindReferencesInServiceProcessAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet<Document> documents, CancellationToken cancellationToken) { var client = await solution.Workspace.GetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); if (client == null) { await FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); return; } // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then upate the UI. var serverCallback = new ServerCallback(solution, progress, cancellationToken); using (var session = await client.CreateCodeAnalysisServiceSessionAsync( solution, serverCallback, cancellationToken).ConfigureAwait(false)) { await session.InvokeAsync( nameof(IRemoteSymbolFinder.FindReferencesAsync), SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId), documents?.Select(SerializableDocumentId.Dehydrate).ToArray()).ConfigureAwait(false); } }
internal static async Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var handled = await TryFindReferencesInServiceProcessAsync( symbolAndProjectId, solution, progress, documents, options, cancellationToken).ConfigureAwait(false); if (handled) { return; } // Couldn't effectively search using the OOP process. Just perform the search in-proc. await FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, options, cancellationToken).ConfigureAwait(false); } }
private static async Task <bool> TryFindReferencesInServiceProcessAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { // If ProjectId is null then this is a call through our old public API. We don't have // the necessary data to effectively run the call out of proc. if (symbolAndProjectId.ProjectId != null) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken); return(await solution.TryRunCodeAnalysisRemoteAsync( serverCallback, nameof(IRemoteSymbolFinder.FindReferencesAsync), new object[] { SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId), documents?.Select(d => d.Id).ToArray(), SerializableFindReferencesSearchOptions.Dehydrate(options), }, cancellationToken).ConfigureAwait(false)); } return(false); }
public ServerCallback( Solution solution, IStreamingFindReferencesProgress progress, CancellationToken cancellationToken) { _solution = solution; _progress = progress; _cancellationToken = cancellationToken; }
public FindReferencesServerCallback( Solution solution, IStreamingFindReferencesProgress progress, CancellationToken cancellationToken) { _solution = solution; _progress = progress; _cancellationToken = cancellationToken; }
internal static Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet<Document> documents, CancellationToken cancellationToken = default(CancellationToken)) { var engineService = solution.Workspace.Services.GetService<ISymbolFinderEngineService>(); return engineService.FindReferencesAsync(symbolAndProjectId, solution, progress, documents, cancellationToken); }
public FindReferencesServerCallback( Solution solution, IStreamingFindReferencesProgress progress, CancellationToken cancellationToken) { _solution = solution; _progress = progress; _cancellationToken = cancellationToken; _definitionMap = new Dictionary <SerializableSymbolAndProjectId, ISymbol>(this); }
internal static Task FindReferencesInCurrentProcessAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet<Document> documents, CancellationToken cancellationToken) { var finders = ReferenceFinders.DefaultReferenceFinders; progress = progress ?? StreamingFindReferencesProgress.Instance; var engine = new FindReferencesSearchEngine( solution, documents, finders, progress, cancellationToken); return engine.FindReferencesAsync(symbolAndProjectId); }
public async Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet<Document> documents, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { await FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); } }
internal static Task FindReferencesInCurrentProcessAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { var finders = ReferenceFinders.DefaultReferenceFinders; progress = progress ?? StreamingFindReferencesProgress.Instance; var engine = new FindReferencesSearchEngine( solution, documents, finders, progress, options, cancellationToken); return(engine.FindReferencesAsync(symbolAndProjectId)); }
internal static async Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { // If ProjectId is null then this is a call through our old public API. We don't have // the necessary data to effectively run the call out of proc. if (symbolAndProjectId.ProjectId != null) { var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken); var success = await client.TryRunRemoteAsync( WellKnownServiceHubServices.CodeAnalysisService, nameof(IRemoteSymbolFinder.FindReferencesAsync), solution, new object[] { SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId), documents?.Select(d => d.Id).ToArray(), SerializableFindReferencesSearchOptions.Dehydrate(options), }, serverCallback, cancellationToken).ConfigureAwait(false); if (success) { return; } } } // Couldn't effectively search in OOP. Perform the search in-proc. await FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, options, cancellationToken).ConfigureAwait(false); } }
internal static async Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, CancellationToken cancellationToken = default(CancellationToken)) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var finders = ReferenceFinders.DefaultReferenceFinders; progress = progress ?? StreamingFindReferencesProgress.Instance; var engine = new FindReferencesSearchEngine( solution, documents, finders, progress, cancellationToken); await engine.FindReferencesAsync(symbolAndProjectId).ConfigureAwait(false); } }
public FindReferencesSearchEngine( Solution solution, IImmutableSet<Document> documents, ImmutableArray<IReferenceFinder> finders, IStreamingFindReferencesProgress progress, CancellationToken cancellationToken) { _documents = documents; _solution = solution; _finders = finders; _progress = progress; _cancellationToken = cancellationToken; _dependencyGraph = solution.GetProjectDependencyGraph(); _progressTracker = new StreamingProgressTracker(progress.ReportProgressAsync); }
public FindReferencesSearchEngine( Solution solution, IImmutableSet <Document> documents, ImmutableArray <IReferenceFinder> finders, IStreamingFindReferencesProgress progress, CancellationToken cancellationToken) { _documents = documents; _solution = solution; _finders = finders; _progress = progress; _cancellationToken = cancellationToken; _dependencyGraph = solution.GetProjectDependencyGraph(); _progressTracker = new StreamingProgressTracker(progress.ReportProgressAsync); }
public FindReferencesSearchEngine( Solution solution, IImmutableSet <Document> documents, ImmutableArray <IReferenceFinder> finders, IStreamingFindReferencesProgress progress, FindReferencesSearchOptions options, CancellationToken cancellationToken) { _documents = documents; _solution = solution; _finders = finders; _progress = progress; _cancellationToken = cancellationToken; _options = options; _progressTracker = progress.ProgressTracker; }
internal static async Task FindReferencesAsync( ISymbol symbol, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution); using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken); var success = await client.TryRunRemoteAsync( WellKnownServiceHubServices.CodeAnalysisService, nameof(IRemoteSymbolFinder.FindReferencesAsync), solution, new object[] { SerializableSymbolAndProjectId.Dehydrate(solution, symbol, cancellationToken), documents?.Select(d => d.Id).ToArray(), SerializableFindReferencesSearchOptions.Dehydrate(options), }, serverCallback, cancellationToken).ConfigureAwait(false); if (success) { return; } } // Couldn't effectively search in OOP. Perform the search in-proc. await FindReferencesInCurrentProcessAsync( symbol, solution, progress, documents, options, cancellationToken).ConfigureAwait(false); } }
public FindReferencesSearchEngine( Solution solution, IImmutableSet <Document>?documents, ImmutableArray <IReferenceFinder> finders, IStreamingFindReferencesProgress progress, FindReferencesSearchOptions options) { _documents = documents; _solution = solution; _finders = finders; _progress = progress; _options = options; _progressTracker = progress.ProgressTracker; // If we're an explicit invocation, just defer to the threadpool to execute all our work in parallel to get // things done as quickly as possible. If we're running implicitly, then use a // ConcurrentExclusiveSchedulerPair's exclusive scheduler as that's the most built-in way in the TPL to get // will run things serially. _scheduler = _options.Explicit ? TaskScheduler.Default : s_exclusiveScheduler; }
public async Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet<Document> documents, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { if (symbolAndProjectId.ProjectId == null) { // This is a call through our old public API. We don't have the necessary // data to effectively run the call out of proc. await DefaultSymbolFinderEngineService.FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); } else { await FindReferencesInServiceProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); } } }
internal static async Task FindReferencesAsync( ISymbol symbol, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { if (SerializableSymbolAndProjectId.TryCreate(symbol, solution, cancellationToken, out var serializedSymbol)) { var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken); var documentIds = documents?.SelectAsArray(d => d.Id) ?? default; await client.TryInvokeAsync <IRemoteSymbolFinderService>( solution, (service, solutionInfo, callbackId, cancellationToken) => service.FindReferencesAsync(solutionInfo, callbackId, serializedSymbol, documentIds, options, cancellationToken), serverCallback, cancellationToken).ConfigureAwait(false); return; } } // Couldn't effectively search in OOP. Perform the search in-proc. await FindReferencesInCurrentProcessAsync( symbol, solution, progress, documents, options, cancellationToken).ConfigureAwait(false); } }
internal static async Task FindReferencesAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet <Document> documents, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var outOfProcessAllowed = solution.Workspace.Options.GetOption(SymbolFinderOptions.OutOfProcessAllowed); if (symbolAndProjectId.ProjectId == null || !outOfProcessAllowed) { // This is a call through our old public API. We don't have the necessary // data to effectively run the call out of proc. await FindReferencesInCurrentProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); } else { await FindReferencesInServiceProcessAsync( symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false); } } }
public StreamingProgressCollector( IStreamingFindReferencesProgress underlyingProgress) { _underlyingProgress = underlyingProgress; }
public ProgressWrapper(IStreamingFindReferencesProgress progress, int maximum) { _progress = progress; _maximum = maximum; }