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 ddc.src.report; | 6 library ddc.src.report; |
7 | 7 |
8 import 'dart:math' show max; | 8 import 'dart:math' show max; |
9 | 9 |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 level, span.message('[from analyzer]: ${message}', color: color)); | 70 level, span.message('[from analyzer]: ${message}', color: color)); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 /// A reporter that gathers all the information in a [GlobalSummary]. | 74 /// A reporter that gathers all the information in a [GlobalSummary]. |
75 class SummaryReporter implements CheckerReporter { | 75 class SummaryReporter implements CheckerReporter { |
76 GlobalSummary result = new GlobalSummary(); | 76 GlobalSummary result = new GlobalSummary(); |
77 LibrarySummary _currentLibrary; | 77 LibrarySummary _currentLibrary; |
78 SourceFile _file; | 78 SourceFile _file; |
79 | 79 |
| 80 clear() { |
| 81 result = new GlobalSummary(); |
| 82 } |
| 83 |
80 void enterLibrary(LibraryInfo lib) { | 84 void enterLibrary(LibraryInfo lib) { |
81 var libKey = '${lib.library.source.uri}'; | 85 var libKey = '${lib.library.source.uri}'; |
82 var libSummary = _currentLibrary = new LibrarySummary(libKey); | 86 var libSummary = _currentLibrary = new LibrarySummary(libKey); |
83 | 87 |
84 var uri = lib.library.source.uri; | 88 var uri = lib.library.source.uri; |
85 if (uri.scheme == 'package') { | 89 if (uri.scheme == 'package') { |
86 var pname = path.split(uri.path)[0]; | 90 var pname = path.split(uri.path)[0]; |
87 result.packages.putIfAbsent(pname, () => new PackageSummary(pname)); | 91 result.packages.putIfAbsent(pname, () => new PackageSummary(pname)); |
88 if (result.packages[pname].libraries[libKey] != null) { | 92 if (result.packages[pname].libraries[libKey] != null) { |
89 print('ERROR: duplicate ${libKey}'); | 93 print('ERROR: duplicate ${libKey}'); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 var kind = message.kind; | 486 var kind = message.kind; |
483 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); | 487 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); |
484 errorCount[currentPackage].putIfAbsent(kind, () => 0); | 488 errorCount[currentPackage].putIfAbsent(kind, () => 0); |
485 errorCount[currentPackage][kind]++; | 489 errorCount[currentPackage][kind]++; |
486 totals.putIfAbsent(kind, () => 0); | 490 totals.putIfAbsent(kind, () => 0); |
487 totals[kind]++; | 491 totals[kind]++; |
488 } | 492 } |
489 } | 493 } |
490 | 494 |
491 /// Returns a [SourceSpan] in [file] for the offsets of [node]. | 495 /// Returns a [SourceSpan] in [file] for the offsets of [node]. |
| 496 // TODO(sigmund): convert to use span information from AST (issue #73) |
492 SourceSpan _spanForNode(SourceFile file, AstNode node) { | 497 SourceSpan _spanForNode(SourceFile file, AstNode node) { |
493 final begin = node is AnnotatedNode | 498 final begin = node is AnnotatedNode |
494 ? node.firstTokenAfterCommentAndMetadata.offset | 499 ? node.firstTokenAfterCommentAndMetadata.offset |
495 : node.offset; | 500 : node.offset; |
496 return file.span(begin, node.end); | 501 return file.span(begin, node.end); |
497 } | 502 } |
OLD | NEW |