Skip to content

Commit

Permalink
Don't search remote process for unsupported languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilchie committed Jun 30, 2017
1 parent 99c9434 commit 3ea96c5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task<ImmutableArray<AddImportFixData>> GetFixesAsync(

using (session)
{
if (session == null)
if (session == null || !RemoteSupportedLanguages.IsSupported(document.Project.Language))
{
return await GetFixesInCurrentProcessAsync(
document, span, diagnosticId, placeSystemNamespaceFirst,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ private async Task<ImmutableArray<INavigateToSearchResult>> SearchProjectInRemot

private static Task<RemoteHostClient.Session> GetRemoteHostSessionAsync(Project project, CancellationToken cancellationToken)
{
if (!RemoteSupportedLanguages.IsSupported(project.Language))
{
return null;
}

return project.Solution.TryCreateCodeAnalysisServiceSessionAsync(
RemoteFeatureOptions.NavigateToEnabled, cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,22 @@ await AddMetadataDeclarationsWithNormalQueryAsync(
private static async Task<(bool, ImmutableArray<SymbolAndProjectId>)> 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<ImmutableArray<SerializableSymbolAndProjectId>>(
nameof(IRemoteSymbolFinder.FindAllDeclarationsWithNormalQueryAsync),
project.Id, query.Name, query.Kind, criteria).ConfigureAwait(false);
if (session != null)
{
var result = await session.InvokeAsync<ImmutableArray<SerializableSymbolAndProjectId>>(
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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarationsWithNormalQueryAsync(
Solution solution, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken)
Expand Down Expand Up @@ -135,18 +135,21 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarati
private static async Task<(bool, ImmutableArray<SymbolAndProjectId>)> 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<ImmutableArray<SerializableSymbolAndProjectId>>(
nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithNormalQueryAsync),
project.Id, name, ignoreCase, criteria).ConfigureAwait(false);
if (session != null)
{
var result = await session.InvokeAsync<ImmutableArray<SerializableSymbolAndProjectId>>(
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);
}
}
}

Expand All @@ -156,18 +159,21 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarati
private static async Task<(bool, ImmutableArray<SymbolAndProjectId>)> 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<ImmutableArray<SerializableSymbolAndProjectId>>(
nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithPatternAsync),
project.Id, pattern, criteria).ConfigureAwait(false);
if (session != null)
{
var result = await session.InvokeAsync<ImmutableArray<SerializableSymbolAndProjectId>>(
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);
}
}
}

Expand Down

0 comments on commit 3ea96c5

Please sign in to comment.