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

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

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 years, 4 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/refactor.dart ('k') | lib/testing/content_shell_test.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library polymer.src.utils; 5 library polymer.src.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:path/path.dart' show Builder; 8 import 'package:path/path.dart' show Builder;
9 export 'utils_observe.dart' show toCamelCase, toHyphenedName; 9 export 'utils_observe.dart' show toCamelCase, toHyphenedName;
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 print(buf.toString()); 73 print(buf.toString());
74 } 74 }
75 75
76 // Color constants used for generating messages. 76 // Color constants used for generating messages.
77 final String GREEN_COLOR = '\u001b[32m'; 77 final String GREEN_COLOR = '\u001b[32m';
78 final String RED_COLOR = '\u001b[31m'; 78 final String RED_COLOR = '\u001b[31m';
79 final String MAGENTA_COLOR = '\u001b[35m'; 79 final String MAGENTA_COLOR = '\u001b[35m';
80 final String NO_COLOR = '\u001b[0m'; 80 final String NO_COLOR = '\u001b[0m';
81 81
82 /** Find and return the first element in [list] that satisfies [matcher]. */
83 find(List list, bool matcher(elem)) {
84 for (var elem in list) {
85 if (matcher(elem)) return elem;
86 }
87 return null;
88 }
89
90
91 /** A future that waits until all added [Future]s complete. */ 82 /** A future that waits until all added [Future]s complete. */
92 // TODO(sigmund): this should be part of the futures/core libraries. 83 // TODO(sigmund): this should be part of the futures/core libraries.
93 class FutureGroup { 84 class FutureGroup {
94 static const _FINISHED = -1; 85 static const _FINISHED = -1;
95 86
96 int _pending = 0; 87 int _pending = 0;
97 Future _failedTask; 88 Future _failedTask;
98 final Completer<List> _completer = new Completer<List>(); 89 final Completer<List> _completer = new Completer<List>();
99 final List results = []; 90 final List results = [];
100 91
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 230
240 int get current => _next < 0 ? null : _next; 231 int get current => _next < 0 ? null : _next;
241 232
242 bool moveNext() { 233 bool moveNext() {
243 _next++; 234 _next++;
244 return true; 235 return true;
245 } 236 }
246 } 237 }
247 238
248 239
249 // TODO(jmesserly): VM hashCode performance workaround.
250 // https://code.google.com/p/dart/issues/detail?id=5746
251 class Hashable {
252 static int _nextHash = 0;
253 final int hashCode = ++_nextHash;
254 }
255
256
257 /** 240 /**
258 * Asserts that the condition is true, if not throws an [InternalError]. 241 * Asserts that the condition is true, if not throws an [InternalError].
259 * Note: unlike "assert" we want these errors to be always on so we get bug 242 * Note: unlike "assert" we want these errors to be always on so we get bug
260 * reports. 243 * reports.
261 */ 244 */
262 void compilerAssert(bool condition, [String message]) { 245 void compilerAssert(bool condition, [String message]) {
263 if (!condition) throw new InternalError(message); 246 if (!condition) throw new InternalError(message);
264 } 247 }
265 248
266 // TODO(jmesserly): this is a start, but what we might want to instead: catch 249 // TODO(jmesserly): this is a start, but what we might want to instead: catch
(...skipping 11 matching lines...) Expand all
278 if (message != null) { 261 if (message != null) {
279 additionalMessage = '\nInternal message: $message'; 262 additionalMessage = '\nInternal message: $message';
280 } 263 }
281 return "We're sorry, you've just found a compiler bug. " 264 return "We're sorry, you've just found a compiler bug. "
282 'You can report it at:\n' 265 'You can report it at:\n'
283 'https://github.com/dart-lang/web-ui/issues/new\n' 266 'https://github.com/dart-lang/web-ui/issues/new\n'
284 'Thanks in advance for the bug report! It will help us improve Web UI.' 267 'Thanks in advance for the bug report! It will help us improve Web UI.'
285 '$additionalMessage'; 268 '$additionalMessage';
286 } 269 }
287 } 270 }
OLDNEW
« no previous file with comments | « lib/src/refactor.dart ('k') | lib/testing/content_shell_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698