From a35f7996a63c2ab2c77746e984a00d1fb14fba19 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 13 Aug 2019 08:13:24 -0700 Subject: [PATCH 1/2] Do cleanup after opening files only if opening a file. --- src/server/editorServices.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index a25256a3aec79..9fd15333cc9c6 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2705,8 +2705,6 @@ namespace ts.server { // It was then postponed to cleanup these script infos so that they can be reused if // the file from that old project is reopened because of opening file from here. this.removeOrphanScriptInfos(); - - this.printProjects(); } openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult { @@ -2714,6 +2712,7 @@ namespace ts.server { const { defaultConfigProject, ...result } = this.assignProjectToOpenedScriptInfo(info); this.cleanupAfterOpeningFile(defaultConfigProject); this.telemetryOnOpenFile(info); + this.printProjects(); return result; } @@ -2914,12 +2913,16 @@ namespace ts.server { this.assignOrphanScriptInfosToInferredProject(); } - // Cleanup projects - this.cleanupAfterOpeningFile(defaultConfigProjects); - - // Telemetry - forEach(openScriptInfos, info => this.telemetryOnOpenFile(info)); - this.printProjects(); + if (openScriptInfos) { + // Cleanup projects + this.cleanupAfterOpeningFile(defaultConfigProjects); + // Telemetry + openScriptInfos.forEach(info => this.telemetryOnOpenFile(info)); + this.printProjects(); + } + else if (length(closedFiles)) { + this.printProjects(); + } } /* @internal */ From c52b129a193581d168ae82c91d8e3a59f455c9c5 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 13 Aug 2019 11:40:00 -0700 Subject: [PATCH 2/2] Add cancellation token check for function expression, arrow expression and class expression just like their counter part declarations This helps in early exit if request is cancelled and intellisense in js files is super quick with edits --- src/compiler/checker.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 62308cbfbbf78..9d6fa60306c03 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25271,7 +25271,18 @@ namespace ts { } function checkExpressionWorker(node: Expression | QualifiedName, checkMode: CheckMode | undefined, forceTuple?: boolean): Type { - switch (node.kind) { + const kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessively + // hitting the cancellation token on every node we check. + switch (kind) { + case SyntaxKind.ClassExpression: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case SyntaxKind.Identifier: return checkIdentifier(node); case SyntaxKind.ThisKeyword: