Chromium Code Reviews| 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 /// Summarizes the information produced by the checker. | 5 /// Summarizes the information produced by the checker. |
| 6 library dev_compiler.src.report; | 6 library dev_compiler.src.report; |
| 7 | 7 |
| 8 import 'dart:math' show max; | 8 import 'dart:math' show max; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 /// Flushes errors to the log. Until this is called, errors are buffered. | 28 /// Flushes errors to the log. Until this is called, errors are buffered. |
| 29 void flush() { | 29 void flush() { |
| 30 // TODO(jmesserly): this code was taken from analyzer_cli. | 30 // TODO(jmesserly): this code was taken from analyzer_cli. |
| 31 // sort errors | 31 // sort errors |
| 32 _errors.sort((AnalysisError error1, AnalysisError error2) { | 32 _errors.sort((AnalysisError error1, AnalysisError error2) { |
| 33 // severity | 33 // severity |
| 34 var severity1 = _strongModeErrorSeverity(error1); | 34 var severity1 = _strongModeErrorSeverity(error1); |
| 35 var severity2 = _strongModeErrorSeverity(error2); | 35 var severity2 = _strongModeErrorSeverity(error2); |
| 36 int compare = severity2.compareTo(severity1); | 36 int compare = severity2.compareTo(severity1); |
| 37 if (compare != 0) { | 37 if (compare != 0) return compare; |
| 38 return compare; | 38 |
| 39 } | |
| 40 // path | 39 // path |
| 41 compare = Comparable.compare(error1.source.fullName.toLowerCase(), | 40 compare = Comparable.compare(error1.source.fullName.toLowerCase(), |
| 42 error2.source.fullName.toLowerCase()); | 41 error2.source.fullName.toLowerCase()); |
| 43 if (compare != 0) { | 42 if (compare != 0) return compare; |
| 44 return compare; | 43 |
| 45 } | |
| 46 // offset | 44 // offset |
| 47 return error1.offset - error2.offset; | 45 compare = error1.offset - error2.offset; |
| 46 if (compare != 0) return compare; | |
| 47 | |
| 48 // compare message, in worst case. | |
| 49 return error1.message.compareTo(error2.message); | |
|
vsm
2015/08/28 17:12:31
nice :-)
| |
| 48 }); | 50 }); |
| 49 | 51 |
| 50 _errors.forEach(listener.onError); | 52 _errors.forEach(listener.onError); |
| 51 _errors.clear(); | 53 _errors.clear(); |
| 52 } | 54 } |
| 53 | 55 |
| 54 void onError(AnalysisError error) { | 56 void onError(AnalysisError error) { |
| 55 _errors.add(error); | 57 _errors.add(error); |
| 56 } | 58 } |
| 57 } | 59 } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 | 353 |
| 352 visitMessage(MessageSummary message) { | 354 visitMessage(MessageSummary message) { |
| 353 var kind = message.kind; | 355 var kind = message.kind; |
| 354 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); | 356 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); |
| 355 errorCount[currentPackage].putIfAbsent(kind, () => 0); | 357 errorCount[currentPackage].putIfAbsent(kind, () => 0); |
| 356 errorCount[currentPackage][kind]++; | 358 errorCount[currentPackage][kind]++; |
| 357 totals.putIfAbsent(kind, () => 0); | 359 totals.putIfAbsent(kind, () => 0); |
| 358 totals[kind]++; | 360 totals[kind]++; |
| 359 } | 361 } |
| 360 } | 362 } |
| OLD | NEW |