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

Side by Side Diff: lib/src/report.dart

Issue 1126243004: Summarize only per logging level (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « lib/src/options.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) 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/source.dart' show Source; 10 import 'package:analyzer/src/generated/source.dart' show Source;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void clearLibrary(Uri uri) {} 117 void clearLibrary(Uri uri) {}
118 void clearHtml(Uri uri) {} 118 void clearHtml(Uri uri) {}
119 void clearAll() {} 119 void clearAll() {}
120 } 120 }
121 121
122 /// A reporter that gathers all the information in a [GlobalSummary]. 122 /// A reporter that gathers all the information in a [GlobalSummary].
123 class SummaryReporter implements CheckerReporter { 123 class SummaryReporter implements CheckerReporter {
124 GlobalSummary result = new GlobalSummary(); 124 GlobalSummary result = new GlobalSummary();
125 IndividualSummary _current; 125 IndividualSummary _current;
126 SourceFile _file; 126 SourceFile _file;
127 final Level _level;
128
129 SummaryReporter([this._level = Level.ALL]);
127 130
128 void enterLibrary(Uri uri) { 131 void enterLibrary(Uri uri) {
129 var container; 132 var container;
130 if (uri.scheme == 'package') { 133 if (uri.scheme == 'package') {
131 var pname = path.split(uri.path)[0]; 134 var pname = path.split(uri.path)[0];
132 result.packages.putIfAbsent(pname, () => new PackageSummary(pname)); 135 result.packages.putIfAbsent(pname, () => new PackageSummary(pname));
133 container = result.packages[pname].libraries; 136 container = result.packages[pname].libraries;
134 } else if (uri.scheme == 'dart') { 137 } else if (uri.scheme == 'dart') {
135 container = result.system; 138 container = result.system;
136 } else { 139 } else {
(...skipping 19 matching lines...) Expand all
156 if (_current is LibrarySummary) { 159 if (_current is LibrarySummary) {
157 (_current as LibrarySummary).lines += _file.lines; 160 (_current as LibrarySummary).lines += _file.lines;
158 } 161 }
159 } 162 }
160 163
161 void leaveSource() { 164 void leaveSource() {
162 _file = null; 165 _file = null;
163 } 166 }
164 167
165 void log(Message message) { 168 void log(Message message) {
169 // Only summarize messages per configured logging level
170 if (message.level < _level) return;
166 assert(message is MessageWithSpan || _file != null); 171 assert(message is MessageWithSpan || _file != null);
167 // TODO(sigmund): convert to use span information from AST (issue #73) 172 // TODO(sigmund): convert to use span information from AST (issue #73)
168 final span = message is MessageWithSpan 173 final span = message is MessageWithSpan
169 ? message.span 174 ? message.span
170 : _file.span(message.begin, message.end); 175 : _file.span(message.begin, message.end);
171 _current.messages.add(new MessageSummary('${message.runtimeType}', 176 _current.messages.add(new MessageSummary('${message.runtimeType}',
172 message.level.name.toLowerCase(), span, message.message)); 177 message.level.name.toLowerCase(), span, message.message));
173 } 178 }
174 179
175 void clearLibrary(Uri uri) { 180 void clearLibrary(Uri uri) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 386
382 visitMessage(MessageSummary message) { 387 visitMessage(MessageSummary message) {
383 var kind = message.kind; 388 var kind = message.kind;
384 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); 389 errorCount.putIfAbsent(currentPackage, () => <String, int>{});
385 errorCount[currentPackage].putIfAbsent(kind, () => 0); 390 errorCount[currentPackage].putIfAbsent(kind, () => 0);
386 errorCount[currentPackage][kind]++; 391 errorCount[currentPackage][kind]++;
387 totals.putIfAbsent(kind, () => 0); 392 totals.putIfAbsent(kind, () => 0);
388 totals[kind]++; 393 totals[kind]++;
389 } 394 }
390 } 395 }
OLDNEW
« no previous file with comments | « lib/src/options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698