From 097b094082827c2055a401686a4b5aec30afbfe6 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 7 Sep 2017 10:58:50 -0700 Subject: [PATCH] Don't get typings for projects with disabled language services --- src/server/project.ts | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index 623c43e8d3a..c8e9e1b4833 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -547,33 +547,32 @@ namespace ts.server { this.cachedUnresolvedImportsPerFile.remove(file); } - // 1. no changes in structure, no changes in unresolved imports - do nothing - // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files - // (can reuse cached imports for files that were not changed) - // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files - // (can reuse cached imports for files that were not changed) - // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch - let unresolvedImports: SortedReadonlyArray; - if (hasChanges || changedFiles.length) { - const result: string[] = []; - for (const sourceFile of this.program.getSourceFiles()) { - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - - const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } - // update builder only if language service is enabled // otherwise tell it to drop its internal state if (this.languageServiceEnabled) { + // 1. no changes in structure, no changes in unresolved imports - do nothing + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // (can reuse cached imports for files that were not changed) + // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files + // (can reuse cached imports for files that were not changed) + // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch + if (hasChanges || changedFiles.length) { + const result: string[] = []; + for (const sourceFile of this.program.getSourceFiles()) { + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result); + } + + const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + this.builder.onProjectUpdateGraph(); } else { + this.lastCachedUnresolvedImportsList = undefined; this.builder.clear(); }