@@ -18,33 +18,35 @@ internal partial class DiagnosticAnalyzerService
18
18
private partial class DiagnosticIncrementalAnalyzer
19
19
{
20
20
public Task < ImmutableArray < DiagnosticData > > GetDiagnosticsForIdsAsync ( Solution solution , ProjectId projectId , DocumentId ? documentId , ImmutableHashSet < string > ? diagnosticIds , Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer , bool includeLocalDocumentDiagnostics , bool includeNonLocalDocumentDiagnostics , CancellationToken cancellationToken )
21
- => new IdeLatestDiagnosticGetter ( this , solution , projectId , documentId , diagnosticIds , shouldIncludeAnalyzer , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics ) . GetDiagnosticsAsync ( cancellationToken ) ;
21
+ => new DiagnosticGetter ( this , solution , projectId , documentId , diagnosticIds , shouldIncludeAnalyzer , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics ) . GetDiagnosticsAsync ( cancellationToken ) ;
22
22
23
23
public Task < ImmutableArray < DiagnosticData > > GetProjectDiagnosticsForIdsAsync ( Solution solution , ProjectId projectId , ImmutableHashSet < string > ? diagnosticIds , Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer , bool includeNonLocalDocumentDiagnostics , CancellationToken cancellationToken )
24
- => new IdeLatestDiagnosticGetter ( this , solution , projectId , documentId : null , diagnosticIds , shouldIncludeAnalyzer , includeLocalDocumentDiagnostics : false , includeNonLocalDocumentDiagnostics ) . GetProjectDiagnosticsAsync ( cancellationToken ) ;
24
+ => new DiagnosticGetter ( this , solution , projectId , documentId : null , diagnosticIds , shouldIncludeAnalyzer , includeLocalDocumentDiagnostics : false , includeNonLocalDocumentDiagnostics ) . GetProjectDiagnosticsAsync ( cancellationToken ) ;
25
25
26
- private abstract class DiagnosticGetter (
26
+ private sealed class DiagnosticGetter (
27
27
DiagnosticIncrementalAnalyzer owner ,
28
28
Solution solution ,
29
29
ProjectId projectId ,
30
30
DocumentId ? documentId ,
31
+ ImmutableHashSet < string > ? diagnosticIds ,
32
+ Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer ,
31
33
bool includeLocalDocumentDiagnostics ,
32
34
bool includeNonLocalDocumentDiagnostics )
33
35
{
34
- protected readonly DiagnosticIncrementalAnalyzer Owner = owner ;
35
-
36
- protected readonly Solution Solution = solution ;
37
- protected readonly ProjectId ProjectId = projectId ;
38
- protected readonly DocumentId ? DocumentId = documentId ;
39
- protected readonly bool IncludeLocalDocumentDiagnostics = includeLocalDocumentDiagnostics ;
40
- protected readonly bool IncludeNonLocalDocumentDiagnostics = includeNonLocalDocumentDiagnostics ;
36
+ private readonly DiagnosticIncrementalAnalyzer Owner = owner ;
41
37
42
- protected StateManager StateManager => Owner . _stateManager ;
38
+ private readonly Solution Solution = solution ;
39
+ private readonly ProjectId ProjectId = projectId ;
40
+ private readonly DocumentId ? DocumentId = documentId ;
41
+ private readonly ImmutableHashSet < string > ? _diagnosticIds = diagnosticIds ;
42
+ private readonly Func < DiagnosticAnalyzer , bool > ? _shouldIncludeAnalyzer = shouldIncludeAnalyzer ;
43
+ private readonly bool IncludeLocalDocumentDiagnostics = includeLocalDocumentDiagnostics ;
44
+ private readonly bool IncludeNonLocalDocumentDiagnostics = includeNonLocalDocumentDiagnostics ;
43
45
44
- protected virtual bool ShouldIncludeDiagnostic ( DiagnosticData diagnostic ) => true ;
46
+ private StateManager StateManager => Owner . _stateManager ;
45
47
46
- protected abstract Task ProduceDiagnosticsAsync (
47
- Project project , IReadOnlyList < DocumentId > documentIds , bool includeProjectNonLocalResult , ArrayBuilder < DiagnosticData > builder , CancellationToken cancellationToken ) ;
48
+ private bool ShouldIncludeDiagnostic ( DiagnosticData diagnostic )
49
+ => _diagnosticIds == null || _diagnosticIds . Contains ( diagnostic . Id ) ;
48
50
49
51
public async Task < ImmutableArray < DiagnosticData > > GetDiagnosticsAsync ( CancellationToken cancellationToken )
50
52
{
@@ -62,7 +64,7 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsAsync(Cancellati
62
64
includeProjectNonLocalResult , cancellationToken ) . ConfigureAwait ( false ) ;
63
65
}
64
66
65
- protected async Task < ImmutableArray < DiagnosticData > > ProduceProjectDiagnosticsAsync (
67
+ private async Task < ImmutableArray < DiagnosticData > > ProduceProjectDiagnosticsAsync (
66
68
Project project , IReadOnlyList < DocumentId > documentIds ,
67
69
bool includeProjectNonLocalResult , CancellationToken cancellationToken )
68
70
{
@@ -72,30 +74,14 @@ await this.ProduceDiagnosticsAsync(
72
74
return builder . ToImmutableAndClear ( ) ;
73
75
}
74
76
75
- protected void AddIncludedDiagnostics ( ArrayBuilder < DiagnosticData > builder , ImmutableArray < DiagnosticData > diagnostics )
77
+ private void AddIncludedDiagnostics ( ArrayBuilder < DiagnosticData > builder , ImmutableArray < DiagnosticData > diagnostics )
76
78
{
77
79
foreach ( var diagnostic in diagnostics )
78
80
{
79
81
if ( ShouldIncludeDiagnostic ( diagnostic ) )
80
82
builder . Add ( diagnostic ) ;
81
83
}
82
84
}
83
- }
84
-
85
- private sealed class IdeLatestDiagnosticGetter (
86
- DiagnosticIncrementalAnalyzer owner ,
87
- Solution solution ,
88
- ProjectId projectId ,
89
- DocumentId ? documentId ,
90
- ImmutableHashSet < string > ? diagnosticIds ,
91
- Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer ,
92
- bool includeLocalDocumentDiagnostics ,
93
- bool includeNonLocalDocumentDiagnostics )
94
- : DiagnosticGetter (
95
- owner , solution , projectId , documentId , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics )
96
- {
97
- private readonly ImmutableHashSet < string > ? _diagnosticIds = diagnosticIds ;
98
- private readonly Func < DiagnosticAnalyzer , bool > ? _shouldIncludeAnalyzer = shouldIncludeAnalyzer ;
99
85
100
86
public async Task < ImmutableArray < DiagnosticData > > GetProjectDiagnosticsAsync ( CancellationToken cancellationToken )
101
87
{
@@ -107,10 +93,7 @@ public async Task<ImmutableArray<DiagnosticData>> GetProjectDiagnosticsAsync(Can
107
93
project , documentIds : [ ] , includeProjectNonLocalResult : true , cancellationToken ) . ConfigureAwait ( false ) ;
108
94
}
109
95
110
- protected override bool ShouldIncludeDiagnostic ( DiagnosticData diagnostic )
111
- => _diagnosticIds == null || _diagnosticIds . Contains ( diagnostic . Id ) ;
112
-
113
- protected override async Task ProduceDiagnosticsAsync (
96
+ private async Task ProduceDiagnosticsAsync (
114
97
Project project ,
115
98
IReadOnlyList < DocumentId > documentIds ,
116
99
bool includeProjectNonLocalResult ,
0 commit comments