From 55931c46bb690ba7187767006219f9ca186ac794 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 21 Aug 2017 15:09:03 -0700 Subject: [PATCH] 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 --- src/compiler/resolutionCache.ts | 32 ++++---------------------------- src/server/editorServices.ts | 2 +- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index e331133fe7..6d7c1f6c0e 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -240,35 +240,11 @@ namespace ts { } function updateFailedLookupLocationWatches(containingFile: string, name: string, existingFailedLookupLocations: ReadonlyArray | undefined, failedLookupLocations: ReadonlyArray) { - 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( diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6cbc526324..884ee518a3 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -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}`); } /**