| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('dart2js'); | 5 #library('dart2js'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('dart:uri'); | 8 #import('dart:uri'); |
| 9 #import('dart:utf'); | 9 #import('dart:utf'); |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // TODO(podivilov): We should find a better way to return source maps from | 187 // TODO(podivilov): We should find a better way to return source maps from |
| 188 // emitter. Using diagnostic handler for that purpose is a temporary hack. | 188 // emitter. Using diagnostic handler for that purpose is a temporary hack. |
| 189 writeString(sourceMapOut, message); | 189 writeString(sourceMapOut, message); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 if (isAborting) return; | 193 if (isAborting) return; |
| 194 isAborting = kind === api.Diagnostic.CRASH; | 194 isAborting = kind === api.Diagnostic.CRASH; |
| 195 bool fatal = (kind.ordinal & FATAL) != 0; | 195 bool fatal = (kind.ordinal & FATAL) != 0; |
| 196 bool isInfo = (kind.ordinal & INFO) != 0; | 196 bool isInfo = (kind.ordinal & INFO) != 0; |
| 197 if (isInfo && uri === null && kind !== api.Diagnostic.INFO) { | 197 if (isInfo) { |
| 198 assert(uri === null); |
| 198 info(message, kind); | 199 info(message, kind); |
| 199 return; | 200 return; |
| 200 } | 201 } |
| 201 var color; | 202 var color; |
| 202 if (!enableColors) { | 203 if (!enableColors) { |
| 203 color = (x) => x; | 204 color = (x) => x; |
| 204 } else if (kind === api.Diagnostic.ERROR) { | 205 } else if (kind === api.Diagnostic.ERROR) { |
| 205 color = colors.red; | 206 color = colors.red; |
| 206 } else if (kind === api.Diagnostic.WARNING) { | 207 } else if (kind === api.Diagnostic.WARNING) { |
| 207 color = colors.magenta; | 208 color = colors.magenta; |
| 208 } else if (kind === api.Diagnostic.LINT) { | 209 } else if (kind === api.Diagnostic.LINT) { |
| 209 color = colors.magenta; | 210 color = colors.magenta; |
| 210 } else if (kind === api.Diagnostic.CRASH) { | 211 } else if (kind === api.Diagnostic.CRASH) { |
| 211 color = colors.red; | 212 color = colors.red; |
| 212 } else if (kind === api.Diagnostic.INFO) { | |
| 213 color = colors.green; | |
| 214 } else { | 213 } else { |
| 215 throw 'Unknown kind: $kind (${kind.ordinal})'; | 214 throw 'Unknown kind: $kind (${kind.ordinal})'; |
| 216 } | 215 } |
| 217 if (uri === null) { | 216 if (uri === null) { |
| 218 assert(fatal); | 217 assert(fatal); |
| 219 print(color(message)); | 218 print(color(message)); |
| 220 } else if (fatal || showWarnings) { | 219 } else if (fatal || showWarnings) { |
| 221 SourceFile file = sourceFiles[uri.toString()]; | 220 SourceFile file = sourceFiles[uri.toString()]; |
| 222 print(file.getLocationMessage(color(message), begin, end, true, | 221 print(file.getLocationMessage(color(message), begin, end, true, |
| 223 color)); | 222 color)); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } catch (var ignored) { | 374 } catch (var ignored) { |
| 376 print('Internal error: error while printing exception'); | 375 print('Internal error: error while printing exception'); |
| 377 } | 376 } |
| 378 try { | 377 try { |
| 379 print(trace); | 378 print(trace); |
| 380 } finally { | 379 } finally { |
| 381 exit(253); // 253 is recognized as a crash by our test scripts. | 380 exit(253); // 253 is recognized as a crash by our test scripts. |
| 382 } | 381 } |
| 383 } | 382 } |
| 384 } | 383 } |
| OLD | NEW |