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

Side by Side Diff: lib/messages/messages.dart

Issue 1830403002: switch package to strong mode (Closed) Base URL: git@github.com:dart-lang/code_transformers.git@master
Patch Set: Created 4 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 | « lib/messages/build_logger.dart ('k') | lib/src/async_benchmark_base.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Defines messages templates and an adapter for TransformLogger to be able 5 /// Defines messages templates and an adapter for TransformLogger to be able
6 /// report error messages from transformers and refer to them in a consistent 6 /// report error messages from transformers and refer to them in a consistent
7 /// manner long term. 7 /// manner long term.
8 library code_transformers.messages; 8 library code_transformers.messages;
9 9
10 // Note: this library purposely doesn't depend on dart:io, dart:html, or barback 10 // Note: this library purposely doesn't depend on dart:io, dart:html, or barback
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 'url': span.end.sourceUrl.toString(), 177 'url': span.end.sourceUrl.toString(),
178 'offset': span.end.offset, 178 'offset': span.end.offset,
179 'line': span.end.line, 179 'line': span.end.line,
180 'column': span.end.column, 180 'column': span.end.column,
181 }, 181 },
182 'text': span.text, 182 'text': span.text,
183 }; 183 };
184 } 184 }
185 return data; 185 return data;
186 } 186 }
187
187 String toString() => '${toJson()}'; 188 String toString() => '${toJson()}';
188 } 189 }
189 190
190 /// A table of entries, that clusters error messages by id. 191 /// A table of entries, that clusters error messages by id.
191 class LogEntryTable { 192 class LogEntryTable {
192 final Map<MessageId, List<BuildLogEntry>> entries; 193 final Map<MessageId, List<BuildLogEntry>> entries;
193 194
194 LogEntryTable() : entries = new LinkedHashMap(); 195 LogEntryTable() : entries = new LinkedHashMap();
195 196
196 /// Creates a new [LogEntryTable] from an encoded value produced via [toJson]. 197 /// Creates a new [LogEntryTable] from an encoded value produced via [toJson].
197 factory LogEntryTable.fromJson(Map json) { 198 factory LogEntryTable.fromJson(Map json) {
198 var res = new LogEntryTable(); 199 var res = new LogEntryTable();
199 for (String key in json.keys) { 200 for (String key in json.keys) {
200 var id = new MessageId.fromJson(key); 201 var id = new MessageId.fromJson(key);
201 res.entries[id] = 202 res.entries[id] = (json[key] as Iterable)
202 json[key].map((v) => new BuildLogEntry.fromJson(v)).toList(); 203 .map((v) => new BuildLogEntry.fromJson(v))
204 .toList();
203 } 205 }
204 return res; 206 return res;
205 } 207 }
206 208
207 /// Serializes this entire table as JSON. 209 /// Serializes this entire table as JSON.
208 Map toJson() { 210 Map toJson() {
209 var res = {}; 211 var res = {};
210 entries.forEach((key, value) { 212 entries.forEach((key, value) {
211 res['$key'] = value.map((e) => e.toJson()).toList(); 213 res['$key'] = value.map((e) => e.toJson()).toList();
212 }); 214 });
213 return res; 215 return res;
214 } 216 }
217
215 String toString() => '${toJson()}'; 218 String toString() => '${toJson()}';
216 219
217 void add(BuildLogEntry entry) { 220 void add(BuildLogEntry entry) {
218 entries.putIfAbsent(entry.message.id, () => []).add(entry); 221 entries.putIfAbsent(entry.message.id, () => []).add(entry);
219 } 222 }
223
220 void addAll(LogEntryTable other) { 224 void addAll(LogEntryTable other) {
221 for (var key in other.entries.keys) { 225 for (var key in other.entries.keys) {
222 var values = entries.putIfAbsent(key, () => []); 226 var values = entries.putIfAbsent(key, () => []);
223 values.addAll(other.entries[key]); 227 values.addAll(other.entries[key]);
224 } 228 }
225 } 229 }
226 } 230 }
OLDNEW
« no previous file with comments | « lib/messages/build_logger.dart ('k') | lib/src/async_benchmark_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698