提交 f2ea263a 编写于 作者: C CyrusNajmabadi

Key off the type and hte projects being searched.

上级 2cdb184e
...@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.FindSymbols ...@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.FindSymbols
{ {
using SymbolAndProjectIdSet = HashSet<SymbolAndProjectId<INamedTypeSymbol>>; using SymbolAndProjectIdSet = HashSet<SymbolAndProjectId<INamedTypeSymbol>>;
using RelatedTypeCache = ConditionalWeakTable<Solution, ConcurrentDictionary<INamedTypeSymbol, AsyncLazy<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>>>>; using RelatedTypeCache = ConditionalWeakTable<Solution, ConcurrentDictionary<(INamedTypeSymbol, IImmutableSet<Project>), AsyncLazy<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>>>>;
/// <summary> /// <summary>
/// Provides helper methods for finding dependent types (derivations, implementations, /// Provides helper methods for finding dependent types (derivations, implementations,
...@@ -56,12 +56,13 @@ internal static class DependentTypeFinder ...@@ -56,12 +56,13 @@ internal static class DependentTypeFinder
public static async Task<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>> FindTypesFromCacheOrComputeAsync( public static async Task<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>> FindTypesFromCacheOrComputeAsync(
INamedTypeSymbol type, INamedTypeSymbol type,
Solution solution, Solution solution,
IImmutableSet<Project> projects,
RelatedTypeCache cache, RelatedTypeCache cache,
Func<CancellationToken, Task<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>>> findAsync, Func<CancellationToken, Task<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>>> findAsync,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var dictionary = cache.GetOrCreateValue(solution); var dictionary = cache.GetOrCreateValue(solution);
var lazy = dictionary.GetOrAdd(type, new AsyncLazy<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>>( var lazy = dictionary.GetOrAdd((type, projects), new AsyncLazy<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>>(
asynchronousComputeFunction: findAsync, cacheResult: true)); asynchronousComputeFunction: findAsync, cacheResult: true));
return await lazy.GetValueAsync(cancellationToken).ConfigureAwait(false); return await lazy.GetValueAsync(cancellationToken).ConfigureAwait(false);
...@@ -76,11 +77,12 @@ internal static class DependentTypeFinder ...@@ -76,11 +77,12 @@ internal static class DependentTypeFinder
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return FindTypesFromCacheOrComputeAsync( return FindTypesFromCacheOrComputeAsync(
type, solution, s_typeToImmediatelyDerivedClassesMap, type, solution, projects: null,
c => FindDerivedClassesAsync( cache: s_typeToImmediatelyDerivedClassesMap,
findAsync: c => FindDerivedClassesAsync(
SymbolAndProjectId.Create(type, projectId: null), solution, projects: null, SymbolAndProjectId.Create(type, projectId: null), solution, projects: null,
transitive: false, cancellationToken: c), transitive: false, cancellationToken: c),
cancellationToken); cancellationToken: cancellationToken);
} }
/// <summary> /// <summary>
...@@ -93,7 +95,7 @@ internal static class DependentTypeFinder ...@@ -93,7 +95,7 @@ internal static class DependentTypeFinder
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return FindTypesFromCacheOrComputeAsync( return FindTypesFromCacheOrComputeAsync(
type, solution, s_typeToTransitivelyDerivedClassesMap, type, solution, projects, s_typeToTransitivelyDerivedClassesMap,
c => FindDerivedClassesAsync( c => FindDerivedClassesAsync(
SymbolAndProjectId.Create(type, projectId: null), solution, projects, SymbolAndProjectId.Create(type, projectId: null), solution, projects,
transitive: true, cancellationToken: c), transitive: true, cancellationToken: c),
...@@ -137,7 +139,7 @@ internal static class DependentTypeFinder ...@@ -137,7 +139,7 @@ internal static class DependentTypeFinder
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return FindTypesFromCacheOrComputeAsync( return FindTypesFromCacheOrComputeAsync(
type, solution, s_typeToTransitivelyImplementingTypesMap, type, solution, projects, s_typeToTransitivelyImplementingTypesMap,
c => FindTransitivelyImplementingTypesWorkerAsync(type, solution, projects, c), c => FindTransitivelyImplementingTypesWorkerAsync(type, solution, projects, c),
cancellationToken); cancellationToken);
} }
...@@ -166,11 +168,12 @@ internal static class DependentTypeFinder ...@@ -166,11 +168,12 @@ internal static class DependentTypeFinder
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return FindTypesFromCacheOrComputeAsync( return FindTypesFromCacheOrComputeAsync(
type, solution, s_typeToImmediatelyDerivedAndImplementingTypesMap, type, solution, projects: null,
c => FindDerivedAndImplementingTypesAsync( cache: s_typeToImmediatelyDerivedAndImplementingTypesMap,
findAsync: c => FindDerivedAndImplementingTypesAsync(
SymbolAndProjectId.Create(type, projectId: null), solution, projects: null, SymbolAndProjectId.Create(type, projectId: null), solution, projects: null,
transitive: false, cancellationToken: c), transitive: false, cancellationToken: c),
cancellationToken); cancellationToken: cancellationToken);
} }
private static Task<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>> FindDerivedAndImplementingTypesAsync( private static Task<ImmutableArray<SymbolAndProjectId<INamedTypeSymbol>>> FindDerivedAndImplementingTypesAsync(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册