Skip to content

Commit

Permalink
Update the failed lookup watches without doing lookups.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sheetalkamat committed Aug 22, 2017
1 parent 6227a36 commit 55931c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
32 changes: 4 additions & 28 deletions src/compiler/resolutionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
2 changes: 1 addition & 1 deletion src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}

/**
Expand Down

0 comments on commit 55931c4

Please sign in to comment.