| 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 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 | 8 |
| 9 import 'package:pathos/path.dart' as path; | 9 import 'package:pathos/path.dart' as path; |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 /// comes from. | 39 /// comes from. |
| 40 /// | 40 /// |
| 41 /// This will usually be the string form of [uri], but a relative path will be | 41 /// This will usually be the string form of [uri], but a relative path will be |
| 42 /// used if possible. | 42 /// used if possible. |
| 43 String get library { | 43 String get library { |
| 44 // TODO(nweiz): handle relative URIs here as well once pathos supports that. | 44 // TODO(nweiz): handle relative URIs here as well once pathos supports that. |
| 45 if (uri.scheme != 'file') return uri.toString(); | 45 if (uri.scheme != 'file') return uri.toString(); |
| 46 return path.relative(fileUriToPath(uri)); | 46 return path.relative(fileUriToPath(uri)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 /// Returns the name of the package this stack frame comes from, or `null` if |
| 50 /// this stack frame doesn't come from a `package:` URL. |
| 51 String get package { |
| 52 if (uri.scheme != 'package') return null; |
| 53 return uri.path.split('/').first; |
| 54 } |
| 55 |
| 49 /// A human-friendly description of the code location. | 56 /// A human-friendly description of the code location. |
| 50 /// | 57 /// |
| 51 /// For Dart core libraries, this will omit the line and column information, | 58 /// For Dart core libraries, this will omit the line and column information, |
| 52 /// since those are useless for baked-in libraries. | 59 /// since those are useless for baked-in libraries. |
| 53 String get location { | 60 String get location { |
| 54 if (isCore) return library; | 61 if (isCore) return library; |
| 55 return '$library $line:$column'; | 62 return '$library $line:$column'; |
| 56 } | 63 } |
| 57 | 64 |
| 58 /// Returns a single frame of the current stack. | 65 /// Returns a single frame of the current stack. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 80 | 87 |
| 81 var uri = new Uri.fromString(match[2]); | 88 var uri = new Uri.fromString(match[2]); |
| 82 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); | 89 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); |
| 83 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); | 90 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); |
| 84 } | 91 } |
| 85 | 92 |
| 86 Frame(this.uri, this.line, this.column, this.member); | 93 Frame(this.uri, this.line, this.column, this.member); |
| 87 | 94 |
| 88 String toString() => '$location in $member'; | 95 String toString() => '$location in $member'; |
| 89 } | 96 } |
| OLD | NEW |