From 3ea96c5553baceff17183fe1d8098d110b9c66d1 Mon Sep 17 00:00:00 2001 From: Kevin Pilch Date: Fri, 23 Jun 2017 16:12:47 -0700 Subject: [PATCH] Don't search remote process for unsupported languages --- .../AbstractAddImportFeatureService.cs | 2 +- .../AbstractNavigateToSearchService.Remote.cs | 5 +++ .../DeclarationFinder_AllDeclarations.cs | 21 +++++----- .../DeclarationFinder_SourceDeclarations.cs | 40 +++++++++++-------- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs b/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs index 5b58326db4edd..c311f2077f62b 100644 --- a/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs +++ b/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs @@ -67,7 +67,7 @@ public async Task> GetFixesAsync( using (session) { - if (session == null) + if (session == null || !RemoteSupportedLanguages.IsSupported(document.Project.Language)) { return await GetFixesInCurrentProcessAsync( document, span, diagnosticId, placeSystemNamespaceFirst, diff --git a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs index 40afd57a9965f..f5075c2085bf3 100644 --- a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs +++ b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs @@ -31,6 +31,11 @@ private async Task> SearchProjectInRemot private static Task GetRemoteHostSessionAsync(Project project, CancellationToken cancellationToken) { + if (!RemoteSupportedLanguages.IsSupported(project.Language)) + { + return null; + } + return project.Solution.TryCreateCodeAnalysisServiceSessionAsync( RemoteFeatureOptions.NavigateToEnabled, cancellationToken); } diff --git a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs index 188088e5a28a6..472487a1fea26 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs @@ -93,19 +93,22 @@ await AddMetadataDeclarationsWithNormalQueryAsync( private static async Task<(bool, ImmutableArray)> TryFindAllDeclarationsWithNormalQueryInRemoteProcessAsync( Project project, SearchQuery query, SymbolFilter criteria, CancellationToken cancellationToken) { - using (var session = await SymbolFinder.TryGetRemoteSessionAsync( - project.Solution, cancellationToken).ConfigureAwait(false)) + if (RemoteSupportedLanguages.IsSupported(project.Language)) { - if (session != null) + using (var session = await SymbolFinder.TryGetRemoteSessionAsync( + project.Solution, cancellationToken).ConfigureAwait(false)) { - var result = await session.InvokeAsync>( - nameof(IRemoteSymbolFinder.FindAllDeclarationsWithNormalQueryAsync), - project.Id, query.Name, query.Kind, criteria).ConfigureAwait(false); + if (session != null) + { + var result = await session.InvokeAsync>( + nameof(IRemoteSymbolFinder.FindAllDeclarationsWithNormalQueryAsync), + project.Id, query.Name, query.Kind, criteria).ConfigureAwait(false); - var rehydrated = await RehydrateAsync( - project.Solution, result, cancellationToken).ConfigureAwait(false); + var rehydrated = await RehydrateAsync( + project.Solution, result, cancellationToken).ConfigureAwait(false); - return (true, rehydrated); + return (true, rehydrated); + } } } diff --git a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs index 12f54f688e579..719ebfac6da14 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs @@ -18,7 +18,7 @@ internal static partial class DeclarationFinder #region Dispatch Members // These are the public entrypoints to finding source declarations. They will attempt to - // remove the query to the OOP process, and will fallback to local processing if they can't. + // remote the query to the OOP process, and will fallback to local processing if they can't. public static async Task> FindSourceDeclarationsWithNormalQueryAsync( Solution solution, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken) @@ -135,18 +135,21 @@ public static async Task> FindSourceDeclarati private static async Task<(bool, ImmutableArray)> TryFindSourceDeclarationsWithNormalQueryInRemoteProcessAsync( Project project, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken) { - using (var session = await SymbolFinder.TryGetRemoteSessionAsync(project.Solution, cancellationToken).ConfigureAwait(false)) + if (RemoteSupportedLanguages.IsSupported(project.Language)) { - if (session != null) + using (var session = await SymbolFinder.TryGetRemoteSessionAsync(project.Solution, cancellationToken).ConfigureAwait(false)) { - var result = await session.InvokeAsync>( - nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithNormalQueryAsync), - project.Id, name, ignoreCase, criteria).ConfigureAwait(false); + if (session != null) + { + var result = await session.InvokeAsync>( + nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithNormalQueryAsync), + project.Id, name, ignoreCase, criteria).ConfigureAwait(false); - var rehydrated = await RehydrateAsync( - project.Solution, result, cancellationToken).ConfigureAwait(false); + var rehydrated = await RehydrateAsync( + project.Solution, result, cancellationToken).ConfigureAwait(false); - return (true, rehydrated); + return (true, rehydrated); + } } } @@ -156,18 +159,21 @@ public static async Task> FindSourceDeclarati private static async Task<(bool, ImmutableArray)> TryFindSourceDeclarationsWithPatternInRemoteProcessAsync( Project project, string pattern, SymbolFilter criteria, CancellationToken cancellationToken) { - using (var session = await SymbolFinder.TryGetRemoteSessionAsync(project.Solution, cancellationToken).ConfigureAwait(false)) + if (RemoteSupportedLanguages.IsSupported(project.Language)) { - if (session != null) + using (var session = await SymbolFinder.TryGetRemoteSessionAsync(project.Solution, cancellationToken).ConfigureAwait(false)) { - var result = await session.InvokeAsync>( - nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithPatternAsync), - project.Id, pattern, criteria).ConfigureAwait(false); + if (session != null) + { + var result = await session.InvokeAsync>( + nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithPatternAsync), + project.Id, pattern, criteria).ConfigureAwait(false); - var rehydrated = await RehydrateAsync( - project.Solution, result, cancellationToken).ConfigureAwait(false); + var rehydrated = await RehydrateAsync( + project.Solution, result, cancellationToken).ConfigureAwait(false); - return (true, rehydrated); + return (true, rehydrated); + } } }