Support find refs on global aliases.#56326
Conversation
| @@ -170,32 +170,47 @@ private async Task<HashSet<ProjectId>> GetProjectIdsToSearchAsync( | |||
|
|
|||
| private async Task ProcessProjectAsync(Project project, ImmutableArray<ISymbol> allSymbols, CancellationToken cancellationToken) | |||
There was a problem hiding this comment.
this is the major top level algorithmic change. as we start to search a project, we first see if the symbols we're searching for could have global aliases to them in that project. We then pass those global aliases along to the actual 'finders' responsible for figuring out what doucments to search and what to search for in those documents.
| protected static Task<ImmutableArray<FinderLocation>> FindAliasReferencesAsync( | ||
| ImmutableArray<FinderLocation> nonAliasReferences, | ||
| protected static Task<ImmutableArray<FinderLocation>> FindLocalAliasReferencesAsync( | ||
| ArrayBuilder<FinderLocation> initialReferences, |
There was a problem hiding this comment.
i stopped calling these 'nonAliasReferences' because these could be global aliases. I also renamed a lot of 'FindAliasXXX' helpers to 'FindLocalAliases' to help keep the split between global and local aliases clearer.
| } | ||
|
|
||
| return result.ToImmutableAndClear(); | ||
| } |
There was a problem hiding this comment.
this is the helper that actually tells you what global aliases there potentially are for a given symbol
| namespace Microsoft.CodeAnalysis.FindSymbols.Finders | ||
| { | ||
| internal class ConstructorInitializerSymbolReferenceFinder : AbstractReferenceFinder<IMethodSymbol> | ||
| internal sealed class ConstructorInitializerSymbolReferenceFinder : AbstractReferenceFinder<IMethodSymbol> |
There was a problem hiding this comment.
i sealed a lot of stuff for my sanity. it was harder to determine virtual/override routes otherwise.
| HashSet<string>? globalAliases, | ||
| Document document, | ||
| SemanticModel semanticModel, | ||
| FindReferencesSearchOptions options, |
There was a problem hiding this comment.
most finders were unaffected (except fort hese signature changes). the only finders that care are Namespaces/NamedTypes/Constructors
| CancellationToken cancellationToken) | ||
| { | ||
| var documentsWithName = await FindDocumentsAsync(project, documents, cancellationToken, typeName).ConfigureAwait(false); | ||
| var documentsWithType = await FindDocumentsAsync(project, documents, symbol.ContainingType.SpecialType.ToPredefinedType(), cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
this got inlined into the caller. we don't want to search for built-in types twice, we only want to do the multi-passes for real names and aliases.
...orkspaces/Core/Portable/FindSymbols/FindReferences/Finders/NamedTypeSymbolReferenceFinder.cs
Show resolved
Hide resolved
|
Thanks! |
Fixes #55894