@@ -168,11 +168,12 @@ namespace ts.projectSystem {
168
168
readonly session : TestSession ;
169
169
readonly service : server . ProjectService ;
170
170
readonly host : TestServerHost ;
171
- constructor ( files : FileOrFolder [ ] ) {
171
+ constructor ( files : FileOrFolder [ ] , suppressDiagnosticEvents ?: boolean ) {
172
172
this . host = createServerHost ( files ) ;
173
173
this . session = createSession ( this . host , {
174
174
canUseEvents : true ,
175
175
eventHandler : event => this . events . push ( event ) ,
176
+ suppressDiagnosticEvents,
176
177
} ) ;
177
178
this . service = this . session . getProjectService ( ) ;
178
179
}
@@ -485,6 +486,12 @@ namespace ts.projectSystem {
485
486
checkNthEvent ( session , server . toEvent ( "projectsUpdatedInBackground" , { openFiles } ) , 0 , /*isMostRecent*/ true ) ;
486
487
}
487
488
489
+ function checkNoDiagnosticEvents ( session : TestSession ) {
490
+ for ( const event of session . events ) {
491
+ assert . isFalse ( event . event . endsWith ( "Diag" ) , JSON . stringify ( event ) ) ;
492
+ }
493
+ }
494
+
488
495
function checkNthEvent ( session : TestSession , expectedEvent : protocol . Event , index : number , isMostRecent : boolean ) {
489
496
const events = session . events ;
490
497
assert . deepEqual ( events [ index ] , expectedEvent ) ;
@@ -4074,6 +4081,63 @@ namespace ts.projectSystem {
4074
4081
session . clearMessages ( ) ;
4075
4082
} ) ;
4076
4083
4084
+ it ( "suppressed diagnostic events" , ( ) => {
4085
+ const file : FileOrFolder = {
4086
+ path : "/a.ts" ,
4087
+ content : "1 = 2;" ,
4088
+ } ;
4089
+
4090
+ const host = createServerHost ( [ file ] ) ;
4091
+ const session = createSession ( host , { canUseEvents : true , suppressDiagnosticEvents : true } ) ;
4092
+ const service = session . getProjectService ( ) ;
4093
+
4094
+ session . executeCommandSeq < protocol . OpenRequest > ( {
4095
+ command : server . CommandNames . Open ,
4096
+ arguments : { file : file . path , fileContent : file . content } ,
4097
+ } ) ;
4098
+
4099
+ checkNumberOfProjects ( service , { inferredProjects : 1 } ) ;
4100
+
4101
+ host . checkTimeoutQueueLength ( 0 ) ;
4102
+ checkNoDiagnosticEvents ( session ) ;
4103
+
4104
+ session . clearMessages ( ) ;
4105
+
4106
+ let expectedSequenceId = session . getNextSeq ( ) ;
4107
+
4108
+ session . executeCommandSeq < protocol . GeterrRequest > ( {
4109
+ command : server . CommandNames . Geterr ,
4110
+ arguments : {
4111
+ delay : 0 ,
4112
+ files : [ file . path ] ,
4113
+ }
4114
+ } ) ;
4115
+
4116
+ host . checkTimeoutQueueLength ( 0 ) ;
4117
+ checkNoDiagnosticEvents ( session ) ;
4118
+
4119
+ checkCompleteEvent ( session , 1 , expectedSequenceId ) ;
4120
+
4121
+ session . clearMessages ( ) ;
4122
+
4123
+ expectedSequenceId = session . getNextSeq ( ) ;
4124
+
4125
+ session . executeCommandSeq < protocol . GeterrForProjectRequest > ( {
4126
+ command : server . CommandNames . Geterr ,
4127
+ arguments : {
4128
+ delay : 0 ,
4129
+ file : file . path ,
4130
+ }
4131
+ } ) ;
4132
+
4133
+ host . checkTimeoutQueueLength ( 0 ) ;
4134
+ checkNoDiagnosticEvents ( session ) ;
4135
+
4136
+ checkCompleteEvent ( session , 1 , expectedSequenceId ) ;
4137
+
4138
+ session . clearMessages ( ) ;
4139
+ } ) ;
4140
+
4077
4141
function createDiagnostic ( start : protocol . Location , end : protocol . Location , message : DiagnosticMessage , args : ReadonlyArray < string > = [ ] ) : protocol . Diagnostic {
4078
4142
return { start, end, text : formatStringFromArgs ( message . message , args ) , code : message . code , category : diagnosticCategoryName ( message ) , source : undefined } ;
4079
4143
}
@@ -4149,7 +4213,7 @@ namespace ts.projectSystem {
4149
4213
serverEventManager . checkSingleConfigFileDiagEvent ( configFile . path , configFile . path ) ;
4150
4214
} ) ;
4151
4215
4152
- it ( "are not generated when the config file doesnot include file opened and config file has errors" , ( ) => {
4216
+ it ( "are not generated when the config file does not include file opened and config file has errors" , ( ) => {
4153
4217
const file = {
4154
4218
path : "/a/b/app.ts" ,
4155
4219
content : "let x = 10"
@@ -4173,7 +4237,26 @@ namespace ts.projectSystem {
4173
4237
serverEventManager . hasZeroEvent ( "configFileDiag" ) ;
4174
4238
} ) ;
4175
4239
4176
- it ( "are not generated when the config file doesnot include file opened and doesnt contain any errors" , ( ) => {
4240
+ it ( "are not generated when the config file has errors but suppressDiagnosticEvents is true" , ( ) => {
4241
+ const file = {
4242
+ path : "/a/b/app.ts" ,
4243
+ content : "let x = 10"
4244
+ } ;
4245
+ const configFile = {
4246
+ path : "/a/b/tsconfig.json" ,
4247
+ content : `{
4248
+ "compilerOptions": {
4249
+ "foo": "bar",
4250
+ "allowJS": true
4251
+ }
4252
+ }`
4253
+ } ;
4254
+ const serverEventManager = new TestServerEventManager ( [ file , configFile ] , /*suppressDiagnosticEvents*/ true ) ;
4255
+ openFilesForSession ( [ file ] , serverEventManager . session ) ;
4256
+ serverEventManager . hasZeroEvent ( "configFileDiag" ) ;
4257
+ } ) ;
4258
+
4259
+ it ( "are not generated when the config file does not include file opened and doesnt contain any errors" , ( ) => {
4177
4260
const file = {
4178
4261
path : "/a/b/app.ts" ,
4179
4262
content : "let x = 10"
0 commit comments