Remove more delegates from FindRefs.#62027
Conversation
|
|
||
| return default; | ||
| }; | ||
| } |
There was a problem hiding this comment.
both of these static static lambdas just became ordinary methods.
| public abstract ValueTask<ImmutableArray<FinderLocation>> FindReferencesInDocumentAsync( | ||
| ISymbol symbol, FindReferencesDocumentState state, FindReferencesSearchOptions options, CancellationToken cancellationToken); | ||
|
|
||
| protected virtual ValueTask<(bool matched, CandidateReason reason)> SymbolsMatchAsync( |
There was a problem hiding this comment.
these are moves up from the static lambdas we had into normal methods.
There was a problem hiding this comment.
note: This is a virtual as there's one finder currently that overrides it (though i'd like to get rid of htat asap).
There was a problem hiding this comment.
because it's virtual, it became an instance method, so a lot of statics become instance methods
| return SymbolsMatchAsync(symbol, state, parent, cancellationToken); | ||
| } | ||
|
|
||
| protected static async ValueTask<(bool matched, CandidateReason reason)> SymbolsMatchAsync( |
There was a problem hiding this comment.
renamed as this is the same as the above method, just taking a node instead of a token.
| => FindDocumentsWithPredicateAsync(project, documents, static (sti, _) => sti.ContainsAwait, /*unused*/false, cancellationToken); | ||
|
|
||
| protected static Task<ImmutableArray<Document>> FindDocumentsWithImplicitObjectCreationExpressionAsync(Project project, IImmutableSet<Document>? documents, CancellationToken cancellationToken) | ||
| => FindDocumentsWithPredicateAsync(project, documents, static (sti, _) => sti.ContainsImplicitObjectCreation, /*unused*/false, cancellationToken); |
There was a problem hiding this comment.
these were all only referenced from single specific subtypes. so they moved to those subtypes.
| cancellationToken); | ||
| } | ||
|
|
||
| private static Func<ISymbol, FindReferencesDocumentState, SyntaxToken, CancellationToken, ValueTask<(bool matched, CandidateReason reason)>> GetParameterSymbolsMatchFunction( |
There was a problem hiding this comment.
this got substantively changed. instead of having a single parameter trying to match against lots of different symbols, instead we cascade first to get the different symbols, and then do matching normally.
| state, | ||
| static (state, token, predefinedType, _) => IsPotentialReference(predefinedType, state.SyntaxFacts, token), | ||
| static (_, state, token, _) => ValueTaskFactory.FromResult((matched: true, reason: CandidateReason.None)), | ||
| // static (_, state, token, _) => ValueTaskFactory.FromResult((matched: true, reason: CandidateReason.None)), |
| } | ||
|
|
||
| private static Task<ImmutableArray<Document>> FindDocumentsWithImplicitObjectCreationExpressionAsync(Project project, IImmutableSet<Document>? documents, CancellationToken cancellationToken) | ||
| => FindDocumentsWithPredicateAsync(project, documents, static (sti, _) => sti.ContainsImplicitObjectCreation, /*unused*/false, cancellationToken); |
There was a problem hiding this comment.
would it be worth having an overload that doesn't take the unused value?
There was a problem hiding this comment.
sure. let me try that :)
There was a problem hiding this comment.
thanks. that does make things nicer!
…s/NamedTypeSymbolReferenceFinder.cs
No description provided.