From 30509f1ecc8d44d10a4645fb94d7b58f6466fac9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 1 Aug 2014 18:54:26 -0700 Subject: [PATCH] Changed messages, got rid of 'oldProgram'. --- .../diagnosticInformationMap.generated.ts | 4 ++-- src/compiler/diagnosticMessages.json | 4 ++-- src/compiler/sys.ts | 2 +- src/compiler/tc.ts | 15 +++++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a3b85cfb013..c1319edd442 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -217,8 +217,8 @@ module ts { Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." }, Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." }, Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" }, - File_Changed_Compiling: { code: 6032, category: DiagnosticCategory.Message, key: "File Changed. Compiling." }, - Compile_complete_Listening_for_changed_files: { code: 6042, category: DiagnosticCategory.Message, key: "Compile complete. Listening for changed files." }, + File_change_detected_Compiling: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Compiling..." }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9ace46f4202..fac4ba6732f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -862,11 +862,11 @@ "category": "Message", "code": 6029 }, - "File Changed. Compiling.": { + "File change detected. Compiling...": { "category": "Message", "code": 6032 }, - "Compile complete. Listening for changed files.": { + "Compilation complete. Watching for file changes.": { "category": "Message", "code": 6042 }, diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 03d517476cd..564f22b9f08 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -199,7 +199,7 @@ var sys: System = (function () { close() { _fs.unwatchFile(fileName, fileChanged); } }; - function fileChanged(curr:any, prev:any) { + function fileChanged(curr: any, prev: any) { if (+curr.mtime <= +prev.mtime) { return; } diff --git a/src/compiler/tc.ts b/src/compiler/tc.ts index fc508ed459c..0cfa89a01c9 100644 --- a/src/compiler/tc.ts +++ b/src/compiler/tc.ts @@ -231,7 +231,7 @@ module ts { // Compile the program the first time and watch all given/referenced files. var program = compile(commandLine, compilerHost).program; - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compile_complete_Listening_for_changed_files)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); addWatchers(program); return; @@ -272,11 +272,14 @@ module ts { } function recompile(changedFiles: Map) { - var oldProgram = program; - reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_Changed_Compiling)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling)); // Remove all the watchers, since we may not be watching every file // specified since the last recompilation cycle. - removeWatchers(oldProgram); + removeWatchers(program); + + // Release the old program. + var getUnmodifiedSourceFile = program.getSourceFile; + program = undefined; // We create a new compiler host for this compilation cycle. // This new host is effectively the same except that 'getSourceFile' @@ -285,7 +288,7 @@ module ts { var newCompilerHost = clone(compilerHost); newCompilerHost.getSourceFile = (fileName, languageVersion, onError) => { if (!hasProperty(changedFiles, fileName)) { - var sourceFile = oldProgram.getSourceFile(fileName); + var sourceFile = getUnmodifiedSourceFile(fileName); if (sourceFile) { return sourceFile; } @@ -295,7 +298,7 @@ module ts { }; program = compile(commandLine, newCompilerHost).program; - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compile_complete_Listening_for_changed_files)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); addWatchers(program); } }