| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 | 8 |
| 9 import 'frame.dart'; | 9 import 'frame.dart'; |
| 10 import 'stack_zone_specification.dart'; | 10 import 'stack_zone_specification.dart'; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 return new Chain([foldedTraces.last]); | 186 return new Chain([foldedTraces.last]); |
| 187 } | 187 } |
| 188 | 188 |
| 189 return new Chain(nonEmptyTraces); | 189 return new Chain(nonEmptyTraces); |
| 190 } | 190 } |
| 191 | 191 |
| 192 /// Converts [this] to a [Trace]. | 192 /// Converts [this] to a [Trace]. |
| 193 /// | 193 /// |
| 194 /// The trace version of a chain is just the concatenation of all the traces | 194 /// The trace version of a chain is just the concatenation of all the traces |
| 195 /// in the chain. | 195 /// in the chain. |
| 196 Trace toTrace() => new Trace(flatten(traces.map((trace) => trace.frames))); | 196 Trace toTrace() => new Trace(traces.expand((trace) => trace.frames)); |
| 197 | 197 |
| 198 String toString() { | 198 String toString() { |
| 199 // Figure out the longest path so we know how much to pad. | 199 // Figure out the longest path so we know how much to pad. |
| 200 var longest = traces.map((trace) { | 200 var longest = traces.map((trace) { |
| 201 return trace.frames.map((frame) => frame.location.length) | 201 return trace.frames.map((frame) => frame.location.length) |
| 202 .fold(0, math.max); | 202 .fold(0, math.max); |
| 203 }).fold(0, math.max); | 203 }).fold(0, math.max); |
| 204 | 204 |
| 205 // Don't call out to [Trace.toString] here because that doesn't ensure that | 205 // Don't call out to [Trace.toString] here because that doesn't ensure that |
| 206 // padding is consistent across all traces. | 206 // padding is consistent across all traces. |
| 207 return traces.map((trace) { | 207 return traces.map((trace) { |
| 208 return trace.frames.map((frame) { | 208 return trace.frames.map((frame) { |
| 209 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 209 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
| 210 }).join(); | 210 }).join(); |
| 211 }).join(chainGap); | 211 }).join(chainGap); |
| 212 } | 212 } |
| 213 } | 213 } |
| OLD | NEW |