| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 final String member; | 81 final String member; |
| 82 | 82 |
| 83 /// Whether this stack frame comes from the Dart core libraries. | 83 /// Whether this stack frame comes from the Dart core libraries. |
| 84 bool get isCore => uri.scheme == 'dart'; | 84 bool get isCore => uri.scheme == 'dart'; |
| 85 | 85 |
| 86 /// Returns a human-friendly description of the library that this stack frame | 86 /// Returns a human-friendly description of the library that this stack frame |
| 87 /// comes from. | 87 /// comes from. |
| 88 /// | 88 /// |
| 89 /// This will usually be the string form of [uri], but a relative URI will be | 89 /// This will usually be the string form of [uri], but a relative URI will be |
| 90 /// used if possible. | 90 /// used if possible. |
| 91 String get library { | 91 String get library => path.prettyUri(uri); |
| 92 if (uri.scheme != Uri.base.scheme) return uri.toString(); | |
| 93 if (path.style == path.Style.url) return path.relative(uri.toString()); | |
| 94 return path.relative(path.fromUri(uri)); | |
| 95 } | |
| 96 | 92 |
| 97 /// Returns the name of the package this stack frame comes from, or `null` if | 93 /// Returns the name of the package this stack frame comes from, or `null` if |
| 98 /// this stack frame doesn't come from a `package:` URL. | 94 /// this stack frame doesn't come from a `package:` URL. |
| 99 String get package { | 95 String get package { |
| 100 if (uri.scheme != 'package') return null; | 96 if (uri.scheme != 'package') return null; |
| 101 return uri.path.split('/').first; | 97 return uri.path.split('/').first; |
| 102 } | 98 } |
| 103 | 99 |
| 104 /// A human-friendly description of the code location. | 100 /// A human-friendly description of the code location. |
| 105 String get location { | 101 String get location { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // their stack frames. However, if we do get a relative path, we should | 278 // their stack frames. However, if we do get a relative path, we should |
| 283 // handle it gracefully. | 279 // handle it gracefully. |
| 284 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); | 280 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); |
| 285 return Uri.parse(uriOrPath); | 281 return Uri.parse(uriOrPath); |
| 286 } | 282 } |
| 287 | 283 |
| 288 Frame(this.uri, this.line, this.column, this.member); | 284 Frame(this.uri, this.line, this.column, this.member); |
| 289 | 285 |
| 290 String toString() => '$location in $member'; | 286 String toString() => '$location in $member'; |
| 291 } | 287 } |
| OLD | NEW |