File tree Expand file tree Collapse file tree 1 file changed +25
-16
lines changed Expand file tree Collapse file tree 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<
1919 { range : Range ; codeAction : CodeAction } [ ]
2020> ;
2121
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+
2236let 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 ,
3838 diagnosticsResultCodeActions : DiagnosticsResultCodeActionsMap
3939) : {
4040 diagnosticsMap : Map < string , Diagnostic [ ] > ;
@@ -202,13 +202,22 @@ export const runCodeAnalysisWithReanalyze = (
202202 p . on ( "close" , ( ) => {
203203 diagnosticsResultCodeActions . clear ( ) ;
204204
205+ let json : DiagnosticsResultFormat | null = null ;
206+
205207 try {
206- var json = JSON . parse ( data ) ;
208+ json = JSON . parse ( data ) ;
207209 } catch ( e ) {
208210 window . showErrorMessage (
209211 `Something went wrong parsing the json output of reanalyze: '${ e } '`
210212 ) ;
211213 }
214+
215+ if ( json == null ) {
216+ // If reanalyze failed for some reason we'll clear the diagnostics.
217+ diagnosticsCollection . clear ( ) ;
218+ return ;
219+ }
220+
212221 let { diagnosticsMap } = resultsToDiagnostics (
213222 json ,
214223 diagnosticsResultCodeActions
You can’t perform that action at this time.
0 commit comments