Skip to content

Commit 3dd1c3a

Browse files
Remove 'include compiler diagnostics' flag from diagnostics service (#77090)
2 parents ff7628d + 9e4d715 commit 3dd1c3a

File tree

7 files changed

+8
-22
lines changed

7 files changed

+8
-22
lines changed

src/Features/Core/Portable/Diagnostics/IDiagnosticAnalyzerService.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using System.Collections.Generic;
76
using System.Collections.Immutable;
87
using System.Threading;
98
using System.Threading.Tasks;
109
using Microsoft.CodeAnalysis.CodeActions;
11-
using Microsoft.CodeAnalysis.Options;
1210
using Microsoft.CodeAnalysis.Text;
1311

1412
namespace Microsoft.CodeAnalysis.Diagnostics;
@@ -103,7 +101,6 @@ Task<ImmutableArray<DiagnosticData>> GetCachedDiagnosticsAsync(
103101
/// </summary>
104102
Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
105103
TextDocument document, TextSpan? range, Func<string, bool>? shouldIncludeDiagnostic,
106-
bool includeCompilerDiagnostics,
107104
ICodeActionRequestPriorityProvider priorityProvider,
108105
DiagnosticKind diagnosticKind,
109106
bool isExplicit,
@@ -144,7 +141,6 @@ public static Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(th
144141
{
145142
Func<string, bool>? shouldIncludeDiagnostic = diagnosticId != null ? id => id == diagnosticId : null;
146143
return service.GetDiagnosticsForSpanAsync(document, range, shouldIncludeDiagnostic,
147-
includeCompilerDiagnostics: true, priorityProvider,
148-
diagnosticKind, isExplicit, cancellationToken);
144+
priorityProvider, diagnosticKind, isExplicit, cancellationToken);
149145
}
150146
}

src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ private async Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(
202202
// Compute diagnostics for everything that is not an IDE analyzer
203203
var diagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(document, range,
204204
shouldIncludeDiagnostic: static diagnosticId => !(IDEDiagnosticIdToOptionMappingHelper.IsKnownIDEDiagnosticId(diagnosticId)),
205-
includeCompilerDiagnostics: true,
206205
priorityProvider: new DefaultCodeActionRequestPriorityProvider(),
207206
DiagnosticKind.All, isExplicit: false,
208207
cancellationToken).ConfigureAwait(false);

src/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.FixAllDiagnosticProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override async Task<IEnumerable<Diagnostic>> GetDocumentSpanDiagnosticsAs
5757
{
5858
bool shouldIncludeDiagnostic(string id) => _diagnosticIds == null || _diagnosticIds.Contains(id);
5959
var diagnostics = Filter(await _diagnosticService.GetDiagnosticsForSpanAsync(
60-
document, fixAllSpan, shouldIncludeDiagnostic, includeCompilerDiagnostics: true,
60+
document, fixAllSpan, shouldIncludeDiagnostic,
6161
priorityProvider: new DefaultCodeActionRequestPriorityProvider(),
6262
DiagnosticKind.All, isExplicit: false, cancellationToken).ConfigureAwait(false));
6363
Contract.ThrowIfFalse(diagnostics.All(d => d.DocumentId != null));

src/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public CodeFixService(
109109
{
110110
allDiagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(
111111
document, range, GetShouldIncludeDiagnosticPredicate(document, priorityProvider),
112-
includeCompilerDiagnostics: true, priorityProvider, DiagnosticKind.All, isExplicit: false, cancellationToken).ConfigureAwait(false);
112+
priorityProvider, DiagnosticKind.All, isExplicit: false, cancellationToken).ConfigureAwait(false);
113113

114114
// NOTE(cyrusn): We do not include suppressed diagnostics here as they are effectively hidden from the
115115
// user in the editor. As far as the user is concerned, there is no squiggle for it and no lightbulb
@@ -199,7 +199,7 @@ public async IAsyncEnumerable<CodeFixCollection> StreamFixesAsync(
199199
{
200200
diagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(
201201
document, range, GetShouldIncludeDiagnosticPredicate(document, priorityProvider),
202-
includeCompilerDiagnostics: true, priorityProvider, DiagnosticKind.All, isExplicit: true, cancellationToken).ConfigureAwait(false);
202+
priorityProvider, DiagnosticKind.All, isExplicit: true, cancellationToken).ConfigureAwait(false);
203203
if (!includeSuppressionFixes)
204204
diagnostics = diagnostics.WhereAsArray(d => !d.IsSuppressed);
205205
}

src/LanguageServer/Protocol/Features/Diagnostics/DiagnosticAnalyzerService.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
7676
TextDocument document,
7777
TextSpan? range,
7878
Func<string, bool>? shouldIncludeDiagnostic,
79-
bool includeCompilerDiagnostics,
8079
ICodeActionRequestPriorityProvider priorityProvider,
8180
DiagnosticKind diagnosticKinds,
8281
bool isExplicit,
@@ -89,8 +88,7 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
8988
priorityProvider ??= new DefaultCodeActionRequestPriorityProvider();
9089

9190
return await analyzer.GetDiagnosticsForSpanAsync(
92-
document, range, shouldIncludeDiagnostic, includeCompilerDiagnostics,
93-
priorityProvider, diagnosticKinds, isExplicit, cancellationToken).ConfigureAwait(false);
91+
document, range, shouldIncludeDiagnostic, priorityProvider, diagnosticKinds, isExplicit, cancellationToken).ConfigureAwait(false);
9492
}
9593

9694
public Task<ImmutableArray<DiagnosticData>> GetCachedDiagnosticsAsync(

src/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
2626
TextDocument document,
2727
TextSpan? range,
2828
Func<string, bool>? shouldIncludeDiagnostic,
29-
bool includeCompilerDiagnostics,
3029
ICodeActionRequestPriorityProvider priorityProvider,
3130
DiagnosticKind diagnosticKinds,
3231
bool isExplicit,
@@ -35,8 +34,7 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
3534
using var _ = ArrayBuilder<DiagnosticData>.GetInstance(out var list);
3635

3736
var getter = await LatestDiagnosticsForSpanGetter.CreateAsync(
38-
this, document, range, includeCompilerDiagnostics,
39-
priorityProvider, shouldIncludeDiagnostic, diagnosticKinds, isExplicit, cancellationToken).ConfigureAwait(false);
37+
this, document, range, priorityProvider, shouldIncludeDiagnostic, diagnosticKinds, isExplicit, cancellationToken).ConfigureAwait(false);
4038
await getter.GetAsync(list, cancellationToken).ConfigureAwait(false);
4139

4240
return list.ToImmutableAndClear();
@@ -62,7 +60,6 @@ private sealed class LatestDiagnosticsForSpanGetter
6260
private readonly TextSpan? _range;
6361
private readonly ICodeActionRequestPriorityProvider _priorityProvider;
6462
private readonly Func<string, bool>? _shouldIncludeDiagnostic;
65-
private readonly bool _includeCompilerDiagnostics;
6663
private readonly bool _isExplicit;
6764
private readonly bool _logPerformanceInfo;
6865
private readonly bool _incrementalAnalysis;
@@ -72,7 +69,6 @@ public static async Task<LatestDiagnosticsForSpanGetter> CreateAsync(
7269
DiagnosticIncrementalAnalyzer owner,
7370
TextDocument document,
7471
TextSpan? range,
75-
bool includeCompilerDiagnostics,
7672
ICodeActionRequestPriorityProvider priorityProvider,
7773
Func<string, bool>? shouldIncludeDiagnostic,
7874
DiagnosticKind diagnosticKinds,
@@ -102,7 +98,7 @@ public static async Task<LatestDiagnosticsForSpanGetter> CreateAsync(
10298
&& document is Document { SupportsSyntaxTree: true };
10399

104100
return new LatestDiagnosticsForSpanGetter(
105-
owner, compilationWithAnalyzers, document, text, stateSets, shouldIncludeDiagnostic, includeCompilerDiagnostics,
101+
owner, compilationWithAnalyzers, document, text, stateSets, shouldIncludeDiagnostic,
106102
range, priorityProvider, isExplicit, logPerformanceInfo, incrementalAnalysis, diagnosticKinds);
107103
}
108104

@@ -151,7 +147,6 @@ private LatestDiagnosticsForSpanGetter(
151147
SourceText text,
152148
ImmutableArray<StateSet> stateSets,
153149
Func<string, bool>? shouldIncludeDiagnostic,
154-
bool includeCompilerDiagnostics,
155150
TextSpan? range,
156151
ICodeActionRequestPriorityProvider priorityProvider,
157152
bool isExplicit,
@@ -165,7 +160,6 @@ private LatestDiagnosticsForSpanGetter(
165160
_text = text;
166161
_stateSets = stateSets;
167162
_shouldIncludeDiagnostic = shouldIncludeDiagnostic;
168-
_includeCompilerDiagnostics = includeCompilerDiagnostics;
169163
_range = range;
170164
_priorityProvider = priorityProvider;
171165
_isExplicit = isExplicit;
@@ -462,7 +456,6 @@ private bool ShouldInclude(DiagnosticData diagnostic)
462456
{
463457
return diagnostic.DocumentId == _document.Id &&
464458
(_range == null || _range.Value.IntersectsWith(diagnostic.DataLocation.UnmappedFileSpan.GetClampedTextSpan(_text)))
465-
&& (_includeCompilerDiagnostics || !diagnostic.CustomTags.Any(static t => t is WellKnownDiagnosticTags.Compiler))
466459
&& (_shouldIncludeDiagnostic == null || _shouldIncludeDiagnostic(diagnostic.Id));
467460
}
468461
}

src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
313313
Public Sub RequestDiagnosticRefresh() Implements IDiagnosticAnalyzerService.RequestDiagnosticRefresh
314314
End Sub
315315

316-
Public Function GetDiagnosticsForSpanAsync(document As TextDocument, range As TextSpan?, shouldIncludeDiagnostic As Func(Of String, Boolean), includeCompilerDiagnostics As Boolean, priority As ICodeActionRequestPriorityProvider, diagnosticKinds As DiagnosticKind, isExplicit As Boolean, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of DiagnosticData)) Implements IDiagnosticAnalyzerService.GetDiagnosticsForSpanAsync
316+
Public Function GetDiagnosticsForSpanAsync(document As TextDocument, range As TextSpan?, shouldIncludeDiagnostic As Func(Of String, Boolean), priority As ICodeActionRequestPriorityProvider, diagnosticKinds As DiagnosticKind, isExplicit As Boolean, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of DiagnosticData)) Implements IDiagnosticAnalyzerService.GetDiagnosticsForSpanAsync
317317
Return SpecializedTasks.EmptyImmutableArray(Of DiagnosticData)
318318
End Function
319319

0 commit comments

Comments
 (0)