Chromium Code Reviews| Index: pkg/analyzer/lib/src/error_formatter.dart |
| diff --git a/pkg/analyzer/lib/src/error_formatter.dart b/pkg/analyzer/lib/src/error_formatter.dart |
| index c26aaa4a5ab7a42b67c21ba906d7cfaec7a9406a..b7322df0ec028906f5b443cbc8f3b52c6c04cbe5 100644 |
| --- a/pkg/analyzer/lib/src/error_formatter.dart |
| +++ b/pkg/analyzer/lib/src/error_formatter.dart |
| @@ -9,23 +9,29 @@ import 'generated/error.dart'; |
| import 'generated/source_io.dart'; |
| import '../options.dart'; |
| +typedef bool _ErrorFilter(AnalysisError error); |
|
Brian Wilkerson
2014/03/21 13:23:00
Perhaps document that the function is expected to
scheglov
2014/03/21 16:17:38
Done.
|
| +bool _anyError(AnalysisError error) => true; |
| + |
| /** |
| * Helper for formatting [AnalysisError]s. |
| * The two format options are a user consumable format and a machine consumable format. |
| */ |
| class ErrorFormatter { |
| - StringSink out; |
| - CommandLineOptions options; |
| + final StringSink out; |
| + final CommandLineOptions options; |
| + final _ErrorFilter errorFilter; |
| - ErrorFormatter(this.out, this.options); |
| + ErrorFormatter(this.out, this.options, [this.errorFilter = _anyError]); |
| void formatErrors(List<AnalysisErrorInfo> errorInfos) { |
| var errors = new List<AnalysisError>(); |
| var errorToLine = new Map<AnalysisError, LineInfo>(); |
| for (AnalysisErrorInfo errorInfo in errorInfos) { |
| for (AnalysisError error in errorInfo.errors) { |
| - errors.add(error); |
| - errorToLine[error] = errorInfo.lineInfo; |
| + if (errorFilter(error)) { |
| + errors.add(error); |
| + errorToLine[error] = errorInfo.lineInfo; |
| + } |
| } |
| } |
| // sort errors |