@@ -141,7 +141,7 @@ export interface ResolutionCache {
141
141
142
142
invalidateResolutionsOfFailedLookupLocations ( ) : boolean ;
143
143
invalidateResolutionOfFile ( filePath : Path ) : void ;
144
- removeResolutionsOfFile ( filePath : Path , syncDirWatcherRemove ?: boolean ) : void ;
144
+ removeResolutionsOfFile ( filePath : Path ) : void ;
145
145
removeResolutionsFromProjectReferenceRedirects ( filePath : Path ) : void ;
146
146
setFilesWithInvalidatedNonRelativeUnresolvedImports ( filesWithUnresolvedImports : Map < Path , readonly string [ ] > ) : void ;
147
147
createHasInvalidatedResolutions (
@@ -1273,7 +1273,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1273
1273
else if ( packageDirWatcher . isSymlink !== isSymlink ) {
1274
1274
// Handle the change
1275
1275
packageDirWatcher . dirPathToWatcher . forEach ( watcher => {
1276
- removeDirectoryWatcher ( packageDirWatcher ! . isSymlink ? packageDirPath : dirPath , /*syncDirWatcherRemove*/ false ) ;
1276
+ removeDirectoryWatcher ( packageDirWatcher ! . isSymlink ? packageDirPath : dirPath ) ;
1277
1277
watcher . watcher = createDirPathToWatcher ( ) ;
1278
1278
} ) ;
1279
1279
packageDirWatcher . isSymlink = isSymlink ;
@@ -1329,7 +1329,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1329
1329
return dirWatcher ;
1330
1330
}
1331
1331
1332
- function stopWatchFailedLookupLocation ( failedLookupLocation : string , removeAtRoot : boolean , syncDirWatcherRemove : boolean | undefined ) {
1332
+ function stopWatchFailedLookupLocation ( failedLookupLocation : string , removeAtRoot : boolean ) {
1333
1333
const failedLookupLocationPath = resolutionHost . toPath ( failedLookupLocation ) ;
1334
1334
const toWatch = getDirectoryToWatchFailedLookupLocation (
1335
1335
failedLookupLocation ,
@@ -1350,7 +1350,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1350
1350
const forDirPath = packageDirWatcher . dirPathToWatcher . get ( dirPath ) ! ;
1351
1351
forDirPath . refCount -- ;
1352
1352
if ( forDirPath . refCount === 0 ) {
1353
- removeDirectoryWatcher ( packageDirWatcher . isSymlink ? packageDirPath : dirPath , syncDirWatcherRemove ) ;
1353
+ removeDirectoryWatcher ( packageDirWatcher . isSymlink ? packageDirPath : dirPath ) ;
1354
1354
packageDirWatcher . dirPathToWatcher . delete ( dirPath ) ;
1355
1355
if ( packageDirWatcher . isSymlink ) {
1356
1356
const refCount = dirPathToSymlinkPackageRefCount . get ( dirPath ) ! - 1 ;
@@ -1361,11 +1361,10 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1361
1361
dirPathToSymlinkPackageRefCount . set ( dirPath , refCount ) ;
1362
1362
}
1363
1363
}
1364
- if ( syncDirWatcherRemove ) closePackageDirWatcher ( packageDirWatcher , packageDirPath ) ;
1365
1364
}
1366
1365
}
1367
1366
else {
1368
- removeDirectoryWatcher ( dirPath , syncDirWatcherRemove ) ;
1367
+ removeDirectoryWatcher ( dirPath ) ;
1369
1368
}
1370
1369
}
1371
1370
return removeAtRoot ;
@@ -1375,7 +1374,6 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1375
1374
resolution : T ,
1376
1375
filePath : Path ,
1377
1376
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
1378
- syncDirWatcherRemove ?: boolean ,
1379
1377
) {
1380
1378
Debug . checkDefined ( resolution . files ) . delete ( filePath ) ;
1381
1379
if ( resolution . files ! . size ) return ;
@@ -1392,11 +1390,11 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1392
1390
let removeAtRoot = false ;
1393
1391
if ( failedLookupLocations ) {
1394
1392
for ( const failedLookupLocation of failedLookupLocations ) {
1395
- removeAtRoot = stopWatchFailedLookupLocation ( failedLookupLocation , removeAtRoot , syncDirWatcherRemove ) ;
1393
+ removeAtRoot = stopWatchFailedLookupLocation ( failedLookupLocation , removeAtRoot ) ;
1396
1394
}
1397
1395
}
1398
- if ( alternateResult ) removeAtRoot = stopWatchFailedLookupLocation ( alternateResult , removeAtRoot , syncDirWatcherRemove ) ;
1399
- if ( removeAtRoot ) removeDirectoryWatcher ( rootPath , syncDirWatcherRemove ) ;
1396
+ if ( alternateResult ) removeAtRoot = stopWatchFailedLookupLocation ( alternateResult , removeAtRoot ) ;
1397
+ if ( removeAtRoot ) removeDirectoryWatcher ( rootPath ) ;
1400
1398
}
1401
1399
else if ( affectingLocations ?. length ) {
1402
1400
resolutionsWithOnlyAffectingLocations . delete ( resolution ) ;
@@ -1406,16 +1404,14 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1406
1404
for ( const affectingLocation of affectingLocations ) {
1407
1405
const watcher = fileWatchesOfAffectingLocations . get ( affectingLocation ) ! ;
1408
1406
watcher . resolutions -- ;
1409
- if ( syncDirWatcherRemove ) closeFileWatcherOfAffectingLocation ( watcher , affectingLocation ) ;
1410
1407
}
1411
1408
}
1412
1409
}
1413
1410
1414
- function removeDirectoryWatcher ( dirPath : Path , syncDirWatcherRemove : boolean | undefined ) {
1411
+ function removeDirectoryWatcher ( dirPath : Path ) {
1415
1412
const dirWatcher = directoryWatchesOfFailedLookups . get ( dirPath ) ! ;
1416
1413
// Do not close the watcher yet since it might be needed by other failed lookup locations.
1417
1414
dirWatcher . refCount -- ;
1418
- if ( syncDirWatcherRemove ) closeDirectoryWatchesOfFailedLookup ( dirWatcher , dirPath ) ;
1419
1415
}
1420
1416
1421
1417
function createDirectoryWatcher ( directory : string , dirPath : Path , nonRecursive : boolean | undefined ) {
@@ -1434,7 +1430,6 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1434
1430
cache : Map < string , ModeAwareCache < T > > ,
1435
1431
filePath : Path ,
1436
1432
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
1437
- syncDirWatcherRemove : boolean | undefined ,
1438
1433
) {
1439
1434
// Deleted file, stop watching failed lookups for all the resolutions in the file
1440
1435
const resolutions = cache . get ( filePath ) ;
@@ -1444,7 +1439,6 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1444
1439
resolution ,
1445
1440
filePath ,
1446
1441
getResolutionWithResolvedFileName ,
1447
- syncDirWatcherRemove ,
1448
1442
)
1449
1443
) ;
1450
1444
cache . delete ( filePath ) ;
@@ -1465,9 +1459,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1465
1459
resolvedProjectReference . commandLine . fileNames . forEach ( f => removeResolutionsOfFile ( resolutionHost . toPath ( f ) ) ) ;
1466
1460
}
1467
1461
1468
- function removeResolutionsOfFile ( filePath : Path , syncDirWatcherRemove ?: boolean ) {
1469
- removeResolutionsOfFileFromCache ( resolvedModuleNames , filePath , getResolvedModuleFromResolution , syncDirWatcherRemove ) ;
1470
- removeResolutionsOfFileFromCache ( resolvedTypeReferenceDirectives , filePath , getResolvedTypeReferenceDirectiveFromResolution , syncDirWatcherRemove ) ;
1462
+ function removeResolutionsOfFile ( filePath : Path ) {
1463
+ removeResolutionsOfFileFromCache ( resolvedModuleNames , filePath , getResolvedModuleFromResolution ) ;
1464
+ removeResolutionsOfFileFromCache ( resolvedTypeReferenceDirectives , filePath , getResolvedTypeReferenceDirectiveFromResolution ) ;
1471
1465
}
1472
1466
1473
1467
function invalidateResolutions ( resolutions : Set < ResolutionWithFailedLookupLocations > | Map < string , ResolutionWithFailedLookupLocations > | undefined , canInvalidate : ( resolution : ResolutionWithFailedLookupLocations ) => boolean | undefined ) {
0 commit comments