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

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

Issue 968483002: Fix reporter (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | 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 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void enterLibrary(LibraryInfo lib) { 80 void enterLibrary(LibraryInfo lib) {
81 var libSummary = _currentLibrary = new LibrarySummary(lib.name); 81 var libKey = '${lib.library.source.uri}';
82 var libSummary = _currentLibrary = new LibrarySummary(libKey);
82 83
83 var uri = lib.library.source.uri; 84 var uri = lib.library.source.uri;
84 if (uri.scheme == 'package') { 85 if (uri.scheme == 'package') {
85 var pname = path.split(uri.path)[0]; 86 var pname = path.split(uri.path)[0];
86 result.packages.putIfAbsent(pname, () => new PackageSummary(pname)); 87 result.packages.putIfAbsent(pname, () => new PackageSummary(pname));
87 if (result.packages[pname].libraries[lib.name] != null) { 88 if (result.packages[pname].libraries[libKey] != null) {
88 print('ERROR: duplicate ${lib.name}'); 89 print('ERROR: duplicate ${libKey}');
89 } 90 }
90 result.packages[pname].libraries[lib.name] = libSummary; 91 result.packages[pname].libraries[libKey] = libSummary;
91 } else if (uri.scheme == 'dart') { 92 } else if (uri.scheme == 'dart') {
92 if (result.system[lib.name] != null) { 93 if (result.system[libKey] != null) {
93 print('ERROR: duplicate ${lib.name}'); 94 print('ERROR: duplicate ${libKey}');
94 } 95 }
95 result.system[lib.name] = libSummary; 96 result.system[libKey] = libSummary;
96 } else { 97 } else {
97 if (result.loose[lib.name] != null) { 98 if (result.loose[libKey] != null) {
98 print('ERROR: duplicate ${lib.name}'); 99 print('ERROR: duplicate ${libKey}');
99 } 100 }
100 result.loose[lib.name] = libSummary; 101 result.loose[libKey] = libSummary;
101 } 102 }
102 } 103 }
103 104
104 void leaveLibrary() { 105 void leaveLibrary() {
105 _currentLibrary = null; 106 _currentLibrary = null;
106 } 107 }
107 108
108 void enterSource(Source source) { 109 void enterSource(Source source) {
109 _file = new SourceFile(source.contents.data, url: source.uri); 110 _file = new SourceFile(source.contents.data, url: source.uri);
110 _currentLibrary.lines += _file.lines; 111 _currentLibrary.lines += _file.lines;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 488 }
488 } 489 }
489 490
490 /// Returns a [SourceSpan] in [file] for the offsets of [node]. 491 /// Returns a [SourceSpan] in [file] for the offsets of [node].
491 SourceSpan _spanForNode(SourceFile file, AstNode node) { 492 SourceSpan _spanForNode(SourceFile file, AstNode node) {
492 final begin = node is AnnotatedNode 493 final begin = node is AnnotatedNode
493 ? node.firstTokenAfterCommentAndMetadata.offset 494 ? node.firstTokenAfterCommentAndMetadata.offset
494 : node.offset; 495 : node.offset;
495 return file.span(begin, node.end); 496 return file.span(begin, node.end);
496 } 497 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698