@@ -342,6 +342,41 @@ namespace ts.projectSystem {
342
342
}
343
343
}
344
344
345
+ function patchHostTimeouts ( host : TestFSWithWatch . TestServerHostTrackingWrittenFiles , session : TestSession | TestProjectService ) {
346
+ const originalCheckTimeoutQueueLength = host . checkTimeoutQueueLength ;
347
+ const originalRunQueuedTimeoutCallbacks = host . runQueuedTimeoutCallbacks ;
348
+ const originalRunQueuedImmediateCallbacks = host . runQueuedImmediateCallbacks ;
349
+
350
+ host . checkTimeoutQueueLengthAndRun = checkTimeoutQueueLengthAndRun ;
351
+ host . checkTimeoutQueueLength = checkTimeoutQueueLength ;
352
+ host . runQueuedTimeoutCallbacks = runQueuedTimeoutCallbacks ;
353
+ host . runQueuedImmediateCallbacks = runQueuedImmediateCallbacks ;
354
+
355
+ function checkTimeoutQueueLengthAndRun ( expected : number ) {
356
+ session . baselineHost ( `Before checking timeout queue length (${ expected } ) and running` ) ;
357
+ originalCheckTimeoutQueueLength . call ( host , expected ) ;
358
+ originalRunQueuedTimeoutCallbacks . call ( host ) ;
359
+ session . baselineHost ( `After checking timeout queue length (${ expected } ) and running` ) ;
360
+ }
361
+
362
+ function checkTimeoutQueueLength ( expected : number ) {
363
+ session . baselineHost ( `Checking timeout queue length: ${ expected } ` ) ;
364
+ originalCheckTimeoutQueueLength . call ( host , expected ) ;
365
+ }
366
+
367
+ function runQueuedTimeoutCallbacks ( timeoutId ?: number ) {
368
+ session . baselineHost ( `Before running timeout callback${ timeoutId === undefined ? "s" : timeoutId } ` ) ;
369
+ originalRunQueuedTimeoutCallbacks . call ( host , timeoutId ) ;
370
+ session . baselineHost ( `After running timeout callback${ timeoutId === undefined ? "s" : timeoutId } ` ) ;
371
+ }
372
+
373
+ function runQueuedImmediateCallbacks ( checkCount ?: number ) {
374
+ session . baselineHost ( `Before running immediate callbacks${ checkCount === undefined ? "" : ` and checking length (${ checkCount } )` } ` ) ;
375
+ originalRunQueuedImmediateCallbacks . call ( host , checkCount ) ;
376
+ session . baselineHost ( `Before running immediate callbacks${ checkCount === undefined ? "" : ` and checking length (${ checkCount } )` } ` ) ;
377
+ }
378
+ }
379
+
345
380
export interface TestSessionOptions extends server . SessionOptions {
346
381
logger : Logger ;
347
382
}
@@ -357,6 +392,7 @@ namespace ts.projectSystem {
357
392
super ( opts ) ;
358
393
this . logger = opts . logger ;
359
394
this . testhost = TestFSWithWatch . changeToHostTrackingWrittenFiles ( this . host as TestServerHost ) ;
395
+ patchHostTimeouts ( this . testhost , this ) ;
360
396
}
361
397
362
398
getProjectService ( ) {
@@ -408,29 +444,6 @@ namespace ts.projectSystem {
408
444
this . hostDiff = this . testhost . snap ( ) ;
409
445
this . testhost . writtenFiles . clear ( ) ;
410
446
}
411
-
412
- checkTimeoutQueueLengthAndRun ( expected : number ) {
413
- this . baselineHost ( `Before checking timeout queue length (${ expected } ) and running` ) ;
414
- this . testhost . checkTimeoutQueueLengthAndRun ( expected ) ;
415
- this . baselineHost ( `After checking timeout queue length (${ expected } ) and running` ) ;
416
- }
417
-
418
- checkTimeoutQueueLength ( expected : number ) {
419
- this . baselineHost ( `Checking timeout queue length: ${ expected } ` ) ;
420
- this . testhost . checkTimeoutQueueLength ( expected ) ;
421
- }
422
-
423
- runQueuedTimeoutCallbacks ( timeoutId ?: number ) {
424
- this . baselineHost ( `Before running timeout callback${ timeoutId === undefined ? "s" : timeoutId } ` ) ;
425
- this . testhost . runQueuedTimeoutCallbacks ( timeoutId ) ;
426
- this . baselineHost ( `After running timeout callback${ timeoutId === undefined ? "s" : timeoutId } ` ) ;
427
- }
428
-
429
- runQueuedImmediateCallbacks ( checkCount ?: number ) {
430
- this . baselineHost ( `Before running immediate callbacks${ checkCount === undefined ? "" : ` and checking length (${ checkCount } )` } ` ) ;
431
- this . testhost . runQueuedImmediateCallbacks ( checkCount ) ;
432
- this . baselineHost ( `Before running immediate callbacks${ checkCount === undefined ? "" : ` and checking length (${ checkCount } )` } ` ) ;
433
- }
434
447
}
435
448
436
449
export function createSession ( host : server . ServerHost , opts : Partial < TestSessionOptions > = { } ) {
@@ -513,6 +526,7 @@ namespace ts.projectSystem {
513
526
...opts
514
527
} ) ;
515
528
this . testhost = TestFSWithWatch . changeToHostTrackingWrittenFiles ( this . host as TestServerHost ) ;
529
+ patchHostTimeouts ( this . testhost , this ) ;
516
530
this . baselineHost ( "Creating project service" ) ;
517
531
}
518
532
@@ -528,29 +542,6 @@ namespace ts.projectSystem {
528
542
this . hostDiff = this . testhost . snap ( ) ;
529
543
this . testhost . writtenFiles . clear ( ) ;
530
544
}
531
-
532
- checkTimeoutQueueLengthAndRun ( expected : number ) {
533
- this . baselineHost ( `Before checking timeout queue length (${ expected } ) and running` ) ;
534
- this . testhost . checkTimeoutQueueLengthAndRun ( expected ) ;
535
- this . baselineHost ( `After checking timeout queue length (${ expected } ) and running` ) ;
536
- }
537
-
538
- checkTimeoutQueueLength ( expected : number ) {
539
- this . baselineHost ( `Checking timeout queue length: ${ expected } ` ) ;
540
- this . testhost . checkTimeoutQueueLength ( expected ) ;
541
- }
542
-
543
- runQueuedTimeoutCallbacks ( timeoutId ?: number ) {
544
- this . baselineHost ( `Before running timeout callback${ timeoutId === undefined ? "s" : timeoutId } ` ) ;
545
- this . testhost . runQueuedTimeoutCallbacks ( timeoutId ) ;
546
- this . baselineHost ( `After running timeout callback${ timeoutId === undefined ? "s" : timeoutId } ` ) ;
547
- }
548
-
549
- runQueuedImmediateCallbacks ( checkCount ?: number ) {
550
- this . baselineHost ( `Before running immediate callbacks${ checkCount === undefined ? "" : ` and checking length (${ checkCount } )` } ` ) ;
551
- this . testhost . runQueuedImmediateCallbacks ( checkCount ) ;
552
- this . baselineHost ( `Before running immediate callbacks${ checkCount === undefined ? "" : ` and checking length (${ checkCount } )` } ` ) ;
553
- }
554
545
}
555
546
556
547
export function createProjectService ( host : TestServerHost , options ?: Partial < TestProjectServiceOptions > ) {
@@ -854,14 +845,14 @@ namespace ts.projectSystem {
854
845
Debug . assert ( session . logger . logs . length ) ;
855
846
for ( let i = 0 ; i < files . length ; i ++ ) {
856
847
if ( existingTimeouts !== undefined ) {
857
- session . checkTimeoutQueueLength ( existingTimeouts + 1 ) ;
858
- session . runQueuedTimeoutCallbacks ( host . getNextTimeoutId ( ) - 1 ) ;
848
+ host . checkTimeoutQueueLength ( existingTimeouts + 1 ) ;
849
+ host . runQueuedTimeoutCallbacks ( host . getNextTimeoutId ( ) - 1 ) ;
859
850
}
860
851
else {
861
- session . checkTimeoutQueueLengthAndRun ( 1 ) ;
852
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ;
862
853
}
863
- if ( ! skip ?. [ i ] ?. semantic ) session . runQueuedImmediateCallbacks ( 1 ) ;
864
- if ( ! skip ?. [ i ] ?. suggestion ) session . runQueuedImmediateCallbacks ( 1 ) ;
854
+ if ( ! skip ?. [ i ] ?. semantic ) host . runQueuedImmediateCallbacks ( 1 ) ;
855
+ if ( ! skip ?. [ i ] ?. suggestion ) host . runQueuedImmediateCallbacks ( 1 ) ;
865
856
}
866
857
}
867
858
0 commit comments