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:collection'; | |
6 import 'dart:math' as math; | 5 import 'dart:math' as math; |
7 | 6 |
8 import 'chain.dart'; | 7 import 'chain.dart'; |
9 import 'frame.dart'; | 8 import 'frame.dart'; |
10 import 'lazy_trace.dart'; | 9 import 'lazy_trace.dart'; |
11 import 'unparsed_frame.dart'; | 10 import 'unparsed_frame.dart'; |
12 import 'utils.dart'; | 11 import 'utils.dart'; |
13 import 'vm_trace.dart'; | 12 import 'vm_trace.dart'; |
14 | 13 |
15 final _terseRegExp = new RegExp(r"(-patch)?([/\\].*)?$"); | 14 final _terseRegExp = new RegExp(r"(-patch)?([/\\].*)?$"); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Trace.parseFriendly(String trace) | 197 Trace.parseFriendly(String trace) |
199 : this(trace.isEmpty | 198 : this(trace.isEmpty |
200 ? [] | 199 ? [] |
201 : trace.trim().split("\n") | 200 : trace.trim().split("\n") |
202 // Filter out asynchronous gaps from [Chain]s. | 201 // Filter out asynchronous gaps from [Chain]s. |
203 .where((line) => !line.startsWith('=====')) | 202 .where((line) => !line.startsWith('=====')) |
204 .map((line) => new Frame.parseFriendly(line))); | 203 .map((line) => new Frame.parseFriendly(line))); |
205 | 204 |
206 /// Returns a new [Trace] comprised of [frames]. | 205 /// Returns a new [Trace] comprised of [frames]. |
207 Trace(Iterable<Frame> frames) | 206 Trace(Iterable<Frame> frames) |
208 : frames = new UnmodifiableListView<Frame>(frames.toList()); | 207 : frames = new List<Frame>.unmodifiable(frames); |
209 | 208 |
210 /// Returns a VM-style [StackTrace] object. | 209 /// Returns a VM-style [StackTrace] object. |
211 /// | 210 /// |
212 /// The return value's [toString] method will always return a string | 211 /// The return value's [toString] method will always return a string |
213 /// representation in the Dart VM's stack trace format, regardless of what | 212 /// representation in the Dart VM's stack trace format, regardless of what |
214 /// platform is being used. | 213 /// platform is being used. |
215 StackTrace get vmTrace => new VMTrace(frames); | 214 StackTrace get vmTrace => new VMTrace(frames); |
216 | 215 |
217 /// Returns a terser version of [this]. | 216 /// Returns a terser version of [this]. |
218 /// | 217 /// |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 var longest = frames.map((frame) => frame.location.length) | 284 var longest = frames.map((frame) => frame.location.length) |
286 .fold(0, math.max); | 285 .fold(0, math.max); |
287 | 286 |
288 // Print out the stack trace nicely formatted. | 287 // Print out the stack trace nicely formatted. |
289 return frames.map((frame) { | 288 return frames.map((frame) { |
290 if (frame is UnparsedFrame) return "$frame\n"; | 289 if (frame is UnparsedFrame) return "$frame\n"; |
291 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 290 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
292 }).join(); | 291 }).join(); |
293 } | 292 } |
294 } | 293 } |
OLD | NEW |