| Index: sdk/lib/_collection_dev/to_string.dart
|
| diff --git a/sdk/lib/_collection_dev/to_string.dart b/sdk/lib/_collection_dev/to_string.dart
|
| index f90ff183d00bb54d3da95ddb9da78f75d004d8d9..e1ff05d55df99e96e742540ac3099bb3bf35d0a3 100644
|
| --- a/sdk/lib/_collection_dev/to_string.dart
|
| +++ b/sdk/lib/_collection_dev/to_string.dart
|
| @@ -11,50 +11,50 @@ class ToString {
|
| // TODO(jjb): visiting list should be an identityHashSet when it exists
|
|
|
| /**
|
| - * Returns a string representing the specified collection. If the
|
| - * collection is a [List], the returned string looks like this:
|
| + * Returns a string representing the specified iterable. If the
|
| + * iterable is a [List], the returned string looks like this:
|
| * [:'[element0, element1, ... elementN]':]. The value returned by its
|
| * [toString] method is used to represent each element. If the specified
|
| - * collection is not a list, the returned string looks like this:
|
| + * iterable is not a list, the returned string looks like this:
|
| * [:{element0, element1, ... elementN}:]. In other words, the strings
|
| * returned for lists are surrounded by square brackets, while the strings
|
| - * returned for other collections are surrounded by curly braces.
|
| + * returned for other iterables are surrounded by curly braces.
|
| *
|
| - * If the specified collection contains a reference to itself, either
|
| - * directly or indirectly through other collections or maps, the contained
|
| + * If the specified iterable contains a reference to itself, either
|
| + * directly or indirectly through other iterables or maps, the contained
|
| * reference is rendered as [:'[...]':] if it is a list, or [:'{...}':] if
|
| * it is not. This prevents the infinite regress that would otherwise occur.
|
| * So, for example, calling this method on a list whose sole element is a
|
| * reference to itself would return [:'[[...]]':].
|
| *
|
| - * A typical implementation of a collection's [toString] method will
|
| - * simply return the results of this method applied to the collection.
|
| + * A typical implementation of a iterable's [toString] method will
|
| + * simply return the results of this method applied to the iterable.
|
| */
|
| - static String collectionToString(Collection c) {
|
| + static String iterableToString(Iterable i) {
|
| var result = new StringBuffer();
|
| - _emitCollection(c, result, new List());
|
| + _emitValue(i, result, new List());
|
| return result.toString();
|
| }
|
|
|
| /**
|
| - * Appends a string representing the specified collection to the specified
|
| - * string buffer. The string is formatted as per [collectionToString].
|
| + * Appends a string representing the specified iterable to the specified
|
| + * string buffer. The string is formatted as per [iterableToString].
|
| * The [:visiting:] list contains references to all of the enclosing
|
| - * collections and maps (which are currently in the process of being
|
| + * iterables and maps (which are currently in the process of being
|
| * emitted into [:result:]). The [:visiting:] parameter allows this method to
|
| * generate a [:'[...]':] or [:'{...}':] where required. In other words,
|
| - * it allows this method and [_emitMap] to identify recursive collections
|
| + * it allows this method and [_emitMap] to identify recursive iterables
|
| * and maps.
|
| */
|
| - static void _emitCollection(Collection c,
|
| - StringBuffer result,
|
| - List visiting) {
|
| - visiting.add(c);
|
| - bool isList = c is List;
|
| + static void _emitValue(Iterable i,
|
| + StringBuffer result,
|
| + List visiting) {
|
| + visiting.add(i);
|
| + bool isList = i is List;
|
| result.write(isList ? '[' : '{');
|
|
|
| bool first = true;
|
| - for (var e in c) {
|
| + for (var e in i) {
|
| if (!first) {
|
| result.write(', ');
|
| }
|
| @@ -68,8 +68,8 @@ class ToString {
|
|
|
| /**
|
| * Appends a string representing the specified object to the specified
|
| - * string buffer. If the object is a [Collection] or [Map], it is formatted
|
| - * as per [collectionToString] or [mapToString]; otherwise, it is formatted
|
| + * string buffer. If the object is a [iterable] or [Map], it is formatted
|
| + * as per [iterableToString] or [mapToString]; otherwise, it is formatted
|
| * by invoking its own [toString] method.
|
| *
|
| * The [:visiting:] list contains references to all of the enclosing
|
| @@ -80,17 +80,17 @@ class ToString {
|
| * and collections.
|
| */
|
| static void _emitObject(Object o, StringBuffer result, List visiting) {
|
| - if (o is Collection) {
|
| + if (o is Iterable) {
|
| if (_containsRef(visiting, o)) {
|
| result.write(o is List ? '[...]' : '{...}');
|
| } else {
|
| - _emitCollection(o, result, visiting);
|
| + _emitValue(o, result, visiting);
|
| }
|
| } else if (o is Map) {
|
| if (_containsRef(visiting, o)) {
|
| result.write('{...}');
|
| } else {
|
| - _emitMap(o, result, visiting);
|
| + _emitPair(o, result, visiting);
|
| }
|
| } else { // o is neither a collection nor a map
|
| result.write(o);
|
| @@ -101,8 +101,8 @@ class ToString {
|
| * Returns true if the specified collection contains the specified object
|
| * reference.
|
| */
|
| - static _containsRef(Collection c, Object ref) {
|
| - for (var e in c) {
|
| + static _containsRef(Iterable i, Object ref) {
|
| + for (var e in i) {
|
| if (identical(e, ref)) return true;
|
| }
|
| return false;
|
| @@ -126,7 +126,7 @@ class ToString {
|
| */
|
| static String mapToString(Map m) {
|
| var result = new StringBuffer();
|
| - _emitMap(m, result, new List());
|
| + _emitPair(m, result, new List());
|
| return result.toString();
|
| }
|
|
|
| @@ -140,7 +140,7 @@ class ToString {
|
| * it allows this method and [_emitCollection] to identify recursive maps
|
| * and collections.
|
| */
|
| - static void _emitMap(Map m, StringBuffer result, List visiting) {
|
| + static void _emitPair(Map m, StringBuffer result, List visiting) {
|
| visiting.add(m);
|
| result.write('{');
|
|
|
|
|