| 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 library stack_trace.chain; | 5 library stack_trace.chain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 factory Chain.forTrace(StackTrace trace) { | 121 factory Chain.forTrace(StackTrace trace) { |
| 122 if (trace is Chain) return trace; | 122 if (trace is Chain) return trace; |
| 123 if (_currentSpec == null) return new Chain([new Trace.from(trace)]); | 123 if (_currentSpec == null) return new Chain([new Trace.from(trace)]); |
| 124 return _currentSpec.chainFor(trace); | 124 return _currentSpec.chainFor(trace); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /// Parses a string representation of a stack chain. | 127 /// Parses a string representation of a stack chain. |
| 128 /// | 128 /// |
| 129 /// Specifically, this parses the output of [Chain.toString]. | 129 /// Specifically, this parses the output of [Chain.toString]. |
| 130 factory Chain.parse(String chain) => | 130 factory Chain.parse(String chain) => |
| 131 new Chain(chain.split(_GAP).map((trace) => new Trace.parseFriendly(trace))); | 131 new Chain(chain.split(_gap).map((trace) => new Trace.parseFriendly(trace))); |
| 132 | 132 |
| 133 /// Returns a new [Chain] comprised of [traces]. | 133 /// Returns a new [Chain] comprised of [traces]. |
| 134 Chain(Iterable<Trace> traces) | 134 Chain(Iterable<Trace> traces) |
| 135 : traces = new UnmodifiableListView<Trace>(traces.toList()); | 135 : traces = new UnmodifiableListView<Trace>(traces.toList()); |
| 136 | 136 |
| 137 /// Returns a terser version of [this]. | 137 /// Returns a terser version of [this]. |
| 138 /// | 138 /// |
| 139 /// This calls [Trace.terse] on every trace in [traces], and discards any | 139 /// This calls [Trace.terse] on every trace in [traces], and discards any |
| 140 /// trace that contain only internal frames. | 140 /// trace that contain only internal frames. |
| 141 Chain get terse => foldFrames((_) => false, terse: true); | 141 Chain get terse => foldFrames((_) => false, terse: true); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 // Don't call out to [Trace.toString] here because that doesn't ensure that | 192 // Don't call out to [Trace.toString] here because that doesn't ensure that |
| 193 // padding is consistent across all traces. | 193 // padding is consistent across all traces. |
| 194 return traces.map((trace) { | 194 return traces.map((trace) { |
| 195 return trace.frames.map((frame) { | 195 return trace.frames.map((frame) { |
| 196 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 196 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
| 197 }).join(); | 197 }).join(); |
| 198 }).join(_gap); | 198 }).join(_gap); |
| 199 } | 199 } |
| 200 } | 200 } |
| OLD | NEW |