Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: pkg/analyzer/lib/src/error_formatter.dart

Issue 207693002: Don't print TODOs in Dart based analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/analyzer_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 error_formatter; 5 library error_formatter;
6 6
7 import 'generated/engine.dart'; 7 import 'generated/engine.dart';
8 import 'generated/error.dart'; 8 import 'generated/error.dart';
9 import 'generated/source_io.dart'; 9 import 'generated/source_io.dart';
10 import '../options.dart'; 10 import '../options.dart';
11 11
12 /// Returns `true` if [AnalysisError] should be printed.
13 typedef bool _ErrorFilter(AnalysisError error);
14
15 /// Allows any [AnalysisError].
16 bool _anyError(AnalysisError error) => true;
17
12 /** 18 /**
13 * Helper for formatting [AnalysisError]s. 19 * Helper for formatting [AnalysisError]s.
14 * The two format options are a user consumable format and a machine consumable format. 20 * The two format options are a user consumable format and a machine consumable format.
15 */ 21 */
16 class ErrorFormatter { 22 class ErrorFormatter {
17 StringSink out; 23 final StringSink out;
18 CommandLineOptions options; 24 final CommandLineOptions options;
25 final _ErrorFilter errorFilter;
19 26
20 ErrorFormatter(this.out, this.options); 27 ErrorFormatter(this.out, this.options, [this.errorFilter = _anyError]);
21 28
22 void formatErrors(List<AnalysisErrorInfo> errorInfos) { 29 void formatErrors(List<AnalysisErrorInfo> errorInfos) {
23 var errors = new List<AnalysisError>(); 30 var errors = new List<AnalysisError>();
24 var errorToLine = new Map<AnalysisError, LineInfo>(); 31 var errorToLine = new Map<AnalysisError, LineInfo>();
25 for (AnalysisErrorInfo errorInfo in errorInfos) { 32 for (AnalysisErrorInfo errorInfo in errorInfos) {
26 for (AnalysisError error in errorInfo.errors) { 33 for (AnalysisError error in errorInfo.errors) {
27 errors.add(error); 34 if (errorFilter(error)) {
28 errorToLine[error] = errorInfo.lineInfo; 35 errors.add(error);
36 errorToLine[error] = errorInfo.lineInfo;
37 }
29 } 38 }
30 } 39 }
31 // sort errors 40 // sort errors
32 errors.sort((AnalysisError error1, AnalysisError error2) { 41 errors.sort((AnalysisError error1, AnalysisError error2) {
33 // severity 42 // severity
34 int compare = error2.errorCode.errorSeverity.compareTo(error1.errorCode.er rorSeverity); 43 int compare = error2.errorCode.errorSeverity.compareTo(error1.errorCode.er rorSeverity);
35 if (compare != 0) { 44 if (compare != 0) {
36 return compare; 45 return compare;
37 } 46 }
38 // path 47 // path
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 164 }
156 165
157 static String pluralize(String word, int count) { 166 static String pluralize(String word, int count) {
158 if (count == 1) { 167 if (count == 1) {
159 return word; 168 return word;
160 } else { 169 } else {
161 return word + "s"; 170 return word + "s";
162 } 171 }
163 } 172 }
164 } 173 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/analyzer_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698