| 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 source_file_provider; | 5 library source_file_provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:uri'; | 8 import 'dart:uri'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:utf'; | 10 import 'dart:utf'; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 bool enableColors = false; | 61 bool enableColors = false; |
| 62 bool throwOnError = false; | 62 bool throwOnError = false; |
| 63 | 63 |
| 64 final int FATAL = api.Diagnostic.CRASH.ordinal | api.Diagnostic.ERROR.ordinal; | 64 final int FATAL = api.Diagnostic.CRASH.ordinal | api.Diagnostic.ERROR.ordinal; |
| 65 final int INFO = | 65 final int INFO = |
| 66 api.Diagnostic.INFO.ordinal | api.Diagnostic.VERBOSE_INFO.ordinal; | 66 api.Diagnostic.INFO.ordinal | api.Diagnostic.VERBOSE_INFO.ordinal; |
| 67 | 67 |
| 68 FormattingDiagnosticHandler(SourceFileProvider this.provider); | 68 FormattingDiagnosticHandler(SourceFileProvider this.provider); |
| 69 | 69 |
| 70 void info(var message, [api.Diagnostic kind = api.Diagnostic.VERBOSE_INFO]) { | 70 void info(var message, [api.Diagnostic kind = api.Diagnostic.VERBOSE_INFO]) { |
| 71 if (!verbose && identical(kind, api.Diagnostic.VERBOSE_INFO)) return; |
| 71 if (enableColors) { | 72 if (enableColors) { |
| 72 print('${colors.green("info:")} $message'); | 73 print('${colors.green("info:")} $message'); |
| 73 } else { | 74 } else { |
| 74 print('info: $message'); | 75 print('info: $message'); |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 | 78 |
| 78 void diagnosticHandler(Uri uri, int begin, int end, String message, | 79 void diagnosticHandler(Uri uri, int begin, int end, String message, |
| 79 api.Diagnostic kind) { | 80 api.Diagnostic kind) { |
| 80 // TODO(ahe): Remove this when source map is handled differently. | 81 // TODO(ahe): Remove this when source map is handled differently. |
| 81 if (identical(kind.name, 'source map')) return; | 82 if (identical(kind.name, 'source map')) return; |
| 82 if (!verbose && identical(kind, api.Diagnostic.VERBOSE_INFO)) return; | |
| 83 | 83 |
| 84 if (isAborting) return; | 84 if (isAborting) return; |
| 85 isAborting = identical(kind, api.Diagnostic.CRASH); | 85 isAborting = identical(kind, api.Diagnostic.CRASH); |
| 86 bool fatal = (kind.ordinal & FATAL) != 0; | 86 bool fatal = (kind.ordinal & FATAL) != 0; |
| 87 bool isInfo = (kind.ordinal & INFO) != 0; | 87 bool isInfo = (kind.ordinal & INFO) != 0; |
| 88 if (isInfo && uri == null && !identical(kind, api.Diagnostic.INFO)) { | 88 if (isInfo && uri == null && !identical(kind, api.Diagnostic.INFO)) { |
| 89 info(message, kind); | 89 info(message, kind); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 var color; | 92 var color; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 116 print(file.getLocationMessage(color(message), begin, end, true, color)); | 116 print(file.getLocationMessage(color(message), begin, end, true, color)); |
| 117 } | 117 } |
| 118 if (fatal && throwOnError) { | 118 if (fatal && throwOnError) { |
| 119 isAborting = true; | 119 isAborting = true; |
| 120 throw new AbortLeg(message); | 120 throw new AbortLeg(message); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| OLD | NEW |