[Lightbulb Perf] Expose FilterSpan/FilterTree public API on remaining analysis contexts #68033
Labels
api-approved
API was approved in API review, it can be implemented
Area-Analyzers
Concept-API
This issue involves adding, removing, clarification, or modification of an API.
Feature Request
Performance-Scenario-Diagnostics
This issue affects diagnostics computation performance for lightbulb, background analysis, tagger.
Milestone
#67257 added
FilterSpan
public API toSyntaxTreeAnalysisContext
andSemanticModelAnalysisContext
. These APIs were implemented with #67818 and our IDE code style analyzers moved over to the new API with #68014.The performance measurements from both these PRs (added to the PR descriptions) showed quite good performance improvements in lightbulb code path from these changes. Hence, we would like to add similar
FilterSpan
API to other context types, and also aFilterTree
API to context types where it is relevant.Proposal
Add
FilterSpan
API to the following contexts:roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 704 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 782 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 920 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 1013 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 1106 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 1229 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 1485 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 1580 in 193c659
Add
FilterTree
API to the following contexts:roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 704 in 193c659
roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 782 in 193c659
Note that rest of the contexts are only scoped to a specific syntax tree and there is already some property chain to get to this tree from the context object. For example,
OperationTreeAnalysisContext.Operation.Syntax.SyntaxTree
,SyntaxNodeAnalysisContext.Node.SyntaxTree
, etc. Exposing aFilterTree
property on them would seem to unnecessarily pollute the API surface and make it confusing for the analyzer authors that they ought to be doing something with it. I'd vote for not exposingFilterTree
property on rest of the context types, but I am fine if the API review decides otherwise for consistency purposes.Open question: Should we add
FilterSpan
API toAdditionalFileAnalysisContext
?roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
Line 1425 in 193c659
If yes, then this would require us to add public API overloads to below methods that take a
TextSpan? filterSpan
parameter (similar to existing APIs to fetch single file syntax and semantic diagnostics):roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs
Lines 427 to 455 in 0368609
Proposed API overloads to add
Note that we have already added Roslyn support for code fixes and refactorings in additional files with Add support for code refactorings and code fixes in non-source files #64364, so we can consume this new API on the Roslyn side and thread in filter span for lightbulb code path.
Performance measurements
SymbolStartAnalysisContext
andSymbolAnalysisContext
+ update the IDE code style SymbolStart analyzers to respect the filter tree and span.The text was updated successfully, but these errors were encountered: