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

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

Issue 1419953002: Fix the error message widget (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 1 month 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
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/engine.dart' show AnalysisContext; 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 void onError(AnalysisError error) { 132 void onError(AnalysisError error) {
133 // Only summarize messages per configured logging level 133 // Only summarize messages per configured logging level
134 var code = error.errorCode; 134 var code = error.errorCode;
135 if (_severityToLevel[code.errorSeverity] < _level) return; 135 if (_severityToLevel[code.errorSeverity] < _level) return;
136 136
137 var span = _toSpan(_context, error); 137 var span = _toSpan(_context, error);
138 var summary = _getIndividualSummary(error.source.uri); 138 var summary = _getIndividualSummary(error.source.uri);
139 if (summary is LibrarySummary) { 139 if (summary is LibrarySummary) {
140 summary.countSourceLines(_context, error.source); 140 summary.recordSourceLines(error.source.uri, () {
141 // TODO(jmesserly): parsing is serious overkill for this.
142 // Should be cached, but still.
143 // On the other hand, if we are going to parse, we could get a much bett er
144 // source lines of code estimate by excluding things like comments,
145 // blank lines, and closing braces.
146 var unit = _context.parseCompilationUnit(error.source);
147 return unit.lineInfo.getLocation(unit.endToken.end).lineNumber;
148 });
141 } 149 }
142 summary.messages.add(new MessageSummary(errorCodeName(code), 150 summary.messages.add(new MessageSummary(errorCodeName(code),
143 code.errorSeverity.displayName, span, error.message)); 151 code.errorSeverity.displayName, span, error.message));
144 } 152 }
145 153
146 // TODO(jmesserly): fix to not depend on SourceSpan. This will be really slow 154 // TODO(jmesserly): fix to not depend on SourceSpan. This will be really slow
147 // because it will reload source text from disk, for every single message... 155 // because it will reload source text from disk, for every single message...
148 SourceSpanWithContext _toSpan(AnalysisContext context, AnalysisError error) { 156 SourceSpanWithContext _toSpan(AnalysisContext context, AnalysisError error) {
149 var source = error.source; 157 var source = error.source;
150 var lineInfo = context.computeLineInfo(source); 158 var lineInfo = context.computeLineInfo(source);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 361
354 visitMessage(MessageSummary message) { 362 visitMessage(MessageSummary message) {
355 var kind = message.kind; 363 var kind = message.kind;
356 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); 364 errorCount.putIfAbsent(currentPackage, () => <String, int>{});
357 errorCount[currentPackage].putIfAbsent(kind, () => 0); 365 errorCount[currentPackage].putIfAbsent(kind, () => 0);
358 errorCount[currentPackage][kind]++; 366 errorCount[currentPackage][kind]++;
359 totals.putIfAbsent(kind, () => 0); 367 totals.putIfAbsent(kind, () => 0);
360 totals[kind]++; 368 totals[kind]++;
361 } 369 }
362 } 370 }
OLDNEW
« no previous file with comments | « lib/runtime/messages_widget.js ('k') | lib/src/server/server.dart » ('j') | lib/src/summary.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698