-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove 'open file only' concept from analyzer driver #74340
Conversation
@@ -945,24 +945,6 @@ public override void Initialize(AnalysisContext context) | |||
} | |||
} | |||
|
|||
private class OpenFileOnlyAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never referenced.
@@ -23,9 +23,6 @@ public static bool IsWorkspaceDiagnosticAnalyzer(this DiagnosticAnalyzer analyze | |||
public static bool IsBuiltInAnalyzer(this DiagnosticAnalyzer analyzer) | |||
=> analyzer is IBuiltInAnalyzer || analyzer.IsWorkspaceDiagnosticAnalyzer() || analyzer.IsCompilerAnalyzer(); | |||
|
|||
public static bool IsOpenFileOnly(this DiagnosticAnalyzer analyzer, SimplifierOptions? options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now only returns false. was inlined as appropriate into callsites.
@@ -33,12 +33,8 @@ internal partial class DiagnosticIncrementalAnalyzer | |||
var version = await GetDiagnosticVersionAsync(project, cancellationToken).ConfigureAwait(false); | |||
var existingData = await ProjectAnalysisData.CreateAsync(project, stateSets, avoidLoadingData, cancellationToken).ConfigureAwait(false); | |||
|
|||
// We can't return here if we have open file only analyzers since saved data for open file only analyzer | |||
// is incomplete -- it only contains info on open files rather than whole project. | |||
if (existingData.Version == version && !CompilationHasOpenFileOnlyAnalyzers(compilationWithAnalyzers, ideOptions.SimplifierOptions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method only returns false now. so inlined and updated as appropriate.
@@ -213,8 +191,7 @@ private static bool CompilationHasOpenFileOnlyAnalyzers(CompilationWithAnalyzers | |||
foreach (var analyzer in existingAnalyzers) | |||
{ | |||
if (existing.TryGetValue(analyzer, out var analysisResult) && | |||
analysisResult.Version == version && | |||
!analyzer.IsOpenFileOnly(ideOptions.SimplifierOptions)) | |||
analysisResult.Version == version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inlined and elided.
@@ -195,8 +193,7 @@ public async Task<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync | |||
|
|||
var ideOptions = ((WorkspaceAnalyzerOptions)compilationWithAnalyzers.AnalysisOptions.Options!).IdeOptions; | |||
|
|||
var analyzers = documentAnalysisScope?.Analyzers ?? | |||
compilationWithAnalyzers.Analyzers.Where(a => forceExecuteAllAnalyzers || !a.IsOpenFileOnly(ideOptions.SimplifierOptions)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the right side of the ||
became true
. So this Where
was unnecessary. which made forceExecuteAllAnalyzers
unnecessary. which led to the callsite updates.
@tmat ptal. |
This logic existed at a time when we unilaterally ran all analyzers all the time. This was far too slow for some of these analyzers, and so we had a special back-door to have them opt out of running.
We no longer need this as our move to pull diagnostics (with separate categories for analyzers vs compiler errors), and our user options around how/when analyzers and compiler diagnostics should run supersedes this.