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

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: 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 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.
13 bool _anyError(AnalysisError error) => true;
14
12 /** 15 /**
13 * Helper for formatting [AnalysisError]s. 16 * Helper for formatting [AnalysisError]s.
14 * The two format options are a user consumable format and a machine consumable format. 17 * The two format options are a user consumable format and a machine consumable format.
15 */ 18 */
16 class ErrorFormatter { 19 class ErrorFormatter {
17 StringSink out; 20 final StringSink out;
18 CommandLineOptions options; 21 final CommandLineOptions options;
22 final _ErrorFilter errorFilter;
19 23
20 ErrorFormatter(this.out, this.options); 24 ErrorFormatter(this.out, this.options, [this.errorFilter = _anyError]);
21 25
22 void formatErrors(List<AnalysisErrorInfo> errorInfos) { 26 void formatErrors(List<AnalysisErrorInfo> errorInfos) {
23 var errors = new List<AnalysisError>(); 27 var errors = new List<AnalysisError>();
24 var errorToLine = new Map<AnalysisError, LineInfo>(); 28 var errorToLine = new Map<AnalysisError, LineInfo>();
25 for (AnalysisErrorInfo errorInfo in errorInfos) { 29 for (AnalysisErrorInfo errorInfo in errorInfos) {
26 for (AnalysisError error in errorInfo.errors) { 30 for (AnalysisError error in errorInfo.errors) {
27 errors.add(error); 31 if (errorFilter(error)) {
28 errorToLine[error] = errorInfo.lineInfo; 32 errors.add(error);
33 errorToLine[error] = errorInfo.lineInfo;
34 }
29 } 35 }
30 } 36 }
31 // sort errors 37 // sort errors
32 errors.sort((AnalysisError error1, AnalysisError error2) { 38 errors.sort((AnalysisError error1, AnalysisError error2) {
33 // severity 39 // severity
34 int compare = error2.errorCode.errorSeverity.compareTo(error1.errorCode.er rorSeverity); 40 int compare = error2.errorCode.errorSeverity.compareTo(error1.errorCode.er rorSeverity);
35 if (compare != 0) { 41 if (compare != 0) {
36 return compare; 42 return compare;
37 } 43 }
38 // path 44 // path
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 161 }
156 162
157 static String pluralize(String word, int count) { 163 static String pluralize(String word, int count) {
158 if (count == 1) { 164 if (count == 1) {
159 return word; 165 return word;
160 } else { 166 } else {
161 return word + "s"; 167 return word + "s";
162 } 168 }
163 } 169 }
164 } 170 }
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