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:
Sheetal Nandi 2017-08-21 15:09:03 -07:00
parent 6227a36ff0
commit 55931c46bb
2 changed files with 5 additions and 29 deletions

View file

@ -240,35 +240,11 @@ namespace ts {
}
function updateFailedLookupLocationWatches(containingFile: string, name: string, existingFailedLookupLocations: ReadonlyArray<string> | undefined, failedLookupLocations: ReadonlyArray<string>) {
if (failedLookupLocations) {
if (existingFailedLookupLocations) {
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);
}
}
// Watch all the failed lookup locations
withFailedLookupLocations(failedLookupLocations, containingFile, name, watchFailedLookupLocation);
// Close all the watches that are still present in the existingWatches since those are not the locations looked up for buy new resolution
existingWatches.forEach((failedLookupLocation, failedLookupLocationPath: Path) =>
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);
}
// Close existing watches for the failed locations
withFailedLookupLocations(existingFailedLookupLocations, containingFile, name, closeFailedLookupLocationWatcher);
}
function invalidateResolutionCacheOfDeletedFile<T extends NameResolutionWithFailedLookupLocations, R>(

View file

@ -1023,7 +1023,7 @@ namespace ts.server {
if (this.configuredProjects.has(canonicalConfigFilePath)) {
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}`);
}
/**