Skip to content

Commit 15a2ff3

Browse files
committed
Address feedback
1 parent 35825a0 commit 15a2ff3

File tree

12 files changed

+86
-72
lines changed

12 files changed

+86
-72
lines changed

src/EditorFeatures/Test/Diagnostics/DiagnosticAnalyzerServiceTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ internal async Task TestAdditionalFileAnalyzer(bool registerFromInitialize, bool
668668
switch (analysisScope)
669669
{
670670
case BackgroundAnalysisScope.None:
671-
case BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics:
671+
case BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics:
672672
case BackgroundAnalysisScope.OpenFiles:
673673
workspace.OpenAdditionalDocument(firstAdditionalDocument.Id);
674674
await incrementalAnalyzer.AnalyzeNonSourceDocumentAsync(firstAdditionalDocument, InvocationReasons.SyntaxChanged, CancellationToken.None);
@@ -686,7 +686,7 @@ internal async Task TestAdditionalFileAnalyzer(bool registerFromInitialize, bool
686686

687687
var expectedCount = (analysisScope, testMultiple) switch
688688
{
689-
(BackgroundAnalysisScope.None or BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics, _) => 0,
689+
(BackgroundAnalysisScope.None or BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics, _) => 0,
690690
(BackgroundAnalysisScope.OpenFiles or BackgroundAnalysisScope.FullSolution, false) => 1,
691691
(BackgroundAnalysisScope.OpenFiles, true) => 2,
692692
(BackgroundAnalysisScope.FullSolution, true) => 4,
@@ -704,7 +704,7 @@ internal async Task TestAdditionalFileAnalyzer(bool registerFromInitialize, bool
704704
d => d.Id == analyzer.Descriptor.Id && d.DataLocation.UnmappedFileSpan.Path == additionalDoc.FilePath);
705705

706706
var text = await additionalDoc.GetTextAsync();
707-
if (analysisScope is BackgroundAnalysisScope.None or BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics)
707+
if (analysisScope is BackgroundAnalysisScope.None or BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics)
708708
{
709709
Assert.Empty(applicableDiagnostics);
710710
}
@@ -779,7 +779,7 @@ internal async Task TestDiagnosticSuppressor(bool includeAnalyzer, bool includeS
779779
switch (analysisScope)
780780
{
781781
case BackgroundAnalysisScope.None:
782-
case BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics:
782+
case BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics:
783783
workspace.OpenDocument(document.Id);
784784
var documentTrackingService = (TestDocumentTrackingService)workspace.Services.GetService<IDocumentTrackingService>();
785785
documentTrackingService.SetActiveDocument(document.Id);
@@ -910,7 +910,7 @@ void M()
910910
switch (analysisScope)
911911
{
912912
case BackgroundAnalysisScope.None:
913-
case BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics:
913+
case BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics:
914914
if (isSourceGenerated)
915915
workspace.OpenSourceGeneratedDocument(document.Id);
916916
else

src/EditorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.Executor.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static bool IsAnalyzerEnabledForDocument(
9393
CompilerDiagnosticsScope.None => false,
9494

9595
// Compiler diagnostics are enabled for visible documents and open documents which had errors/warnings in prior snapshot.
96-
CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics => IsVisibleDocumentOrOpenDocumentWithPriorReportedVisibleDiagnostics(isVisibleDocument, isOpenDocument, previousData),
96+
CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics => IsVisibleDocumentOrOpenDocumentWithPriorReportedVisibleDiagnostics(isVisibleDocument, isOpenDocument, previousData),
9797

9898
// Compiler diagnostics are enabled for all open documents.
9999
CompilerDiagnosticsScope.OpenFiles => isOpenDocument,
@@ -112,7 +112,7 @@ static bool IsAnalyzerEnabledForDocument(
112112
BackgroundAnalysisScope.None => false,
113113

114114
// Analyzers are enabled for visible documents and open documents which had errors/warnings in prior snapshot.
115-
BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics => IsVisibleDocumentOrOpenDocumentWithPriorReportedVisibleDiagnostics(isVisibleDocument, isOpenDocument, previousData),
115+
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics => IsVisibleDocumentOrOpenDocumentWithPriorReportedVisibleDiagnostics(isVisibleDocument, isOpenDocument, previousData),
116116

117117
// Analyzers are enabled for all open documents.
118118
BackgroundAnalysisScope.OpenFiles => isOpenDocument,
@@ -129,7 +129,13 @@ static bool IsVisibleDocumentOrOpenDocumentWithPriorReportedVisibleDiagnostics(
129129
bool isVisibleDocument,
130130
bool isOpenDocument,
131131
DocumentAnalysisData previousData)
132-
=> isVisibleDocument || (isOpenDocument && previousData.Items.Any(d => d.Severity is DiagnosticSeverity.Error or DiagnosticSeverity.Warning or DiagnosticSeverity.Info));
132+
{
133+
if (isVisibleDocument)
134+
return true;
135+
136+
return isOpenDocument
137+
&& previousData.Items.Any(static d => d.Severity is DiagnosticSeverity.Error or DiagnosticSeverity.Warning or DiagnosticSeverity.Info);
138+
}
133139
}
134140

135141
/// <summary>

src/Features/LanguageServer/Protocol/Features/Options/SolutionCrawlerOptionsStorage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public static CompilerDiagnosticsScope GetBackgroundCompilerAnalysisScope(this I
7373
{
7474
if (LowMemoryForcedMinimalBackgroundAnalysis)
7575
{
76-
return CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics;
76+
return CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics;
7777
}
7878

7979
return globalOptions.GetOption(SolutionBackgroundAnalysisScopeOption) switch
8080
{
81-
BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics => CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics,
81+
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics => CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics,
8282
BackgroundAnalysisScope.OpenFiles => CompilerDiagnosticsScope.OpenFiles,
8383
BackgroundAnalysisScope.FullSolution => CompilerDiagnosticsScope.FullSolution,
8484
BackgroundAnalysisScope.None => CompilerDiagnosticsScope.None,

src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private protected static InitializationOptions GetInitializationOptions(
324324
compilerDiagnosticsScope ??= analyzerDiagnosticsScope switch
325325
{
326326
BackgroundAnalysisScope.None => CompilerDiagnosticsScope.None,
327-
BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics => CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics,
327+
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics => CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics,
328328
BackgroundAnalysisScope.OpenFiles => CompilerDiagnosticsScope.OpenFiles,
329329
BackgroundAnalysisScope.FullSolution => CompilerDiagnosticsScope.FullSolution,
330330
_ => throw ExceptionUtilities.UnexpectedValue(analyzerDiagnosticsScope),

src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static BackgroundAnalysisScope Option_Background_Analysis_Scope_None_Tag
3131
=> BackgroundAnalysisScope.None;
3232

3333
public static BackgroundAnalysisScope Option_Background_Analysis_Scope_Active_File_Tag
34-
=> BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics;
34+
=> BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics;
3535

3636
public static BackgroundAnalysisScope Option_Background_Analysis_Scope_Open_Files_Tag
3737
=> BackgroundAnalysisScope.OpenFiles;
@@ -58,7 +58,7 @@ public static CompilerDiagnosticsScope Option_Compiler_Diagnostics_Scope_None_Ta
5858
=> CompilerDiagnosticsScope.None;
5959

6060
public static CompilerDiagnosticsScope Option_Compiler_Diagnostics_Scope_Visible_Files_Tag
61-
=> CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics;
61+
=> CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics;
6262

6363
public static CompilerDiagnosticsScope Option_Compiler_Diagnostics_Scope_Open_Files_Tag
6464
=> CompilerDiagnosticsScope.OpenFiles;

src/VisualStudio/Core/Def/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private void OnSetAnalysisScopeDefaultStatus(object sender, EventArgs e)
154154
=> OnSetAnalysisScopeStatus((OleMenuCommand)sender, scope: null);
155155

156156
private void OnSetAnalysisScopeCurrentDocumentStatus(object sender, EventArgs e)
157-
=> OnSetAnalysisScopeStatus((OleMenuCommand)sender, BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics);
157+
=> OnSetAnalysisScopeStatus((OleMenuCommand)sender, BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics);
158158

159159
private void OnSetAnalysisScopeOpenDocumentsStatus(object sender, EventArgs e)
160160
=> OnSetAnalysisScopeStatus((OleMenuCommand)sender, BackgroundAnalysisScope.OpenFiles);
@@ -195,7 +195,7 @@ private void OnSetAnalysisScopeStatus(OleMenuCommand command, BackgroundAnalysis
195195
{
196196
command.Text = GetBackgroundAnalysisScope(_workspace.CurrentSolution, _globalOptions) switch
197197
{
198-
BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics => ServicesVSResources.Default_Current_Document,
198+
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics => ServicesVSResources.Default_Current_Document,
199199
BackgroundAnalysisScope.OpenFiles => ServicesVSResources.Default_Open_Documents,
200200
BackgroundAnalysisScope.FullSolution => ServicesVSResources.Default_Entire_Solution,
201201
BackgroundAnalysisScope.None => ServicesVSResources.Default_None,
@@ -235,7 +235,7 @@ private void OnSetAnalysisScopeDefault(object sender, EventArgs args)
235235
=> OnSetAnalysisScope(scope: null);
236236

237237
private void OnSetAnalysisScopeCurrentDocument(object sender, EventArgs args)
238-
=> OnSetAnalysisScope(BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics);
238+
=> OnSetAnalysisScope(BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics);
239239

240240
private void OnSetAnalysisScopeOpenDocuments(object sender, EventArgs args)
241241
=> OnSetAnalysisScope(BackgroundAnalysisScope.OpenFiles);

src/VisualStudio/IntegrationTest/New.IntegrationTests/CSharp/CSharpCodeActions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ static async Task VerifyDiagnosticInErrorListAsync(string expectedSeverity, Test
918918
}
919919

920920
[IdeTheory, Trait(Traits.Feature, Traits.Features.CodeActionsConfiguration)]
921-
[InlineData(BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics, CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics)]
921+
[InlineData(BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics, CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics)]
922922
[InlineData(BackgroundAnalysisScope.FullSolution, CompilerDiagnosticsScope.FullSolution)]
923923
internal async Task ConfigureSeverityWithManualEditsToEditorconfig_CurrentDocumentScope(BackgroundAnalysisScope analyzerScope, CompilerDiagnosticsScope compilerScope)
924924
{

src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageStrings.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
3838
BackgroundAnalysisScope.None
3939

4040
Public ReadOnly Property Option_Background_Analysis_Scope_Active_File_Tag As BackgroundAnalysisScope =
41-
BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics
41+
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics
4242

4343
Public ReadOnly Property Option_Background_Analysis_Scope_Open_Files_Tag As BackgroundAnalysisScope =
4444
BackgroundAnalysisScope.OpenFiles
@@ -65,7 +65,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
6565
CompilerDiagnosticsScope.None
6666

6767
Public ReadOnly Property Option_Compiler_Diagnostics_Scope_Visible_Files_Tag As CompilerDiagnosticsScope =
68-
CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics
68+
CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics
6969

7070
Public ReadOnly Property Option_Compiler_Diagnostics_Scope_Open_Files_Tag As CompilerDiagnosticsScope =
7171
CompilerDiagnosticsScope.OpenFiles

src/Workspaces/Core/Portable/Shared/Extensions/BackgroundAnalysisScopeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static CompilerDiagnosticsScope ToEquivalentCompilerDiagnosticsScope(this
1313
=> backgroundAnalysisScope switch
1414
{
1515
BackgroundAnalysisScope.None => CompilerDiagnosticsScope.None,
16-
BackgroundAnalysisScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics => CompilerDiagnosticsScope.VisibleFilesAndFilesWithPreviouslyReportedDiagnostics,
16+
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics => CompilerDiagnosticsScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics,
1717
BackgroundAnalysisScope.OpenFiles => CompilerDiagnosticsScope.OpenFiles,
1818
BackgroundAnalysisScope.FullSolution => CompilerDiagnosticsScope.FullSolution,
1919
_ => throw ExceptionUtilities.UnexpectedValue(backgroundAnalysisScope),

0 commit comments

Comments
 (0)