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 trace; | 5 library trace; |
6 | 6 |
7 import 'dart:uri'; | 7 import 'dart:uri'; |
8 import 'dart:math'; | 8 import 'dart:math'; |
9 | 9 |
10 import 'frame.dart'; | 10 import 'frame.dart'; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 return new Trace(trace.frames.skip(level + 1)); | 45 return new Trace(trace.frames.skip(level + 1)); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 /// Returns a new stack trace containing the same data as [trace]. | 49 /// Returns a new stack trace containing the same data as [trace]. |
50 /// | 50 /// |
51 /// If [trace] is a native [StackTrace], its data will be parsed out; if it's | 51 /// If [trace] is a native [StackTrace], its data will be parsed out; if it's |
52 /// a [Trace], it will be returned as-is. | 52 /// a [Trace], it will be returned as-is. |
53 factory Trace.from(StackTrace trace) { | 53 factory Trace.from(StackTrace trace) { |
54 if (trace is Trace) return trace; | 54 if (trace is Trace) return trace; |
55 return new Trace.parse(trace.fullStackTrace); | 55 return new Trace.parse(trace.toString()); |
56 } | 56 } |
57 | 57 |
58 /// Parses a string representation of a stack trace. | 58 /// Parses a string representation of a stack trace. |
59 /// | 59 /// |
60 /// [trace] should be formatted in the same way as native stack traces. | 60 /// [trace] should be formatted in the same way as native stack traces. |
61 Trace.parse(String trace) | 61 Trace.parse(String trace) |
62 : this(trace.trim().split("\n").map((line) => new Frame.parse(line))); | 62 : this(trace.trim().split("\n").map((line) => new Frame.parse(line))); |
63 | 63 |
64 /// Returns a new [Trace] comprised of [frames]. | 64 /// Returns a new [Trace] comprised of [frames]. |
65 Trace(Iterable<Frame> frames) | 65 Trace(Iterable<Frame> frames) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (string.length >= length) return string; | 132 if (string.length >= length) return string; |
133 | 133 |
134 var result = new StringBuffer(); | 134 var result = new StringBuffer(); |
135 result.write(string); | 135 result.write(string); |
136 for (var i = 0; i < length - string.length; i++) { | 136 for (var i = 0; i < length - string.length; i++) { |
137 result.write(' '); | 137 result.write(' '); |
138 } | 138 } |
139 | 139 |
140 return result.toString(); | 140 return result.toString(); |
141 } | 141 } |
OLD | NEW |