@@ -295,6 +295,8 @@ namespace ts.server {
295
295
*/
296
296
canUseEvents : boolean ;
297
297
eventHandler ?: ProjectServiceEventHandler ;
298
+ /** Has no effect if eventHandler is also specified. */
299
+ suppressDiagnosticEvents ?: boolean ;
298
300
throttleWaitMilliseconds ?: number ;
299
301
300
302
globalPlugins ?: ReadonlyArray < string > ;
@@ -318,6 +320,7 @@ namespace ts.server {
318
320
protected logger : Logger ;
319
321
320
322
protected canUseEvents : boolean ;
323
+ private suppressDiagnosticEvents ?: boolean ;
321
324
private eventHandler : ProjectServiceEventHandler ;
322
325
323
326
constructor ( opts : SessionOptions ) {
@@ -328,6 +331,7 @@ namespace ts.server {
328
331
this . hrtime = opts . hrtime ;
329
332
this . logger = opts . logger ;
330
333
this . canUseEvents = opts . canUseEvents ;
334
+ this . suppressDiagnosticEvents = opts . suppressDiagnosticEvents ;
331
335
332
336
const { throttleWaitMilliseconds } = opts ;
333
337
@@ -352,6 +356,7 @@ namespace ts.server {
352
356
typingsInstaller : this . typingsInstaller ,
353
357
throttleWaitMilliseconds,
354
358
eventHandler : this . eventHandler ,
359
+ suppressDiagnosticEvents : this . suppressDiagnosticEvents ,
355
360
globalPlugins : opts . globalPlugins ,
356
361
pluginProbeLocations : opts . pluginProbeLocations ,
357
362
allowLocalPluginLoads : opts . allowLocalPluginLoads
@@ -401,11 +406,12 @@ namespace ts.server {
401
406
private projectsUpdatedInBackgroundEvent ( openFiles : string [ ] ) : void {
402
407
this . projectService . logger . info ( `got projects updated in background, updating diagnostics for ${ openFiles } ` ) ;
403
408
if ( openFiles . length ) {
404
- const checkList = this . createCheckList ( openFiles ) ;
405
-
406
- // For now only queue error checking for open files. We can change this to include non open files as well
407
- this . errorCheck . startNew ( next => this . updateErrorCheck ( next , checkList , 100 , /*requireOpen*/ true ) ) ;
409
+ if ( ! this . suppressDiagnosticEvents ) {
410
+ const checkList = this . createCheckList ( openFiles ) ;
408
411
412
+ // For now only queue error checking for open files. We can change this to include non open files as well
413
+ this . errorCheck . startNew ( next => this . updateErrorCheck ( next , checkList , 100 , /*requireOpen*/ true ) ) ;
414
+ }
409
415
410
416
// Send project changed event
411
417
this . event < protocol . ProjectsUpdatedInBackgroundEventBody > ( {
@@ -489,7 +495,10 @@ namespace ts.server {
489
495
}
490
496
}
491
497
498
+ /** It is the caller's responsibility to verify that `!this.suppressDiagnosticEvents`. */
492
499
private updateErrorCheck ( next : NextStep , checkList : PendingErrorCheck [ ] , ms : number , requireOpen = true ) {
500
+ Debug . assert ( ! this . suppressDiagnosticEvents ) ; // Caller's responsibility
501
+
493
502
const seq = this . changeSeq ;
494
503
const followMs = Math . min ( ms , 200 ) ;
495
504
@@ -1379,6 +1388,10 @@ namespace ts.server {
1379
1388
}
1380
1389
1381
1390
private getDiagnostics ( next : NextStep , delay : number , fileNames : string [ ] ) : void {
1391
+ if ( this . suppressDiagnosticEvents ) {
1392
+ return ;
1393
+ }
1394
+
1382
1395
const checkList = this . createCheckList ( fileNames ) ;
1383
1396
if ( checkList . length > 0 ) {
1384
1397
this . updateErrorCheck ( next , checkList , delay ) ;
@@ -1748,6 +1761,10 @@ namespace ts.server {
1748
1761
}
1749
1762
1750
1763
private getDiagnosticsForProject ( next : NextStep , delay : number , fileName : string ) : void {
1764
+ if ( this . suppressDiagnosticEvents ) {
1765
+ return ;
1766
+ }
1767
+
1751
1768
const { fileNames, languageServiceDisabled } = this . getProjectInfoWorker ( fileName , /*projectFileName*/ undefined , /*needFileNameList*/ true , /*excludeConfigFiles*/ true ) ;
1752
1769
if ( languageServiceDisabled ) {
1753
1770
return ;
0 commit comments