Update the failed lookup watches without doing lookups.
This helps in not having to deal with duplicate locations and checking if there exists watch Anyways the watches are refCount based so we would just addref and remove ref on the same watches
This commit is contained in:
parent
6227a36ff0
commit
55931c46bb
2 changed files with 5 additions and 29 deletions
|
@ -240,35 +240,11 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateFailedLookupLocationWatches(containingFile: string, name: string, existingFailedLookupLocations: ReadonlyArray<string> | undefined, failedLookupLocations: ReadonlyArray<string>) {
|
function updateFailedLookupLocationWatches(containingFile: string, name: string, existingFailedLookupLocations: ReadonlyArray<string> | undefined, failedLookupLocations: ReadonlyArray<string>) {
|
||||||
if (failedLookupLocations) {
|
// Watch all the failed lookup locations
|
||||||
if (existingFailedLookupLocations) {
|
withFailedLookupLocations(failedLookupLocations, containingFile, name, watchFailedLookupLocation);
|
||||||
const existingWatches = arrayToMap(existingFailedLookupLocations, toPath);
|
|
||||||
for (const failedLookupLocation of failedLookupLocations) {
|
|
||||||
const failedLookupLocationPath = toPath(failedLookupLocation);
|
|
||||||
if (existingWatches && existingWatches.has(failedLookupLocationPath)) {
|
|
||||||
// still has same failed lookup location, keep the watch
|
|
||||||
existingWatches.delete(failedLookupLocationPath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Create new watch
|
|
||||||
watchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, containingFile, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close all the watches that are still present in the existingWatches since those are not the locations looked up for buy new resolution
|
// Close existing watches for the failed locations
|
||||||
existingWatches.forEach((failedLookupLocation, failedLookupLocationPath: Path) =>
|
withFailedLookupLocations(existingFailedLookupLocations, containingFile, name, closeFailedLookupLocationWatcher);
|
||||||
closeFailedLookupLocationWatcher(failedLookupLocation, failedLookupLocationPath, containingFile, name)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Watch all the failed lookup locations
|
|
||||||
withFailedLookupLocations(failedLookupLocations, containingFile, name, watchFailedLookupLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Close existing watches for the failed locations
|
|
||||||
withFailedLookupLocations(existingFailedLookupLocations, containingFile, name, closeFailedLookupLocationWatcher);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function invalidateResolutionCacheOfDeletedFile<T extends NameResolutionWithFailedLookupLocations, R>(
|
function invalidateResolutionCacheOfDeletedFile<T extends NameResolutionWithFailedLookupLocations, R>(
|
||||||
|
|
|
@ -1023,7 +1023,7 @@ namespace ts.server {
|
||||||
if (this.configuredProjects.has(canonicalConfigFilePath)) {
|
if (this.configuredProjects.has(canonicalConfigFilePath)) {
|
||||||
watches.push(WatchType.ConfigFilePath);
|
watches.push(WatchType.ConfigFilePath);
|
||||||
}
|
}
|
||||||
this.logger.info(`ConfigFilePresence:: Current Watches: ['${watches.join("','")}']:: File: ${configFileName} Currently impacted open files: RootsOfInferredProjects: ${inferredRoots} OtherOpenFiles: ${otherFiles} Status: ${status}`);
|
this.logger.info(`ConfigFilePresence:: Current Watches: ${watches}:: File: ${configFileName} Currently impacted open files: RootsOfInferredProjects: ${inferredRoots} OtherOpenFiles: ${otherFiles} Status: ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue