| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_style.src.error_listener; | 5 library dart_style.src.error_listener; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 | 8 |
| 9 import 'formatter_exception.dart'; | 9 import 'exceptions.dart'; |
| 10 | 10 |
| 11 /// A simple [AnalysisErrorListener] that just collects the reported errors. | 11 /// A simple [AnalysisErrorListener] that just collects the reported errors. |
| 12 class ErrorListener implements AnalysisErrorListener { | 12 class ErrorListener implements AnalysisErrorListener { |
| 13 final _errors = <AnalysisError>[]; | 13 final _errors = <AnalysisError>[]; |
| 14 | 14 |
| 15 void onError(AnalysisError error) { | 15 void onError(AnalysisError error) { |
| 16 _errors.add(error); | 16 _errors.add(error); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /// Throws a [FormatterException] if any errors have been reported. | 19 /// Throws a [FormatterException] if any errors have been reported. |
| 20 void throwIfErrors() { | 20 void throwIfErrors() { |
| 21 if (_errors.isEmpty) return; | 21 if (_errors.isEmpty) return; |
| 22 | 22 |
| 23 throw new FormatterException(_errors); | 23 throw new FormatterException(_errors); |
| 24 } | 24 } |
| 25 } | 25 } |
| OLD | NEW |