| 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 csslib.src.messages; | 5 library csslib.src.messages; |
| 6 | 6 |
| 7 import 'package:logging/logging.dart' show Level; | 7 import 'package:logging/logging.dart' show Level; |
| 8 import 'package:source_maps/span.dart' show Span; | 8 import 'package:source_maps/span.dart' show Span; |
| 9 | 9 |
| 10 import 'options.dart'; | 10 import 'options.dart'; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 output.write(message); | 61 output.write(message); |
| 62 } else { | 62 } else { |
| 63 output.write(span.getLocationMessage(message, useColors: colors, | 63 output.write(span.getLocationMessage(message, useColors: colors, |
| 64 color: levelColor)); | 64 color: levelColor)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 return output.toString(); | 67 return output.toString(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 typedef void PrintHandler(Object obj); | 71 typedef void PrintHandler(Message obj); |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * This class tracks and prints information, warnings, and errors emitted by the | 74 * This class tracks and prints information, warnings, and errors emitted by the |
| 75 * compiler. | 75 * compiler. |
| 76 */ | 76 */ |
| 77 class Messages { | 77 class Messages { |
| 78 /** Called on every error. Set to blank function to supress printing. */ | 78 /** Called on every error. Set to blank function to supress printing. */ |
| 79 final PrintHandler printHandler; | 79 final PrintHandler printHandler; |
| 80 | 80 |
| 81 final PreprocessorOptions options; | 81 final PreprocessorOptions options; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 /** Merge [newMessages] to this message lsit. */ | 120 /** Merge [newMessages] to this message lsit. */ |
| 121 void mergeMessages(Messages newMessages) { | 121 void mergeMessages(Messages newMessages) { |
| 122 messages.addAll(newMessages.messages); | 122 messages.addAll(newMessages.messages); |
| 123 newMessages.messages.where((message) => | 123 newMessages.messages.where((message) => |
| 124 message.level.value == Level.SEVERE || options.verbose) | 124 message.level.value == Level.SEVERE || options.verbose) |
| 125 .forEach((message) { printHandler(message); }); | 125 .forEach((message) { printHandler(message); }); |
| 126 } | 126 } |
| 127 } | 127 } |
| OLD | NEW |