Changed messages, got rid of 'oldProgram'.

This commit is contained in:
Daniel Rosenwasser
2014-08-01 18:54:26 -07:00
parent 91023227e4
commit 30509f1ecc
4 changed files with 14 additions and 11 deletions

View File

@@ -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." },

View File

@@ -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
},

View File

@@ -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;
}

View File

@@ -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<boolean>) {
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);
}
}