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

Side by Side Diff: test/dart_codegen/expect/collection/iterable.dart

Issue 959073002: Fix new line breaks on } (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
OLDNEW
1 part of dart.collection; 1 part of dart.collection;
2 abstract class IterableMixin<E> implements Iterable<E> {Iterable map(f(E elemen t)) => new MappedIterable<E, dynamic>(this, f); 2 abstract class IterableMixin<E> implements Iterable<E> {Iterable map(f(E elemen t)) => new MappedIterable<E, dynamic>(this, f);
3 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); 3 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f);
4 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f); 4 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f);
5 bool contains(Object element) { 5 bool contains(Object element) {
6 for (E e in this) { 6 for (E e in this) {
7 if (e == element) return true; 7 if (e == element) return true;
8 } 8 }
9 return false; 9 return false;
10 } 10 }
(...skipping 21 matching lines...) Expand all
32 if (!f(element)) return false; 32 if (!f(element)) return false;
33 } 33 }
34 return true; 34 return true;
35 } 35 }
36 String join([String separator = ""]) { 36 String join([String separator = ""]) {
37 Iterator<E> iterator = this.iterator; 37 Iterator<E> iterator = this.iterator;
38 if (!iterator.moveNext()) return ""; 38 if (!iterator.moveNext()) return "";
39 StringBuffer buffer = new StringBuffer(); 39 StringBuffer buffer = new StringBuffer();
40 if (separator == null || separator == "") { 40 if (separator == null || separator == "") {
41 do { 41 do {
42 buffer.write("${iterator.current} 42 buffer.write("${iterator.current}");
43 "); 43 }
44 while (iterator.moveNext());}
45 else {
46 buffer.write("${iterator.current}");
47 while (iterator.moveNext()) {
48 buffer.write(separator);
49 buffer.write("${iterator.current}");
50 }
44 } 51 }
45 while (iterator.moveNext());} 52 return buffer.toString();
46 else { 53 }
47 buffer.write("${iterator.current}
48 ");
49 while (iterator.moveNext()) {
50 buffer.write(separator);
51 buffer.write("${iterator.current}
52 ");
53 }
54 }
55 return buffer.toString();
56 }
57 bool any(bool f(E element)) { 54 bool any(bool f(E element)) {
58 for (E element in this) { 55 for (E element in this) {
59 if (f(element)) return true; 56 if (f(element)) return true;
60 } 57 }
61 return false; 58 return false;
62 } 59 }
63 List<E> toList({ 60 List<E> toList({
64 bool growable : true} 61 bool growable : true}
65 ) => new List<E>.from(this, growable: growable); 62 ) => new List<E>.from(this, growable: growable);
66 Set<E> toSet() => new Set<E>.from(this); 63 Set<E> toSet() => new Set<E>.from(this);
67 int get length { 64 int get length {
68 assert (this is! EfficientLength); int count = 0; 65 assert (this is! EfficientLength); int count = 0;
69 Iterator it = iterator; 66 Iterator it = iterator;
70 while (it.moveNext()) { 67 while (it.moveNext()) {
71 count++; 68 count++;
72 } 69 }
73 return count; 70 return count;
74 } 71 }
75 bool get isEmpty => !iterator.moveNext(); 72 bool get isEmpty => !iterator.moveNext();
76 bool get isNotEmpty => !isEmpty; 73 bool get isNotEmpty => !isEmpty;
77 Iterable<E> take(int n) { 74 Iterable<E> take(int n) {
78 return new TakeIterable<E>(this, n); 75 return new TakeIterable<E>(this, n);
79 } 76 }
80 Iterable<E> takeWhile(bool test(E value)) { 77 Iterable<E> takeWhile(bool test(E value)) {
81 return new TakeWhileIterable<E>(this, test); 78 return new TakeWhileIterable<E>(this, test);
82 } 79 }
83 Iterable<E> skip(int n) { 80 Iterable<E> skip(int n) {
84 return new SkipIterable<E>(this, n); 81 return new SkipIterable<E>(this, n);
85 } 82 }
86 Iterable<E> skipWhile(bool test(E value)) { 83 Iterable<E> skipWhile(bool test(E value)) {
87 return new SkipWhileIterable<E>(this, test); 84 return new SkipWhileIterable<E>(this, test);
88 } 85 }
89 E get first { 86 E get first {
90 Iterator it = iterator; 87 Iterator it = iterator;
91 if (!it.moveNext()) { 88 if (!it.moveNext()) {
92 throw IterableElementError.noElement(); 89 throw IterableElementError.noElement();
93 } 90 }
94 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 127, column 1 2 of dart:collection/iterable.dart: """, it.current is E, false); 91 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 127, column 12 of dart:collection/iterable.dart: """, it.current is E, false);
95 } 92 }
96 E get last { 93 E get last {
97 Iterator it = iterator; 94 Iterator it = iterator;
98 if (!it.moveNext()) { 95 if (!it.moveNext()) {
99 throw IterableElementError.noElement(); 96 throw IterableElementError.noElement();
100 } 97 }
101 E result; 98 E result;
102 do { 99 do {
103 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 137, column 16 of dart:collection/iterable.dart: """, it.current is E, false); 100 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 137, col umn 16 of dart:collection/iterable.dart: """, it.current is E, false);
104 } 101 }
105 while (it.moveNext()); return result; 102 while (it.moveNext()); return result;
106 } 103 }
107 E get single { 104 E get single {
108 Iterator it = iterator; 105 Iterator it = iterator;
109 if (!it.moveNext()) throw IterableElementError.noElement(); 106 if (!it.moveNext()) throw IterableElementError.noElement();
110 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 145, colu mn 16 of dart:collection/iterable.dart: """, it.current is E, false); 107 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 145, co lumn 16 of dart:collection/iterable.dart: """, it.current is E, false);
111 if (it.moveNext()) throw IterableElementError.tooMany(); 108 if (it.moveNext()) throw IterableElementError.tooMany();
112 return result; 109 return result;
113 } 110 }
114 E firstWhere(bool test(E value), { 111 E firstWhere(bool test(E value), {
115 E orElse()} 112 E orElse()}
116 ) { 113 ) {
117 for (E element in this) { 114 for (E element in this) {
118 if (test(element)) return element; 115 if (test(element)) return element;
119 } 116 }
120 if (orElse != null) return orElse(); 117 if (orElse != null) return orElse();
121 throw IterableElementError.noElement(); 118 throw IterableElementError.noElement();
122 } 119 }
123 E lastWhere(bool test(E value), { 120 E lastWhere(bool test(E value), {
124 E orElse()} 121 E orElse()}
125 ) { 122 ) {
126 E result = ((__x0) => DDC$RT.cast(__x0, Null, E, "CastLiteral", """line 159, col umn 16 of dart:collection/iterable.dart: """, __x0 is E, false))(null); 123 E result = ((__x0) => DDC$RT.cast(__x0, Null, E, "CastLiteral", """line 159, c olumn 16 of dart:collection/iterable.dart: """, __x0 is E, false))(null);
127 bool foundMatching = false; 124 bool foundMatching = false;
128 for (E element in this) { 125 for (E element in this) {
129 if (test(element)) { 126 if (test(element)) {
130 result = element; 127 result = element;
131 foundMatching = true; 128 foundMatching = true;
132 } 129 }
133 } 130 }
134 if (foundMatching) return result; 131 if (foundMatching) return result;
135 if (orElse != null) return orElse(); 132 if (orElse != null) return orElse();
136 throw IterableElementError.noElement(); 133 throw IterableElementError.noElement();
137 } 134 }
138 E singleWhere(bool test(E value)) { 135 E singleWhere(bool test(E value)) {
139 E result = ((__x1) => DDC$RT.cast(__x1, Null, E, "CastLiteral", """line 173, col umn 16 of dart:collection/iterable.dart: """, __x1 is E, false))(null); 136 E result = ((__x1) => DDC$RT.cast(__x1, Null, E, "CastLiteral", """line 173, c olumn 16 of dart:collection/iterable.dart: """, __x1 is E, false))(null);
140 bool foundMatching = false; 137 bool foundMatching = false;
141 for (E element in this) { 138 for (E element in this) {
142 if (test(element)) { 139 if (test(element)) {
143 if (foundMatching) { 140 if (foundMatching) {
144 throw IterableElementError.tooMany(); 141 throw IterableElementError.tooMany();
142 }
143 result = element;
144 foundMatching = true;
145 }
146 }
147 if (foundMatching) return result;
148 throw IterableElementError.noElement();
145 } 149 }
146 result = element;
147 foundMatching = true;
148 }
149 }
150 if (foundMatching) return result;
151 throw IterableElementError.noElement();
152 }
153 E elementAt(int index) { 150 E elementAt(int index) {
154 if (index is! int) throw new ArgumentError.notNull("index"); 151 if (index is! int) throw new ArgumentError.notNull("index");
155 RangeError.checkNotNegative(index, "index"); 152 RangeError.checkNotNegative(index, "index");
156 int elementIndex = 0; 153 int elementIndex = 0;
157 for (E element in this) { 154 for (E element in this) {
158 if (index == elementIndex) return element; 155 if (index == elementIndex) return element;
159 elementIndex++; 156 elementIndex++;
160 } 157 }
161 throw new RangeError.index(index, this, "index", null, elementIndex); 158 throw new RangeError.index(index, this, "index", null, elementIndex);
162 } 159 }
163 String toString() => IterableBase.iterableToShortString(this, '(', ')'); 160 String toString() => IterableBase.iterableToShortString(this, '(', ')');
164 } 161 }
165 abstract class IterableBase<E> implements Iterable<E> {const IterableBase(); 162 abstract class IterableBase<E> implements Iterable<E> {const IterableBase();
166 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f); 163 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f);
167 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); 164 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f);
168 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f); 165 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f);
169 bool contains(Object element) { 166 bool contains(Object element) {
170 for (E e in this) { 167 for (E e in this) {
171 if (e == element) return true; 168 if (e == element) return true;
172 } 169 }
173 return false; 170 return false;
174 } 171 }
175 void forEach(void f(E element)) { 172 void forEach(void f(E element)) {
176 for (E element in this) f(element); 173 for (E element in this) f(element);
177 } 174 }
178 E reduce(E combine(E value, E element)) { 175 E reduce(E combine(E value, E element)) {
179 Iterator<E> iterator = this.iterator; 176 Iterator<E> iterator = this.iterator;
180 if (!iterator.moveNext()) { 177 if (!iterator.moveNext()) {
181 throw IterableElementError.noElement(); 178 throw IterableElementError.noElement();
182 } 179 }
183 E value = iterator.current; 180 E value = iterator.current;
184 while (iterator.moveNext()) { 181 while (iterator.moveNext()) {
185 value = combine(value, iterator.current); 182 value = combine(value, iterator.current);
186 } 183 }
187 return value; 184 return value;
188 } 185 }
189 dynamic fold(var initialValue, dynamic combine(var previousValue, E element)) { 186 dynamic fold(var initialValue, dynamic combine(var previousValue, E element)) {
190 var value = initialValue; 187 var value = initialValue;
191 for (E element in this) value = combine(value, element); 188 for (E element in this) value = combine(value, element);
192 return value; 189 return value;
193 } 190 }
194 bool every(bool f(E element)) { 191 bool every(bool f(E element)) {
195 for (E element in this) { 192 for (E element in this) {
196 if (!f(element)) return false; 193 if (!f(element)) return false;
197 } 194 }
198 return true; 195 return true;
199 } 196 }
200 String join([String separator = ""]) { 197 String join([String separator = ""]) {
201 Iterator<E> iterator = this.iterator; 198 Iterator<E> iterator = this.iterator;
202 if (!iterator.moveNext()) return ""; 199 if (!iterator.moveNext()) return "";
203 StringBuffer buffer = new StringBuffer(); 200 StringBuffer buffer = new StringBuffer();
204 if (separator == null || separator == "") { 201 if (separator == null || separator == "") {
205 do { 202 do {
206 buffer.write("${iterator.current} 203 buffer.write("${iterator.current}");
207 "); 204 }
208 } 205 while (iterator.moveNext());}
209 while (iterator.moveNext());}
210 else { 206 else {
211 buffer.write("${iterator.current} 207 buffer.write("${iterator.current}");
212 "); 208 while (iterator.moveNext()) {
213 while (iterator.moveNext()) { 209 buffer.write(separator);
214 buffer.write(separator); 210 buffer.write("${iterator.current}");
215 buffer.write("${iterator.current} 211 }
216 "); 212 }
217 }
218 }
219 return buffer.toString(); 213 return buffer.toString();
220 } 214 }
221 bool any(bool f(E element)) { 215 bool any(bool f(E element)) {
222 for (E element in this) { 216 for (E element in this) {
223 if (f(element)) return true; 217 if (f(element)) return true;
224 } 218 }
225 return false; 219 return false;
226 } 220 }
227 List<E> toList({ 221 List<E> toList({
228 bool growable : true} 222 bool growable : true}
229 ) => new List<E>.from(this, growable: growable); 223 ) => new List<E>.from(this, growable: growable);
230 Set<E> toSet() => new Set<E>.from(this); 224 Set<E> toSet() => new Set<E>.from(this);
231 int get length { 225 int get length {
232 assert (this is! EfficientLength); int count = 0; 226 assert (this is! EfficientLength); int count = 0;
233 Iterator it = iterator; 227 Iterator it = iterator;
234 while (it.moveNext()) { 228 while (it.moveNext()) {
235 count++; 229 count++;
236 } 230 }
237 return count; 231 return count;
238 } 232 }
239 bool get isEmpty => !iterator.moveNext(); 233 bool get isEmpty => !iterator.moveNext();
240 bool get isNotEmpty => !isEmpty; 234 bool get isNotEmpty => !isEmpty;
241 Iterable<E> take(int n) { 235 Iterable<E> take(int n) {
242 return new TakeIterable<E>(this, n); 236 return new TakeIterable<E>(this, n);
243 } 237 }
244 Iterable<E> takeWhile(bool test(E value)) { 238 Iterable<E> takeWhile(bool test(E value)) {
245 return new TakeWhileIterable<E>(this, test); 239 return new TakeWhileIterable<E>(this, test);
246 } 240 }
247 Iterable<E> skip(int n) { 241 Iterable<E> skip(int n) {
248 return new SkipIterable<E>(this, n); 242 return new SkipIterable<E>(this, n);
249 } 243 }
250 Iterable<E> skipWhile(bool test(E value)) { 244 Iterable<E> skipWhile(bool test(E value)) {
251 return new SkipWhileIterable<E>(this, test); 245 return new SkipWhileIterable<E>(this, test);
252 } 246 }
253 E get first { 247 E get first {
254 Iterator it = iterator; 248 Iterator it = iterator;
255 if (!it.moveNext()) { 249 if (!it.moveNext()) {
256 throw IterableElementError.noElement(); 250 throw IterableElementError.noElement();
257 } 251 }
258 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 323, column 1 2 of dart:collection/iterable.dart: """, it.current is E, false); 252 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 323, column 1 2 of dart:collection/iterable.dart: """, it.current is E, false);
259 } 253 }
260 E get last { 254 E get last {
261 Iterator it = iterator; 255 Iterator it = iterator;
262 if (!it.moveNext()) { 256 if (!it.moveNext()) {
263 throw IterableElementError.noElement(); 257 throw IterableElementError.noElement();
264 } 258 }
265 E result; 259 E result;
266 do { 260 do {
267 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 333, column 16 of dart:collection/iterable.dart: """, it.current is E, false); 261 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 333, colum n 16 of dart:collection/iterable.dart: """, it.current is E, false);
268 } 262 }
269 while (it.moveNext()); return result; 263 while (it.moveNext()); return result;
270 } 264 }
271 E get single { 265 E get single {
272 Iterator it = iterator; 266 Iterator it = iterator;
273 if (!it.moveNext()) throw IterableElementError.noElement(); 267 if (!it.moveNext()) throw IterableElementError.noElement();
274 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 341, colu mn 16 of dart:collection/iterable.dart: """, it.current is E, false); 268 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 341, colu mn 16 of dart:collection/iterable.dart: """, it.current is E, false);
275 if (it.moveNext()) throw IterableElementError.tooMany(); 269 if (it.moveNext()) throw IterableElementError.tooMany();
276 return result; 270 return result;
277 } 271 }
278 E firstWhere(bool test(E value), { 272 E firstWhere(bool test(E value), {
279 E orElse()} 273 E orElse()}
280 ) { 274 ) {
281 for (E element in this) { 275 for (E element in this) {
282 if (test(element)) return element; 276 if (test(element)) return element;
283 } 277 }
284 if (orElse != null) return orElse(); 278 if (orElse != null) return orElse();
285 throw IterableElementError.noElement(); 279 throw IterableElementError.noElement();
286 } 280 }
287 E lastWhere(bool test(E value), { 281 E lastWhere(bool test(E value), {
288 E orElse()} 282 E orElse()}
289 ) { 283 ) {
290 E result = ((__x2) => DDC$RT.cast(__x2, Null, E, "CastLiteral", """line 355, col umn 16 of dart:collection/iterable.dart: """, __x2 is E, false))(null); 284 E result = ((__x2) => DDC$RT.cast(__x2, Null, E, "CastLiteral", """line 355, col umn 16 of dart:collection/iterable.dart: """, __x2 is E, false))(null);
291 bool foundMatching = false; 285 bool foundMatching = false;
292 for (E element in this) { 286 for (E element in this) {
293 if (test(element)) { 287 if (test(element)) {
294 result = element; 288 result = element;
295 foundMatching = true; 289 foundMatching = true;
296 } 290 }
297 } 291 }
298 if (foundMatching) return result; 292 if (foundMatching) return result;
299 if (orElse != null) return orElse(); 293 if (orElse != null) return orElse();
300 throw IterableElementError.noElement(); 294 throw IterableElementError.noElement();
301 } 295 }
302 E singleWhere(bool test(E value)) { 296 E singleWhere(bool test(E value)) {
303 E result = ((__x3) => DDC$RT.cast(__x3, Null, E, "CastLiteral", """line 369, col umn 16 of dart:collection/iterable.dart: """, __x3 is E, false))(null); 297 E result = ((__x3) => DDC$RT.cast(__x3, Null, E, "CastLiteral", """line 369, col umn 16 of dart:collection/iterable.dart: """, __x3 is E, false))(null);
304 bool foundMatching = false; 298 bool foundMatching = false;
305 for (E element in this) { 299 for (E element in this) {
306 if (test(element)) { 300 if (test(element)) {
307 if (foundMatching) { 301 if (foundMatching) {
308 throw IterableElementError.tooMany(); 302 throw IterableElementError.tooMany();
309 } 303 }
310 result = element; 304 result = element;
311 foundMatching = true; 305 foundMatching = true;
312 } 306 }
313 } 307 }
314 if (foundMatching) return result; 308 if (foundMatching) return result;
315 throw IterableElementError.noElement(); 309 throw IterableElementError.noElement();
316 } 310 }
317 E elementAt(int index) { 311 E elementAt(int index) {
318 if (index is! int) throw new ArgumentError.notNull("index"); 312 if (index is! int) throw new ArgumentError.notNull("index");
319 RangeError.checkNotNegative(index, "index"); 313 RangeError.checkNotNegative(index, "index");
320 int elementIndex = 0; 314 int elementIndex = 0;
321 for (E element in this) { 315 for (E element in this) {
322 if (index == elementIndex) return element; 316 if (index == elementIndex) return element;
323 elementIndex++; 317 elementIndex++;
324 } 318 }
325 throw new RangeError.index(index, this, "index", null, elementIndex); 319 throw new RangeError.index(index, this, "index", null, elementIndex);
326 } 320 }
327 String toString() => iterableToShortString(this, '(', ')'); 321 String toString() => iterableToShortString(this, '(', ')');
328 static String iterableToShortString(Iterable iterable, [String leftDelimiter = '(', String rightDelimiter = ')']) { 322 static String iterableToShortString(Iterable iterable, [String leftDelimiter = '(', String rightDelimiter = ')']) {
329 if (_isToStringVisiting(iterable)) { 323 if (_isToStringVisiting(iterable)) {
330 if (leftDelimiter == "(" && rightDelimiter == ")") { 324 if (leftDelimiter == "(" && rightDelimiter == ")") {
331 return "(...)"; 325 return "(...)";
332 } 326 }
333 return "$leftDelimiter...$rightDelimiter"; 327 return "$leftDelimiter...$rightDelimiter";
334 } 328 }
335 List parts = []; 329 List parts = [];
336 _toStringVisiting.add(iterable); 330 _toStringVisiting.add(iterable);
337 try { 331 try {
338 _iterablePartsToStrings(iterable, parts); 332 _iterablePartsToStrings(iterable, parts);
339 } 333 }
340 finally { 334 finally {
341 assert (identical(_toStringVisiting.last, iterable)); _toStringVisiting.removeLa st(); 335 assert (identical(_toStringVisiting.last, iterable)); _toStringVisiting.remove Last();
342 } 336 }
343 return (new StringBuffer(leftDelimiter)..writeAll(parts, ", ")..write(rightDeli miter)).toString(); 337 return (new StringBuffer(leftDelimiter)..writeAll(parts, ", ")..write(rightDeli miter)).toString();
344 } 338 }
345 static String iterableToFullString(Iterable iterable, [String leftDelimiter = ' (', String rightDelimiter = ')']) { 339 static String iterableToFullString(Iterable iterable, [String leftDelimiter = ' (', String rightDelimiter = ')']) {
346 if (_isToStringVisiting(iterable)) { 340 if (_isToStringVisiting(iterable)) {
347 return "$leftDelimiter...$rightDelimiter"; 341 return "$leftDelimiter...$rightDelimiter";
348 } 342 }
349 StringBuffer buffer = new StringBuffer(leftDelimiter); 343 StringBuffer buffer = new StringBuffer(leftDelimiter);
350 _toStringVisiting.add(iterable); 344 _toStringVisiting.add(iterable);
351 try { 345 try {
352 buffer.writeAll(iterable, ", "); 346 buffer.writeAll(iterable, ", ");
353 } 347 }
354 finally { 348 finally {
355 assert (identical(_toStringVisiting.last, iterable)); _toStringVisiting.removeLa st(); 349 assert (identical(_toStringVisiting.last, iterable)); _toStringVisiting.remove Last();
356 } 350 }
357 buffer.write(rightDelimiter); 351 buffer.write(rightDelimiter);
358 return buffer.toString(); 352 return buffer.toString();
359 } 353 }
360 static final List _toStringVisiting = []; 354 static final List _toStringVisiting = [];
361 static bool _isToStringVisiting(Object o) { 355 static bool _isToStringVisiting(Object o) {
362 for (int i = 0; 356 for (int i = 0; i < _toStringVisiting.length; i++) {
363 i < _toStringVisiting.length; 357 if (identical(o, _toStringVisiting[i])) return true;
364 i++) { 358 }
365 if (identical(o, _toStringVisiting[i])) return true;
366 }
367 return false; 359 return false;
368 } 360 }
369 static void _iterablePartsToStrings(Iterable iterable, List parts) { 361 static void _iterablePartsToStrings(Iterable iterable, List parts) {
370 const int LENGTH_LIMIT = 80; 362 const int LENGTH_LIMIT = 80;
371 const int HEAD_COUNT = 3; 363 const int HEAD_COUNT = 3;
372 const int TAIL_COUNT = 2; 364 const int TAIL_COUNT = 2;
373 const int MAX_COUNT = 100; 365 const int MAX_COUNT = 100;
374 const int OVERHEAD = 2; 366 const int OVERHEAD = 2;
375 const int ELLIPSIS_SIZE = 3; 367 const int ELLIPSIS_SIZE = 3;
376 int length = 0; 368 int length = 0;
377 int count = 0; 369 int count = 0;
378 Iterator it = iterable.iterator; 370 Iterator it = iterable.iterator;
379 while (length < LENGTH_LIMIT || count < HEAD_COUNT) { 371 while (length < LENGTH_LIMIT || count < HEAD_COUNT) {
380 if (!it.moveNext()) return; String next = "${it.current} 372 if (!it.moveNext()) return; String next = "${it.current}";
381 "; 373 parts.add(next);
382 parts.add(next); 374 length += next.length + OVERHEAD;
383 length += next.length + OVERHEAD; 375 count++;
384 count++; 376 }
385 }
386 String penultimateString; 377 String penultimateString;
387 String ultimateString; 378 String ultimateString;
388 var penultimate = null; 379 var penultimate = null;
389 var ultimate = null; 380 var ultimate = null;
390 if (!it.moveNext()) { 381 if (!it.moveNext()) {
391 if (count <= HEAD_COUNT + TAIL_COUNT) return; ultimateString = ((__x4) => DDC$RT .cast(__x4, dynamic, String, "CastGeneral", """line 530, column 24 of dart:colle ction/iterable.dart: """, __x4 is String, true))(parts.removeLast()); 382 if (count <= HEAD_COUNT + TAIL_COUNT) return; ultimateString = ((__x4) => DDC$ RT.cast(__x4, dynamic, String, "CastGeneral", """line 530, column 24 of dart:col lection/iterable.dart: """, __x4 is String, true))(parts.removeLast());
392 penultimateString = ((__x5) => DDC$RT.cast(__x5, dynamic, String, "CastGeneral" , """line 531, column 27 of dart:collection/iterable.dart: """, __x5 is String, true))(parts.removeLast()); 383 penultimateString = ((__x5) => DDC$RT.cast(__x5, dynamic, String, "CastGenera l", """line 531, column 27 of dart:collection/iterable.dart: """, __x5 is String , true))(parts.removeLast());
393 } 384 }
394 else { 385 else {
395 penultimate = it.current; 386 penultimate = it.current;
396 count++; 387 count++;
397 if (!it.moveNext()) { 388 if (!it.moveNext()) {
398 if (count <= HEAD_COUNT + 1) { 389 if (count <= HEAD_COUNT + 1) {
399 parts.add("$penultimate"); 390 parts.add("$penultimate");
400 return;} 391 return;}
401 ultimateString = "$penultimate"; 392 ultimateString = "$penultimate";
402 penultimateString = ((__x6) => DDC$RT.cast(__x6, dynamic, String, "CastGeneral" , """line 541, column 29 of dart:collection/iterable.dart: """, __x6 is String, true))(parts.removeLast()); 393 penultimateString = ((__x6) => DDC$RT.cast(__x6, dynamic, String, "CastGene ral", """line 541, column 29 of dart:collection/iterable.dart: """, __x6 is Stri ng, true))(parts.removeLast());
403 length += ultimateString.length + OVERHEAD; 394 length += ultimateString.length + OVERHEAD;
404 } 395 }
405 else { 396 else {
406 ultimate = it.current; 397 ultimate = it.current;
407 count++; 398 count++;
408 assert (count < MAX_COUNT); while (it.moveNext()) { 399 assert (count < MAX_COUNT); while (it.moveNext()) {
409 penultimate = ultimate; 400 penultimate = ultimate;
410 ultimate = it.current; 401 ultimate = it.current;
411 count++; 402 count++;
412 if (count > MAX_COUNT) { 403 if (count > MAX_COUNT) {
413 while (length > LENGTH_LIMIT - ELLIPSIS_SIZE - OVERHEAD && count > HEAD_COUNT) { 404 while (length > LENGTH_LIMIT - ELLIPSIS_SIZE - OVERHEAD && count > HEAD_ COUNT) {
414 length -= ((__x7) => DDC$RT.cast(__x7, dynamic, int, "CastGeneral", """line 562, column 25 of dart:collection/iterable.dart: """, __x7 is int, true))(parts.remo veLast().length + OVERHEAD); 405 length -= ((__x7) => DDC$RT.cast(__x7, dynamic, int, "CastGeneral", "" "line 562, column 25 of dart:collection/iterable.dart: """, __x7 is int, true))( parts.removeLast().length + OVERHEAD);
415 count--; 406 count--;
416 } 407 }
417 parts.add("..."); 408 parts.add("...");
418 return;} 409 return;}
419 } 410 }
420 penultimateString = "$penultimate"; 411 penultimateString = "$penultimate";
421 ultimateString = "$ultimate"; 412 ultimateString = "$ultimate";
422 length += ultimateString.length + penultimateString.length + 2 * OVERHEAD; 413 length += ultimateString.length + penultimateString.length + 2 * OVERHEAD;
423 } 414 }
424 } 415 }
425 String elision = null; 416 String elision = null;
426 if (count > parts.length + TAIL_COUNT) { 417 if (count > parts.length + TAIL_COUNT) {
427 elision = "..."; 418 elision = "...";
428 length += ELLIPSIS_SIZE + OVERHEAD; 419 length += ELLIPSIS_SIZE + OVERHEAD;
429 } 420 }
430 while (length > LENGTH_LIMIT && parts.length > HEAD_COUNT) { 421 while (length > LENGTH_LIMIT && parts.length > HEAD_COUNT) {
431 length -= ((__x8) => DDC$RT.cast(__x8, dynamic, int, "CastGeneral", """line 588, column 17 of dart:collection/iterable.dart: """, __x8 is int, true))(parts.remo veLast().length + OVERHEAD); 422 length -= ((__x8) => DDC$RT.cast(__x8, dynamic, int, "CastGeneral", """line 58 8, column 17 of dart:collection/iterable.dart: """, __x8 is int, true))(parts.re moveLast().length + OVERHEAD);
432 if (elision == null) { 423 if (elision == null) {
433 elision = "..."; 424 elision = "...";
434 length += ELLIPSIS_SIZE + OVERHEAD; 425 length += ELLIPSIS_SIZE + OVERHEAD;
435 } 426 }
436 } 427 }
437 if (elision != null) { 428 if (elision != null) {
438 parts.add(elision); 429 parts.add(elision);
439 } 430 }
440 parts.add(penultimateString); 431 parts.add(penultimateString);
441 parts.add(ultimateString); 432 parts.add(ultimateString);
442 } 433 }
443 } 434 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/async/broadcast_stream_controller.dart ('k') | test/dart_codegen/expect/collection/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698