diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a4c3a65f29c..cb12e6da4d5 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -10,6 +10,22 @@ module ts { /** The version of the TypeScript compiler release */ export let version = "1.5.0.0"; + export function findConfigFile(searchPath: string): string { + var fileName = "tsconfig.json"; + while (true) { + if (sys.fileExists(fileName)) { + return fileName; + } + var parentPath = getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { let currentDirectory: string; let existingDirectories: Map = {}; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 3f82d6c8cf5..a0d21106f43 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -132,23 +132,6 @@ module ts { return typeof JSON === "object" && typeof JSON.parse === "function"; } - function findConfigFile(): string { - var searchPath = normalizePath(sys.getCurrentDirectory()); - var fileName = "tsconfig.json"; - while (true) { - if (sys.fileExists(fileName)) { - return fileName; - } - var parentPath = getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - fileName = "../" + fileName; - } - return undefined; - } - export function executeCommandLine(args: string[]): void { var commandLine = parseCommandLine(args); var configFileName: string; // Configuration file name (if any) @@ -198,7 +181,8 @@ module ts { } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { - configFileName = findConfigFile(); + var searchPath = normalizePath(sys.getCurrentDirectory()); + configFileName = findConfigFile(searchPath); } if (commandLine.fileNames.length === 0 && !configFileName) { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e78e6fa8b78..034549ab464 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -280,12 +280,7 @@ module ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { - if (projectOptions && projectOptions.compilerOptions) { - this.compilerService = new CompilerService(this,projectOptions.compilerOptions); - } - else { - this.compilerService = new CompilerService(this); - } + this.compilerService = new CompilerService(this,projectOptions && projectOptions.compilerOptions); } addOpenRef() { @@ -508,7 +503,7 @@ module ts.server { this.printProjects(); } - gcConfiguredProjects() { + updateConfiguredProjectList() { var configuredProjects: Project[] = []; for (var i = 0, len = this.configuredProjects.length; i < len; i++) { if (this.configuredProjects[i].openRefCount > 0) { @@ -565,7 +560,7 @@ module ts.server { this.openFileRoots.push(info); } } - this.gcConfiguredProjects(); + this.updateConfiguredProjectList(); } /** @@ -762,13 +757,18 @@ module ts.server { */ openClientFile(fileName: string) { - var configFileName = this.findConfigFile(fileName); + var searchPath = ts.normalizePath(getDirectoryPath(fileName)); + var configFileName = ts.findConfigFile(searchPath); + if (configFileName) { + configFileName = getAbsolutePath(configFileName, searchPath); + } if (configFileName && (!this.configProjectIsActive(configFileName))) { var configResult = this.openConfigFile(configFileName, fileName); if (!configResult.success) { this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); } else { + this.log("Opened configuration file " + configFileName,"Info"); this.configuredProjects.push(configResult.project); } } @@ -859,22 +859,6 @@ module ts.server { } return false; } - - findConfigFile(openedFileName: string): string { - var searchPath = getDirectoryPath(openedFileName); - while (true) { - var fileName = searchPath + ts.directorySeparator + "tsconfig.json"; - if (sys.fileExists(fileName)) { - return fileName; - } - var parentPath = getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return undefined; - } openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { configFilename = ts.normalizePath(configFilename); @@ -915,9 +899,9 @@ module ts.server { } createProject(projectFilename: string, projectOptions?: ProjectOptions) { - var eproj = new Project(this, projectOptions); - eproj.projectFilename = projectFilename; - return eproj; + var project = new Project(this, projectOptions); + project.projectFilename = projectFilename; + return project; } } @@ -943,8 +927,6 @@ module ts.server { setCompilerOptions(opt: ts.CompilerOptions) { this.settings = opt; - // override default ES6 (remove when compiler default back at ES5) - this.settings.target = ts.ScriptTarget.ES5; this.host.setCompilationSettings(opt); } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index b8f4c7cdd13..88d9b7ff918 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1475,6 +1475,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; + function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index e1d9aa58961..eb4ddd7c1d4 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -4736,6 +4736,10 @@ declare module "typescript" { let version: string; >version : string + function findConfigFile(searchPath: string): string; +>findConfigFile : (searchPath: string) => string +>searchPath : string + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; >createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 4e3af8d1be0..d688c083e1b 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1506,6 +1506,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; + function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 7cf542f0b40..86d14b4fb88 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -4882,6 +4882,10 @@ declare module "typescript" { let version: string; >version : string + function findConfigFile(searchPath: string): string; +>findConfigFile : (searchPath: string) => string +>searchPath : string + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; >createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 261ad5b25f6..0d7463e8023 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1507,6 +1507,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; + function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index eb4c7ab122f..5e3911d278e 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -4832,6 +4832,10 @@ declare module "typescript" { let version: string; >version : string + function findConfigFile(searchPath: string): string; +>findConfigFile : (searchPath: string) => string +>searchPath : string + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; >createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index a821bc5011d..d2257c88a42 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1544,6 +1544,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; + function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 47e5a0147fd..aafd0df6560 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -5005,6 +5005,10 @@ declare module "typescript" { let version: string; >version : string + function findConfigFile(searchPath: string): string; +>findConfigFile : (searchPath: string) => string +>searchPath : string + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; >createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions