File tree 1 file changed +25
-16
lines changed
1 file changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -19,22 +19,22 @@ export type DiagnosticsResultCodeActionsMap = Map<
19
19
{ range : Range ; codeAction : CodeAction } [ ]
20
20
> ;
21
21
22
+ export type DiagnosticsResultFormat = Array < {
23
+ name : string ;
24
+ kind : string ;
25
+ file : string ;
26
+ range : [ number , number , number , number ] ;
27
+ message : string ;
28
+ annotate ?: {
29
+ line : number ;
30
+ character : number ;
31
+ text : string ;
32
+ action : string ;
33
+ } ;
34
+ } > ;
35
+
22
36
let resultsToDiagnostics = (
23
- results : [
24
- {
25
- name : string ;
26
- kind : string ;
27
- file : string ;
28
- range : [ number , number , number , number ] ;
29
- message : string ;
30
- annotate ?: {
31
- line : number ;
32
- character : number ;
33
- text : string ;
34
- action : string ;
35
- } ;
36
- }
37
- ] ,
37
+ results : DiagnosticsResultFormat ,
38
38
diagnosticsResultCodeActions : DiagnosticsResultCodeActionsMap
39
39
) : {
40
40
diagnosticsMap : Map < string , Diagnostic [ ] > ;
@@ -202,13 +202,22 @@ export const runCodeAnalysisWithReanalyze = (
202
202
p . on ( "close" , ( ) => {
203
203
diagnosticsResultCodeActions . clear ( ) ;
204
204
205
+ let json : DiagnosticsResultFormat | null = null ;
206
+
205
207
try {
206
- var json = JSON . parse ( data ) ;
208
+ json = JSON . parse ( data ) ;
207
209
} catch ( e ) {
208
210
window . showErrorMessage (
209
211
`Something went wrong parsing the json output of reanalyze: '${ e } '`
210
212
) ;
211
213
}
214
+
215
+ if ( json == null ) {
216
+ // If reanalyze failed for some reason we'll clear the diagnostics.
217
+ diagnosticsCollection . clear ( ) ;
218
+ return ;
219
+ }
220
+
212
221
let { diagnosticsMap } = resultsToDiagnostics (
213
222
json ,
214
223
diagnosticsResultCodeActions
You can’t perform that action at this time.
0 commit comments