提交 a416a123 编写于 作者: C Cyrus Najmabadi

Fix

上级 284db945
...@@ -38,7 +38,7 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) ...@@ -38,7 +38,7 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
return; return;
} }
var (symbolAndProjectId, implementations, message) = tupleOpt.Value; var (solution, symbolAndProjectId, implementations, message) = tupleOpt.Value;
if (message != null) if (message != null)
{ {
await context.ReportMessageAsync(message).ConfigureAwait(false); await context.ReportMessageAsync(message).ConfigureAwait(false);
...@@ -49,7 +49,6 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) ...@@ -49,7 +49,6 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
string.Format(EditorFeaturesResources._0_implementations, string.Format(EditorFeaturesResources._0_implementations,
FindUsagesHelpers.GetDisplayName(symbolAndProjectId.Symbol))).ConfigureAwait(false); FindUsagesHelpers.GetDisplayName(symbolAndProjectId.Symbol))).ConfigureAwait(false);
var solution = document.Project.Solution;
foreach (var implementation in implementations) foreach (var implementation in implementations)
{ {
var definitionItem = await implementation.Symbol.ToClassifiedDefinitionItemAsync( var definitionItem = await implementation.Symbol.ToClassifiedDefinitionItemAsync(
...@@ -122,18 +121,16 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) ...@@ -122,18 +121,16 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
// Find the symbol we want to search and the solution we want to search in. // Find the symbol we want to search and the solution we want to search in.
var symbolAndProjectIdOpt = await FindUsagesHelpers.GetRelevantSymbolAndProjectIdAtPositionAsync( var symbolAndProjectOpt = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync(
document, position, cancellationToken).ConfigureAwait(false); document, position, cancellationToken).ConfigureAwait(false);
if (symbolAndProjectIdOpt == null) if (symbolAndProjectOpt == null)
return; return;
var solution = document.Project.Solution; var (symbol, project) = symbolAndProjectOpt.Value;
var symbolAndProjectId = symbolAndProjectIdOpt.Value;
await FindSymbolReferencesAsync( await FindSymbolReferencesAsync(
_threadingContext, context, _threadingContext, context,
symbolAndProjectId.Symbol, symbol, project,
solution.GetRequiredProject(symbolAndProjectId.ProjectId),
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);
} }
......
...@@ -31,7 +31,7 @@ public static string GetDisplayName(ISymbol symbol) ...@@ -31,7 +31,7 @@ public static string GetDisplayName(ISymbol symbol)
/// there may be symbol mapping involved (for example in Metadata-As-Source /// there may be symbol mapping involved (for example in Metadata-As-Source
/// scenarios). /// scenarios).
/// </summary> /// </summary>
public static async Task<SymbolAndProjectId?> GetRelevantSymbolAndProjectIdAtPositionAsync( public static async Task<(ISymbol symbol, Project project)?> GetRelevantSymbolAndProjectAtPositionAsync(
Document document, int position, CancellationToken cancellationToken) Document document, int position, CancellationToken cancellationToken)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
...@@ -49,21 +49,23 @@ public static string GetDisplayName(ISymbol symbol) ...@@ -49,21 +49,23 @@ public static string GetDisplayName(ISymbol symbol)
if (mapping == null) if (mapping == null)
return null; return null;
return new SymbolAndProjectId(mapping.Symbol, mapping.Project.Id); return (mapping.Symbol, mapping.Project);
} }
public static async Task<(SymbolAndProjectId symboAndProjectId, ImmutableArray<SymbolAndProjectId> implementations, string message)?> FindSourceImplementationsAsync(Document document, int position, CancellationToken cancellationToken) public static async Task<(Solution solution, SymbolAndProjectId symboAndProjectId, ImmutableArray<SymbolAndProjectId> implementations, string message)?> FindSourceImplementationsAsync(Document document, int position, CancellationToken cancellationToken)
{ {
var symbolAndProjectIdOpt = await GetRelevantSymbolAndProjectIdAtPositionAsync( var symbolAndProjectOpt = await GetRelevantSymbolAndProjectAtPositionAsync(
document, position, cancellationToken).ConfigureAwait(false); document, position, cancellationToken).ConfigureAwait(false);
if (symbolAndProjectIdOpt == null) if (symbolAndProjectOpt == null)
return null; return null;
var (symbol, project) = symbolAndProjectOpt.Value;
var symbolAndProjectId = new SymbolAndProjectId(symbol, project.Id);
return await FindSourceImplementationsAsync( return await FindSourceImplementationsAsync(
symbolAndProjectIdOpt.Value, document.Project.Solution, cancellationToken).ConfigureAwait(false); symbolAndProjectId, project.Solution, cancellationToken).ConfigureAwait(false);
} }
private static async Task<(SymbolAndProjectId symbolAndProjectId, ImmutableArray<SymbolAndProjectId> implementations, string message)?> FindSourceImplementationsAsync( private static async Task<(Solution solution, SymbolAndProjectId symbolAndProjectId, ImmutableArray<SymbolAndProjectId> implementations, string message)?> FindSourceImplementationsAsync(
SymbolAndProjectId symbolAndProjectId, Solution solution, CancellationToken cancellationToken) SymbolAndProjectId symbolAndProjectId, Solution solution, CancellationToken cancellationToken)
{ {
var builder = new HashSet<SymbolAndProjectId>(SymbolAndProjectIdComparer.SymbolEquivalenceInstance); var builder = new HashSet<SymbolAndProjectId>(SymbolAndProjectIdComparer.SymbolEquivalenceInstance);
...@@ -86,8 +88,8 @@ public static async Task<(SymbolAndProjectId symboAndProjectId, ImmutableArray<S ...@@ -86,8 +88,8 @@ public static async Task<(SymbolAndProjectId symboAndProjectId, ImmutableArray<S
var result = builder.ToImmutableArray(); var result = builder.ToImmutableArray();
return result.Length == 0 return result.Length == 0
? (symbolAndProjectId, result, EditorFeaturesResources.The_symbol_has_no_implementations) ? (solution, symbolAndProjectId, result, EditorFeaturesResources.The_symbol_has_no_implementations)
: (symbolAndProjectId, result, null); : (solution, symbolAndProjectId, result, null);
} }
private static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceImplementationsWorkerAsync( private static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceImplementationsWorkerAsync(
......
...@@ -16,30 +16,24 @@ internal abstract partial class AbstractGoToBaseService : IGoToBaseService ...@@ -16,30 +16,24 @@ internal abstract partial class AbstractGoToBaseService : IGoToBaseService
public async Task FindBasesAsync(Document document, int position, IFindUsagesContext context) public async Task FindBasesAsync(Document document, int position, IFindUsagesContext context)
{ {
var cancellationToken = context.CancellationToken; var cancellationToken = context.CancellationToken;
var symbolAndProjectIdOpt = await FindUsagesHelpers.GetRelevantSymbolAndProjectIdAtPositionAsync( var symbolAndProjectOpt = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync(
document, position, cancellationToken).ConfigureAwait(false); document, position, cancellationToken).ConfigureAwait(false);
if (symbolAndProjectIdOpt == null) if (symbolAndProjectOpt == null)
{ {
await context.ReportMessageAsync( await context.ReportMessageAsync(
EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret).ConfigureAwait(false); EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret).ConfigureAwait(false);
return; return;
} }
var solution = document.Project.Solution; var (symbol, project) = symbolAndProjectOpt.Value;
var symbolAndProjectId = symbolAndProjectIdOpt.Value;
var bases = FindBaseHelpers.FindBases( var bases = FindBaseHelpers.FindBases(
symbolAndProjectId.Symbol, symbol, project, cancellationToken);
solution.GetRequiredProject(symbolAndProjectId.ProjectId),
cancellationToken);
await context.SetSearchTitleAsync( await context.SetSearchTitleAsync(
string.Format(EditorFeaturesResources._0_bases, string.Format(EditorFeaturesResources._0_bases,
FindUsagesHelpers.GetDisplayName(symbolAndProjectId.Symbol))).ConfigureAwait(false); FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false);
var project = document.Project;
var projectId = project.Id;
var found = false; var found = false;
...@@ -49,11 +43,11 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon ...@@ -49,11 +43,11 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon
foreach (var baseSymbol in bases) foreach (var baseSymbol in bases)
{ {
var sourceDefinition = await SymbolFinder.FindSourceDefinitionAsync( var sourceDefinition = await SymbolFinder.FindSourceDefinitionAsync(
SymbolAndProjectId.Create(baseSymbol, projectId), solution, cancellationToken).ConfigureAwait(false); SymbolAndProjectId.Create(baseSymbol, project.Id), project.Solution, cancellationToken).ConfigureAwait(false);
if (sourceDefinition.Symbol != null) if (sourceDefinition.Symbol != null)
{ {
var definitionItem = await sourceDefinition.Symbol.ToClassifiedDefinitionItemAsync( var definitionItem = await sourceDefinition.Symbol.ToClassifiedDefinitionItemAsync(
solution.GetProject(sourceDefinition.ProjectId), includeHiddenLocations: false, project.Solution.GetProject(sourceDefinition.ProjectId), includeHiddenLocations: false,
FindReferencesSearchOptions.Default, cancellationToken: cancellationToken) FindReferencesSearchOptions.Default, cancellationToken: cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册