| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer_cli.src.error_formatter; | 5 library analyzer_cli.src.error_formatter; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart'; |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analyzer_cli/src/options.dart'; | 10 import 'package:analyzer_cli/src/options.dart'; |
| 11 | 11 |
| 12 /// Returns the given error's severity. | 12 /// Returns the given error's severity. |
| 13 ProcessedSeverity _identity(AnalysisError error) => | 13 ProcessedSeverity _identity(AnalysisError error) => |
| 14 new ProcessedSeverity(error.errorCode.errorSeverity); | 14 new ProcessedSeverity(error.errorCode.errorSeverity); |
| 15 | 15 |
| 16 String _pluralize(String word, int count) => count == 1 ? word : word + "s"; | 16 String _pluralize(String word, int count) => count == 1 ? word : word + "s"; |
| 17 | 17 |
| 18 /// Returns desired severity for the given [error] (or `null` if it's to be | 18 /// Returns desired severity for the given [error] (or `null` if it's to be |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 // [warning] 'foo' is not a... (/Users/.../tmp/foo.dart, line 1, col 2) | 167 // [warning] 'foo' is not a... (/Users/.../tmp/foo.dart, line 1, col 2) |
| 168 out.write('[$errorType] ${error.message} '); | 168 out.write('[$errorType] ${error.message} '); |
| 169 out.write('(${source.fullName}'); | 169 out.write('(${source.fullName}'); |
| 170 out.write(', line ${location.lineNumber}, col ${location.columnNumber})'); | 170 out.write(', line ${location.lineNumber}, col ${location.columnNumber})'); |
| 171 } | 171 } |
| 172 out.writeln(); | 172 out.writeln(); |
| 173 } | 173 } |
| 174 |
| 174 void formatErrors(List<AnalysisErrorInfo> errorInfos) { | 175 void formatErrors(List<AnalysisErrorInfo> errorInfos) { |
| 175 stats.unfilteredCount += errorInfos.length; | 176 stats.unfilteredCount += errorInfos.length; |
| 176 | 177 |
| 177 var errors = new List<AnalysisError>(); | 178 var errors = new List<AnalysisError>(); |
| 178 var errorToLine = new Map<AnalysisError, LineInfo>(); | 179 var errorToLine = new Map<AnalysisError, LineInfo>(); |
| 179 for (AnalysisErrorInfo errorInfo in errorInfos) { | 180 for (AnalysisErrorInfo errorInfo in errorInfos) { |
| 180 for (AnalysisError error in errorInfo.errors) { | 181 for (AnalysisError error in errorInfo.errors) { |
| 181 if (computeSeverity(error) != null) { | 182 if (computeSeverity(error) != null) { |
| 182 errors.add(error); | 183 errors.add(error); |
| 183 errorToLine[error] = errorInfo.lineInfo; | 184 errorToLine[error] = errorInfo.lineInfo; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return result.toString(); | 237 return result.toString(); |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 | 240 |
| 240 /// A severity with awareness of whether it was overridden by a processor. | 241 /// A severity with awareness of whether it was overridden by a processor. |
| 241 class ProcessedSeverity { | 242 class ProcessedSeverity { |
| 242 ErrorSeverity severity; | 243 ErrorSeverity severity; |
| 243 bool overridden; | 244 bool overridden; |
| 244 ProcessedSeverity(this.severity, [this.overridden = false]); | 245 ProcessedSeverity(this.severity, [this.overridden = false]); |
| 245 } | 246 } |
| OLD | NEW |