@@ -395,17 +395,20 @@ namespace ts {
395
395
allDiagnostics ?: Diagnostic [ ] ;
396
396
}
397
397
398
+ /**
399
+ * Determines if program structure is upto date or needs to be recreated
400
+ */
398
401
export function isProgramUptoDate (
399
402
program : Program | undefined ,
400
403
rootFileNames : string [ ] ,
401
404
newOptions : CompilerOptions ,
402
405
getSourceVersion : ( path : Path ) => string ,
403
406
fileExists : ( fileName : string ) => boolean ,
404
407
hasInvalidatedResolution : HasInvalidatedResolution ,
405
- hasChangedAutomaticTypeDirectiveNames : ( ) => boolean ,
408
+ hasChangedAutomaticTypeDirectiveNames : boolean ,
406
409
) : boolean {
407
410
// If we haven't create a program yet or has changed automatic type directives, then it is not up-to-date
408
- if ( ! program || hasChangedAutomaticTypeDirectiveNames ( ) ) {
411
+ if ( ! program || hasChangedAutomaticTypeDirectiveNames ) {
409
412
return false ;
410
413
}
411
414
@@ -416,7 +419,7 @@ namespace ts {
416
419
417
420
// If any file is not up-to-date, then the whole program is not up-to-date
418
421
if ( program . getSourceFiles ( ) . some ( sourceFileNotUptoDate ) ) {
419
- return false ;
422
+ return false ;
420
423
}
421
424
422
425
// If any of the missing file paths are now created
@@ -464,78 +467,6 @@ namespace ts {
464
467
) ;
465
468
}
466
469
467
- /**
468
- * Updates the existing missing file watches with the new set of missing files after new program is created
469
- */
470
- export function updateMissingFilePathsWatch (
471
- program : Program ,
472
- missingFileWatches : Map < FileWatcher > ,
473
- createMissingFileWatch : ( missingFilePath : Path ) => FileWatcher ,
474
- ) {
475
- const missingFilePaths = program . getMissingFilePaths ( ) ;
476
- const newMissingFilePathMap = arrayToSet ( missingFilePaths ) ;
477
- // Update the missing file paths watcher
478
- mutateMap (
479
- missingFileWatches ,
480
- newMissingFilePathMap ,
481
- {
482
- // Watch the missing files
483
- createNewValue : createMissingFileWatch ,
484
- // Files that are no longer missing (e.g. because they are no longer required)
485
- // should no longer be watched.
486
- onDeleteValue : closeFileWatcher
487
- }
488
- ) ;
489
- }
490
-
491
- export interface WildcardDirectoryWatcher {
492
- watcher : FileWatcher ;
493
- flags : WatchDirectoryFlags ;
494
- }
495
-
496
- /**
497
- * Updates the existing wild card directory watches with the new set of wild card directories from the config file
498
- * after new program is created because the config file was reloaded or program was created first time from the config file
499
- * Note that there is no need to call this function when the program is updated with additional files without reloading config files,
500
- * as wildcard directories wont change unless reloading config file
501
- */
502
- export function updateWatchingWildcardDirectories (
503
- existingWatchedForWildcards : Map < WildcardDirectoryWatcher > ,
504
- wildcardDirectories : Map < WatchDirectoryFlags > ,
505
- watchDirectory : ( directory : string , flags : WatchDirectoryFlags ) => FileWatcher
506
- ) {
507
- mutateMap (
508
- existingWatchedForWildcards ,
509
- wildcardDirectories ,
510
- {
511
- // Create new watch and recursive info
512
- createNewValue : createWildcardDirectoryWatcher ,
513
- // Close existing watch thats not needed any more
514
- onDeleteValue : closeFileWatcherOf ,
515
- // Close existing watch that doesnt match in the flags
516
- onExistingValue : updateWildcardDirectoryWatcher
517
- }
518
- ) ;
519
-
520
- function createWildcardDirectoryWatcher ( directory : string , flags : WatchDirectoryFlags ) : WildcardDirectoryWatcher {
521
- // Create new watch and recursive info
522
- return {
523
- watcher : watchDirectory ( directory , flags ) ,
524
- flags
525
- } ;
526
- }
527
-
528
- function updateWildcardDirectoryWatcher ( existingWatcher : WildcardDirectoryWatcher , flags : WatchDirectoryFlags , directory : string ) {
529
- // Watcher needs to be updated if the recursive flags dont match
530
- if ( existingWatcher . flags === flags ) {
531
- return ;
532
- }
533
-
534
- existingWatcher . watcher . close ( ) ;
535
- existingWatchedForWildcards . set ( directory , createWildcardDirectoryWatcher ( directory , flags ) ) ;
536
- }
537
- }
538
-
539
470
/**
540
471
* Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
541
472
* that represent a compilation unit.
@@ -599,7 +530,6 @@ namespace ts {
599
530
let moduleResolutionCache : ModuleResolutionCache ;
600
531
let resolveModuleNamesWorker : ( moduleNames : string [ ] , containingFile : string , reusedNames ?: string [ ] ) => ResolvedModuleFull [ ] ;
601
532
const hasInvalidatedResolution = host . hasInvalidatedResolution || returnFalse ;
602
- const hasChangedAutomaticTypeDirectiveNames = host . hasChangedAutomaticTypeDirectiveNames && host . hasChangedAutomaticTypeDirectiveNames . bind ( host ) || returnFalse ;
603
533
if ( host . resolveModuleNames ) {
604
534
resolveModuleNamesWorker = ( moduleNames , containingFile , reusedNames ) => host . resolveModuleNames ( checkAllDefined ( moduleNames ) , containingFile , reusedNames ) . map ( resolved => {
605
535
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -1105,7 +1035,7 @@ namespace ts {
1105
1035
return oldProgram . structureIsReused ;
1106
1036
}
1107
1037
1108
- if ( hasChangedAutomaticTypeDirectiveNames ( ) ) {
1038
+ if ( host . hasChangedAutomaticTypeDirectiveNames ) {
1109
1039
return oldProgram . structureIsReused = StructureIsReused . SafeModules ;
1110
1040
}
1111
1041
0 commit comments