From 361a852ef179a6e418a29f41a675b96bea613bf6 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 29 Jul 2016 15:23:43 -0700 Subject: [PATCH] use ExternalFile in ApplyChangesInOpenFiles --- src/server/editorServices.ts | 8 ++++---- src/server/protocol.d.ts | 12 ++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 527c16b11b3..d7f783a1610 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -984,13 +984,13 @@ namespace ts.server { return this.openClientFileWithNormalizedPath(toNormalizedPath(fileName), fileContent, scriptKind); } - openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult { + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult { const { configFileName = undefined, configFileErrors = undefined }: OpenConfiguredProjectResult = this.findContainingExternalProject(fileName) ? {} : this.openOrUpdateConfiguredProjectForFile(fileName); // at this point if file is the part of some configured/external project then this project should be created - const info = this.getOrCreateScriptInfoForNormalizedPath(fileName, /*openedByClient*/ true, fileContent, scriptKind); + const info = this.getOrCreateScriptInfoForNormalizedPath(fileName, /*openedByClient*/ true, fileContent, scriptKind, hasMixedContent); this.assignScriptInfoToInferredProjectIfNecessary(info, /*addToListOfOpenFiles*/ true); this.printProjects(); return { configFileName, configFileErrors }; @@ -1024,14 +1024,14 @@ namespace ts.server { return files; } - applyChangesInOpenFiles(openFiles: protocol.NewOpenFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void { + applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void { const recordChangedFiles = changedFiles && !openFiles && !closedFiles; if (openFiles) { for (const file of openFiles) { const scriptInfo = this.getScriptInfo(file.fileName); Debug.assert(!scriptInfo || !scriptInfo.isOpen); const normalizedPath = scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); } } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 3f49e869775..b7b83e60af1 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -494,6 +494,7 @@ declare namespace ts.server.protocol { fileName: string; scriptKind?: ScriptKind; hasMixedContent?: boolean; + content?: string; } export interface ExternalProject { @@ -526,15 +527,6 @@ declare namespace ts.server.protocol { changes?: ProjectChanges; } - /** - * Represents a set of changes for open document with a given file name. - * Either content of textChanges should be present. - */ - export interface NewOpenFile { - fileName: string; - content: string; - } - export interface ChangedOpenFile { fileName: string; changes: ts.TextChange[]; @@ -699,7 +691,7 @@ declare namespace ts.server.protocol { } export interface ApplyChangedToOpenFilesRequestArgs { - openFiles?: NewOpenFile[]; + openFiles?: ExternalFile[]; changedFiles?: ChangedOpenFile[]; closedFiles?: string[]; }