| 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 frame; | 5 library frame; |
| 6 | 6 |
| 7 | 7 |
| 8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
| 9 | 9 |
| 10 import 'trace.dart'; | 10 import 'trace.dart'; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 /// Returns the name of the package this stack frame comes from, or `null` if | 72 /// Returns the name of the package this stack frame comes from, or `null` if |
| 73 /// this stack frame doesn't come from a `package:` URL. | 73 /// this stack frame doesn't come from a `package:` URL. |
| 74 String get package { | 74 String get package { |
| 75 if (uri.scheme != 'package') return null; | 75 if (uri.scheme != 'package') return null; |
| 76 return uri.path.split('/').first; | 76 return uri.path.split('/').first; |
| 77 } | 77 } |
| 78 | 78 |
| 79 /// A human-friendly description of the code location. | 79 /// A human-friendly description of the code location. |
| 80 String get location { | 80 String get location { |
| 81 if (line == null || column == null) return library; | 81 if (line == null) return library; |
| 82 if (column == null) return '$library $line'; |
| 82 return '$library $line:$column'; | 83 return '$library $line:$column'; |
| 83 } | 84 } |
| 84 | 85 |
| 85 /// Returns a single frame of the current stack. | 86 /// Returns a single frame of the current stack. |
| 86 /// | 87 /// |
| 87 /// By default, this will return the frame above the current method. If | 88 /// By default, this will return the frame above the current method. If |
| 88 /// [level] is `0`, it will return the current method's frame; if [level] is | 89 /// [level] is `0`, it will return the current method's frame; if [level] is |
| 89 /// higher than `1`, it will return higher frames. | 90 /// higher than `1`, it will return higher frames. |
| 90 factory Frame.caller([int level=1]) { | 91 factory Frame.caller([int level=1]) { |
| 91 if (level < 0) { | 92 if (level < 0) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 194 |
| 194 var line = match[2] == null ? null : int.parse(match[2]); | 195 var line = match[2] == null ? null : int.parse(match[2]); |
| 195 var column = match[3] == null ? null : int.parse(match[3]); | 196 var column = match[3] == null ? null : int.parse(match[3]); |
| 196 return new Frame(uri, line, column, match[4]); | 197 return new Frame(uri, line, column, match[4]); |
| 197 } | 198 } |
| 198 | 199 |
| 199 Frame(this.uri, this.line, this.column, this.member); | 200 Frame(this.uri, this.line, this.column, this.member); |
| 200 | 201 |
| 201 String toString() => '$location in $member'; | 202 String toString() => '$location in $member'; |
| 202 } | 203 } |
| OLD | NEW |