25
25
namespace Microsoft . AspNetCore . Razor . LanguageServer . Diagnostics ;
26
26
27
27
[ RazorLanguageServerEndpoint ( VSInternalMethods . DocumentPullDiagnosticName ) ]
28
- internal class DocumentPullDiagnosticsEndpoint : IRazorRequestHandler < VSInternalDocumentDiagnosticsParams , IEnumerable < VSInternalDiagnosticReport > ? > , ICapabilitiesProvider
28
+ internal class DocumentPullDiagnosticsEndpoint (
29
+ LanguageServerFeatureOptions languageServerFeatureOptions ,
30
+ RazorTranslateDiagnosticsService translateDiagnosticsService ,
31
+ RazorLSPOptionsMonitor razorLSPOptionsMonitor ,
32
+ IClientConnection clientConnection ,
33
+ ITelemetryReporter ? telemetryReporter ) : IRazorRequestHandler < VSInternalDocumentDiagnosticsParams , IEnumerable < VSInternalDiagnosticReport > ? > , ICapabilitiesProvider
29
34
{
30
- private readonly LanguageServerFeatureOptions _languageServerFeatureOptions ;
31
- private readonly IClientConnection _clientConnection ;
32
- private readonly RazorTranslateDiagnosticsService _translateDiagnosticsService ;
33
- private readonly ITelemetryReporter ? _telemetryReporter ;
35
+ private readonly LanguageServerFeatureOptions _languageServerFeatureOptions = languageServerFeatureOptions ;
36
+ private readonly IClientConnection _clientConnection = clientConnection ;
37
+ private readonly RazorTranslateDiagnosticsService _translateDiagnosticsService = translateDiagnosticsService ;
38
+ private readonly RazorLSPOptionsMonitor _razorLSPOptionsMonitor = razorLSPOptionsMonitor ;
39
+ private readonly ITelemetryReporter ? _telemetryReporter = telemetryReporter ;
34
40
private ImmutableDictionary < ProjectKey , int > _lastReportedProjectTagHelperCount = ImmutableDictionary < ProjectKey , int > . Empty ;
35
41
36
- public DocumentPullDiagnosticsEndpoint (
37
- LanguageServerFeatureOptions languageServerFeatureOptions ,
38
- RazorTranslateDiagnosticsService translateDiagnosticsService ,
39
- IClientConnection clientConnection ,
40
- ITelemetryReporter ? telemetryReporter )
41
- {
42
- _languageServerFeatureOptions = languageServerFeatureOptions ?? throw new ArgumentNullException ( nameof ( languageServerFeatureOptions ) ) ;
43
- _translateDiagnosticsService = translateDiagnosticsService ?? throw new ArgumentNullException ( nameof ( translateDiagnosticsService ) ) ;
44
- _clientConnection = clientConnection ?? throw new ArgumentNullException ( nameof ( clientConnection ) ) ;
45
- _telemetryReporter = telemetryReporter ;
46
- }
47
-
48
42
public bool MutatesSolutionState => false ;
49
43
50
44
public void ApplyCapabilities ( VSInternalServerCapabilities serverCapabilities , VSInternalClientCapabilities clientCapabilities )
51
45
{
52
46
serverCapabilities . SupportsDiagnosticRequests = true ;
53
47
serverCapabilities . DiagnosticProvider ??= new ( ) ;
54
- serverCapabilities . DiagnosticProvider . DiagnosticKinds = [ VSInternalDiagnosticKind . Syntax ] ;
48
+ serverCapabilities . DiagnosticProvider . DiagnosticKinds = [ VSInternalDiagnosticKind . Syntax , VSInternalDiagnosticKind . Task ] ;
55
49
}
56
50
57
51
public TextDocumentIdentifier GetTextDocumentIdentifier ( VSInternalDocumentDiagnosticsParams request )
@@ -71,16 +65,31 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalDocumentDiagno
71
65
return default ;
72
66
}
73
67
74
- var correlationId = Guid . NewGuid ( ) ;
75
- using var __ = _telemetryReporter ? . TrackLspRequest ( VSInternalMethods . DocumentPullDiagnosticName , LanguageServerConstants . RazorLanguageServerName , TelemetryThresholds . DiagnosticsRazorTelemetryThreshold , correlationId ) ;
76
68
var documentContext = context . DocumentContext ;
77
69
if ( documentContext is null )
78
70
{
79
71
return null ;
80
72
}
81
73
82
- var documentSnapshot = documentContext . Snapshot ;
74
+ // This endpoint is called for regular diagnostics, and Task List items, and they're handled separately.
75
+ if ( request . QueryingDiagnosticKind ? . Value == VSInternalDiagnosticKind . Task . Value )
76
+ {
77
+ var codeDocument = await documentContext . GetCodeDocumentAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
78
+ var diagnostics = TaskListDiagnosticProvider . GetTaskListDiagnostics ( codeDocument , _razorLSPOptionsMonitor . CurrentValue . TaskListDescriptors ) ;
79
+ return
80
+ [
81
+ new ( )
82
+ {
83
+ Diagnostics = [ .. diagnostics ] ,
84
+ ResultId = Guid . NewGuid ( ) . ToString ( )
85
+ }
86
+ ] ;
87
+ }
83
88
89
+ var correlationId = Guid . NewGuid ( ) ;
90
+ using var __ = _telemetryReporter ? . TrackLspRequest ( VSInternalMethods . DocumentPullDiagnosticName , LanguageServerConstants . RazorLanguageServerName , TelemetryThresholds . DiagnosticsRazorTelemetryThreshold , correlationId ) ;
91
+
92
+ var documentSnapshot = documentContext . Snapshot ;
84
93
var razorDiagnostics = await GetRazorDiagnosticsAsync ( documentSnapshot , cancellationToken ) . ConfigureAwait ( false ) ;
85
94
86
95
await ReportRZ10012TelemetryAsync ( documentContext , razorDiagnostics , cancellationToken ) . ConfigureAwait ( false ) ;
0 commit comments