-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Do not report unchanged files in workspace-pull diagnostics #72529
Changes from 3 commits
35abb42
ac8e437
3704535
ad9182d
f057dc9
b77e470
616fc28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,17 @@ | |
|
||
namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics | ||
{ | ||
internal abstract class AbstractDocumentPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn> | ||
: AbstractPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn>, ITextDocumentIdentifierHandler<TDiagnosticsParams, TextDocumentIdentifier?> | ||
internal abstract class AbstractDocumentPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn>( | ||
IDiagnosticAnalyzerService diagnosticAnalyzerService, | ||
IDiagnosticsRefresher diagnosticRefresher, | ||
IGlobalOptionService globalOptions) | ||
: AbstractPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn>( | ||
diagnosticAnalyzerService, | ||
diagnosticRefresher, | ||
globalOptions), ITextDocumentIdentifierHandler<TDiagnosticsParams, TextDocumentIdentifier?> | ||
where TDiagnosticsParams : IPartialResultParams<TReport> | ||
{ | ||
public AbstractDocumentPullDiagnosticHandler( | ||
IDiagnosticAnalyzerService diagnosticAnalyzerService, | ||
IDiagnosticsRefresher diagnosticRefresher, | ||
IGlobalOptionService globalOptions) : base(diagnosticAnalyzerService, diagnosticRefresher, globalOptions) | ||
{ | ||
} | ||
protected sealed override bool IsWorkspacePullDiagnosticsHandler => false; | ||
|
||
public abstract LSP.TextDocumentIdentifier? GetTextDocumentIdentifier(TDiagnosticsParams diagnosticsParams); | ||
} | ||
|
@@ -80,6 +81,8 @@ protected AbstractPullDiagnosticHandler( | |
GlobalOptions = globalOptions; | ||
} | ||
|
||
protected abstract bool IsWorkspacePullDiagnosticsHandler { get; } | ||
|
||
protected virtual string? GetDiagnosticSourceIdentifier(TDiagnosticsParams diagnosticsParams) => null; | ||
|
||
/// <summary> | ||
|
@@ -187,8 +190,14 @@ await ComputeAndReportCurrentDiagnosticsAsync( | |
// Nothing changed between the last request and this one. Report a (null-diagnostics, | ||
// same-result-id) response to the client as that means they should just preserve the current | ||
// diagnostics they have for this file. | ||
var previousParams = documentToPreviousDiagnosticParams[diagnosticSource.GetId()]; | ||
progress.Report(CreateUnchangedReport(previousParams.TextDocument, previousParams.PreviousResultId)); | ||
// | ||
// Note: if this is a workspace request, we can do nothing, as that will be interpreted by the | ||
// client as nothing having been changed for that document. | ||
if (!this.IsWorkspacePullDiagnosticsHandler) | ||
{ | ||
var previousParams = documentToPreviousDiagnosticParams[diagnosticSource.GetId()]; | ||
progress.Report(CreateUnchangedReport(previousParams.TextDocument, previousParams.PreviousResultId)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have the before/after previousParams.TextDocument int versions to compare too? If the version is different, we need to be careful about skipping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not. |
||
} | ||
} | ||
} | ||
|
||
|
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.
Alternative approach - allow CreateUnchangedReport to return a nullable value, and in workspace diagnostics return a null value always.
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.
fair. it seemed about the same... i'll noodle on it.