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

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

Issue 2256623003: Fix more strong mode errors and warnings. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 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/io.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) 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 /// Generic utility functions. Stuff that should possibly be in core. 5 /// Generic utility functions. Stuff that should possibly be in core.
6 import 'dart:async'; 6 import 'dart:async';
7 import "dart:convert"; 7 import "dart:convert";
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 /// Takes a simple data structure (composed of [Map]s, [Iterable]s, scalar 623 /// Takes a simple data structure (composed of [Map]s, [Iterable]s, scalar
624 /// objects, and [Future]s) and recursively resolves all the [Future]s contained 624 /// objects, and [Future]s) and recursively resolves all the [Future]s contained
625 /// within. 625 /// within.
626 /// 626 ///
627 /// Completes with the fully resolved structure. 627 /// Completes with the fully resolved structure.
628 Future/*<T>*/ awaitObject/*<T>*/(/*=T*/ object) async { 628 Future/*<T>*/ awaitObject/*<T>*/(/*=T*/ object) async {
629 // Unroll nested futures. 629 // Unroll nested futures.
630 if (object is Future) return await awaitObject(await object); 630 if (object is Future) return await awaitObject(await object);
631 631
632 if (object is Iterable) { 632 if (object is Iterable) {
633 // TODO(nweiz): Remove the unnecessary as check when sdk#26965 is fixed. 633 return await Future.wait(object.map(awaitObject)) as List/*=T*/;
634 return await Future.wait((object as Iterable).map(awaitObject))
635 as List/*=T*/;
636 } 634 }
637 635
638 if (object is Map) { 636 if (object is Map) {
639 // TODO(nweiz): Remove the unnecessary as check when sdk#26965 is fixed.
640 var oldMap = object as Map;
641 var newMap = {}; 637 var newMap = {};
642 await Future.wait(oldMap.keys.map((key) async { 638 await Future.wait(object.keys.map((key) async {
643 newMap[key] = await awaitObject(await oldMap[key]); 639 newMap[key] = await awaitObject(await object[key]);
644 })); 640 }));
645 return newMap as Map/*=T*/; 641 return newMap as Map/*=T*/;
646 } 642 }
647 643
648 return object; 644 return object;
649 } 645 }
650 646
651 /// Whether "special" strings such as Unicode characters or color escapes are 647 /// Whether "special" strings such as Unicode characters or color escapes are
652 /// safe to use. 648 /// safe to use.
653 /// 649 ///
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } else { 779 } else {
784 throw new ApplicationException(message); 780 throw new ApplicationException(message);
785 } 781 }
786 } 782 }
787 783
788 /// Throw a [DataException] with [message] to indicate that the command has 784 /// Throw a [DataException] with [message] to indicate that the command has
789 /// failed because of invalid input data. 785 /// failed because of invalid input data.
790 /// 786 ///
791 /// This will report the error and cause pub to exit with [exit_codes.DATA]. 787 /// This will report the error and cause pub to exit with [exit_codes.DATA].
792 void dataError(String message) => throw new DataException(message); 788 void dataError(String message) => throw new DataException(message);
OLDNEW
« no previous file with comments | « lib/src/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698