@@ -85,7 +85,7 @@ module ts {
85
85
return diagnostic . messageText ;
86
86
}
87
87
88
- function reportDiagnostic ( diagnostic : Diagnostic ) {
88
+ function reportDiagnostic ( diagnostic : Diagnostic , options : CompilerOptions ) {
89
89
var output = "" ;
90
90
91
91
if ( diagnostic . file ) {
@@ -95,14 +95,20 @@ module ts {
95
95
}
96
96
97
97
var category = DiagnosticCategory [ diagnostic . category ] . toLowerCase ( ) ;
98
- output += category + " TS" + diagnostic . code + ": " + diagnostic . messageText + sys . newLine ;
98
+ output += category ;
99
+
100
+ if ( options . printErrorCodes ) {
101
+ output += " TS" + diagnostic . code ;
102
+ }
103
+
104
+ output += ": " + diagnostic . messageText + sys . newLine ;
99
105
100
106
sys . write ( output ) ;
101
107
}
102
108
103
- function reportDiagnostics ( diagnostics : Diagnostic [ ] ) {
109
+ function reportDiagnostics ( diagnostics : Diagnostic [ ] , options : CompilerOptions ) {
104
110
for ( var i = 0 ; i < diagnostics . length ; i ++ ) {
105
- reportDiagnostic ( diagnostics [ i ] ) ;
111
+ reportDiagnostic ( diagnostics [ i ] , options ) ;
106
112
}
107
113
}
108
114
@@ -207,12 +213,12 @@ module ts {
207
213
// If there are any errors due to command line parsing and/or
208
214
// setting up localization, report them and quit.
209
215
if ( commandLine . errors . length > 0 ) {
210
- reportDiagnostics ( commandLine . errors ) ;
216
+ reportDiagnostics ( commandLine . errors , commandLine . options ) ;
211
217
return sys . exit ( 1 ) ;
212
218
}
213
219
214
220
if ( commandLine . options . version ) {
215
- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Version_0 , version ) ) ;
221
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Version_0 , version ) , commandLine . options ) ;
216
222
return sys . exit ( 0 ) ;
217
223
}
218
224
@@ -226,7 +232,7 @@ module ts {
226
232
227
233
if ( commandLine . options . watch ) {
228
234
if ( ! sys . watchFile ) {
229
- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . The_current_host_does_not_support_the_0_option , "--watch" ) ) ;
235
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . The_current_host_does_not_support_the_0_option , "--watch" ) , commandLine . options ) ;
230
236
return sys . exit ( 1 ) ;
231
237
}
232
238
@@ -250,7 +256,7 @@ module ts {
250
256
251
257
// Compile the program the first time and watch all given/referenced files.
252
258
var program = compile ( commandLine , compilerHost ) . program ;
253
- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
259
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) , commandLine . options ) ;
254
260
addWatchers ( program ) ;
255
261
return ;
256
262
@@ -290,7 +296,7 @@ module ts {
290
296
}
291
297
292
298
function recompile ( changedFiles : Map < boolean > ) {
293
- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . File_change_detected_Compiling ) ) ;
299
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . File_change_detected_Compiling ) , commandLine . options ) ;
294
300
// Remove all the watchers, as we may not be watching every file
295
301
// specified since the last compilation cycle.
296
302
removeWatchers ( program ) ;
@@ -317,7 +323,7 @@ module ts {
317
323
} ;
318
324
319
325
program = compile ( commandLine , newCompilerHost ) . program ;
320
- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
326
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) , commandLine . options ) ;
321
327
addWatchers ( program ) ;
322
328
}
323
329
@@ -347,7 +353,7 @@ module ts {
347
353
errors = concatenate ( semanticErrors , emitErrors ) ;
348
354
}
349
355
350
- reportDiagnostics ( errors ) ;
356
+ reportDiagnostics ( errors , commandLine . options ) ;
351
357
if ( commandLine . options . diagnostics ) {
352
358
var memoryUsed = sys . getMemoryUsage ? sys . getMemoryUsage ( ) : - 1 ;
353
359
reportCountStatistic ( "Files" , program . getSourceFiles ( ) . length ) ;
0 commit comments