| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 if (lastKind == api.Diagnostic.WARNING && !showWarnings) return; | 144 if (lastKind == api.Diagnostic.WARNING && !showWarnings) return; |
| 145 if (lastKind == api.Diagnostic.HINT && !showHints) return; | 145 if (lastKind == api.Diagnostic.HINT && !showHints) return; |
| 146 color = colors.green; | 146 color = colors.green; |
| 147 } else { | 147 } else { |
| 148 throw 'Unknown kind: $kind (${kind.ordinal})'; | 148 throw 'Unknown kind: $kind (${kind.ordinal})'; |
| 149 } | 149 } |
| 150 if (!enableColors) { | 150 if (!enableColors) { |
| 151 color = (x) => x; | 151 color = (x) => x; |
| 152 } | 152 } |
| 153 if (uri == null) { | 153 if (uri == null) { |
| 154 assert(fatal); | 154 print('${color(message)}'); |
| 155 print(color(message)); | |
| 156 } else { | 155 } else { |
| 157 SourceFile file = provider.sourceFiles[uri.toString()]; | 156 SourceFile file = provider.sourceFiles[uri.toString()]; |
| 158 if (file == null) { | 157 if (file != null) { |
| 158 print(file.getLocationMessage(color(message), begin, end, true, color)); |
| 159 } else { |
| 159 throw '$uri: file is null'; | 160 throw '$uri: file is null'; |
| 160 } | 161 } |
| 161 print(file.getLocationMessage(color(message), begin, end, true, color)); | |
| 162 } | 162 } |
| 163 if (fatal && throwOnError) { | 163 if (fatal && throwOnError) { |
| 164 isAborting = true; | 164 isAborting = true; |
| 165 throw new AbortLeg(message); | 165 throw new AbortLeg(message); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { | 169 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
| 170 return diagnosticHandler(uri, begin, end, message, kind); | 170 return diagnosticHandler(uri, begin, end, message, kind); |
| 171 } | 171 } |
| 172 } | 172 } |
| OLD | NEW |