@@ -466,43 +466,29 @@ namespace ts.server {
466466 }
467467
468468 private semanticCheck ( file : NormalizedPath , project : Project ) {
469- try {
470- const diags = isDeclarationFileInJSOnlyNonConfiguredProject ( project , file )
471- ? emptyArray
472- : project . getLanguageService ( ) . getSemanticDiagnostics ( file ) ;
473- this . sendDiagnosticsEvent ( file , project , diags , "semanticDiag" ) ;
474- }
475- catch ( err ) {
476- this . logError ( err , "semantic check" ) ;
477- }
469+ const diags = isDeclarationFileInJSOnlyNonConfiguredProject ( project , file )
470+ ? emptyArray
471+ : project . getLanguageService ( ) . getSemanticDiagnostics ( file ) ;
472+ this . sendDiagnosticsEvent ( file , project , diags , "semanticDiag" ) ;
478473 }
479474
480475 private syntacticCheck ( file : NormalizedPath , project : Project ) {
481- try {
482- // TODO: why do we check for diagnostics existence here, but in semanticCheck send unconditionally?
483- const diagnostics = project . getLanguageService ( ) . getSyntacticDiagnostics ( file ) ;
484- if ( diagnostics ) {
485- this . sendDiagnosticsEvent ( file , project , diagnostics , "syntaxDiag" ) ;
486- }
487- }
488- catch ( err ) {
489- this . logError ( err , "syntactic check" ) ;
490- }
476+ this . sendDiagnosticsEvent ( file , project , project . getLanguageService ( ) . getSyntacticDiagnostics ( file ) , "syntaxDiag" ) ;
491477 }
492478
493479 private infoCheck ( file : NormalizedPath , project : Project ) {
480+ this . sendDiagnosticsEvent ( file , project , project . getLanguageService ( ) . getSuggestionDiagnostics ( file ) , "suggestionDiag" ) ;
481+ }
482+
483+ private sendDiagnosticsEvent ( file : NormalizedPath , project : Project , diagnostics : ReadonlyArray < Diagnostic > , kind : protocol . DiagnosticEventKind ) : void {
494484 try {
495- this . sendDiagnosticsEvent ( file , project , project . getLanguageService ( ) . getInfoDiagnostics ( file ) , "infoDiag" ) ;
485+ this . event < protocol . DiagnosticEventBody > ( { file, diagnostics : diagnostics . map ( diag => formatDiag ( file , project , diag ) ) } , kind ) ;
496486 }
497487 catch ( err ) {
498- this . logError ( err , "info check" ) ;
488+ this . logError ( err , kind ) ;
499489 }
500490 }
501491
502- private sendDiagnosticsEvent ( file : NormalizedPath , project : Project , diagnostics : ReadonlyArray < Diagnostic > , kind : protocol . DiagnosticEventKind ) : void {
503- this . event < protocol . DiagnosticEventBody > ( { file, diagnostics : diagnostics . map ( diag => formatDiag ( file , project , diag ) ) } , kind ) ;
504- }
505-
506492 private updateErrorCheck ( next : NextStep , checkList : PendingErrorCheck [ ] , ms : number , requireOpen = true ) {
507493 const seq = this . changeSeq ;
508494 const followMs = Math . min ( ms , 200 ) ;
@@ -779,14 +765,14 @@ namespace ts.server {
779765 return this . getDiagnosticsWorker ( args , /*isSemantic*/ true , ( project , file ) => project . getLanguageService ( ) . getSemanticDiagnostics ( file ) , args . includeLinePosition ) ;
780766 }
781767
782- private getInfoDiagnosticsSync ( args : protocol . InfoDiagnosticsSyncRequestArgs ) : ReadonlyArray < protocol . Diagnostic > | ReadonlyArray < protocol . DiagnosticWithLinePosition > {
768+ private getSuggestionDiagnosticsSync ( args : protocol . SuggestionDiagnosticsSyncRequestArgs ) : ReadonlyArray < protocol . Diagnostic > | ReadonlyArray < protocol . DiagnosticWithLinePosition > {
783769 const { configFile } = this . getConfigFileAndProject ( args ) ;
784770 if ( configFile ) {
785771 // Currently there are no info diagnostics for config files.
786772 return emptyArray ;
787773 }
788774 // isSemantic because we don't want to info diagnostics in declaration files for JS-only users
789- return this . getDiagnosticsWorker ( args , /*isSemantic*/ true , ( project , file ) => project . getLanguageService ( ) . getInfoDiagnostics ( file ) , args . includeLinePosition ) ;
775+ return this . getDiagnosticsWorker ( args , /*isSemantic*/ true , ( project , file ) => project . getLanguageService ( ) . getSuggestionDiagnostics ( file ) , args . includeLinePosition ) ;
790776 }
791777
792778 private getDocumentHighlights ( args : protocol . DocumentHighlightsRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . DocumentHighlightsItem > | ReadonlyArray < DocumentHighlights > {
@@ -1986,8 +1972,8 @@ namespace ts.server {
19861972 [ CommandNames . SyntacticDiagnosticsSync ] : ( request : protocol . SyntacticDiagnosticsSyncRequest ) => {
19871973 return this . requiredResponse ( this . getSyntacticDiagnosticsSync ( request . arguments ) ) ;
19881974 } ,
1989- [ CommandNames . InfoDiagnosticsSync ] : ( request : protocol . InfoDiagnosticsSyncRequest ) => {
1990- return this . requiredResponse ( this . getInfoDiagnosticsSync ( request . arguments ) ) ;
1975+ [ CommandNames . SuggestionDiagnosticsSync ] : ( request : protocol . SuggestionDiagnosticsSyncRequest ) => {
1976+ return this . requiredResponse ( this . getSuggestionDiagnosticsSync ( request . arguments ) ) ;
19911977 } ,
19921978 [ CommandNames . Geterr ] : ( request : protocol . GeterrRequest ) => {
19931979 this . errorCheck . startNew ( next => this . getDiagnostics ( next , request . arguments . delay , request . arguments . files ) ) ;
0 commit comments