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:pathos/path.dart' as path; | 8 import 'package:pathos/path.dart' as path; |
9 | 9 |
10 import 'trace.dart'; | 10 import 'trace.dart'; |
11 import 'utils.dart'; | |
12 | 11 |
13 final _nativeFrameRegExp = new RegExp( | 12 final _nativeFrameRegExp = new RegExp( |
14 r'^#\d+\s+([^\s].*) \((.+):(\d+):(\d+)\)$'); | 13 r'^#\d+\s+([^\s].*) \((.+):(\d+):(\d+)\)$'); |
15 | 14 |
16 /// A single stack frame. Each frame points to a precise location in Dart code. | 15 /// A single stack frame. Each frame points to a precise location in Dart code. |
17 class Frame { | 16 class Frame { |
18 /// The URI of the file in which the code is located. | 17 /// The URI of the file in which the code is located. |
19 /// | 18 /// |
20 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`. | 19 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`. |
21 final Uri uri; | 20 final Uri uri; |
(...skipping 17 matching lines...) Expand all Loading... |
39 | 38 |
40 /// Whether this stack frame comes from the Dart core libraries. | 39 /// Whether this stack frame comes from the Dart core libraries. |
41 bool get isCore => uri.scheme == 'dart'; | 40 bool get isCore => uri.scheme == 'dart'; |
42 | 41 |
43 /// Returns a human-friendly description of the library that this stack frame | 42 /// Returns a human-friendly description of the library that this stack frame |
44 /// comes from. | 43 /// comes from. |
45 /// | 44 /// |
46 /// This will usually be the string form of [uri], but a relative path will be | 45 /// This will usually be the string form of [uri], but a relative path will be |
47 /// used if possible. | 46 /// used if possible. |
48 String get library { | 47 String get library { |
49 // TODO(nweiz): handle relative URIs here as well once pathos supports that. | |
50 if (uri.scheme != 'file') return uri.toString(); | 48 if (uri.scheme != 'file') return uri.toString(); |
51 return path.relative(fileUriToPath(uri)); | 49 return path.relative(path.fromUri(uri)); |
52 } | 50 } |
53 | 51 |
54 /// Returns the name of the package this stack frame comes from, or `null` if | 52 /// Returns the name of the package this stack frame comes from, or `null` if |
55 /// this stack frame doesn't come from a `package:` URL. | 53 /// this stack frame doesn't come from a `package:` URL. |
56 String get package { | 54 String get package { |
57 if (uri.scheme != 'package') return null; | 55 if (uri.scheme != 'package') return null; |
58 return uri.path.split('/').first; | 56 return uri.path.split('/').first; |
59 } | 57 } |
60 | 58 |
61 /// A human-friendly description of the code location. | 59 /// A human-friendly description of the code location. |
(...skipping 27 matching lines...) Expand all Loading... |
89 | 87 |
90 var uri = Uri.parse(match[2]); | 88 var uri = Uri.parse(match[2]); |
91 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); | 89 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); |
92 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); |
93 } | 91 } |
94 | 92 |
95 Frame(this.uri, this.line, this.column, this.member); | 93 Frame(this.uri, this.line, this.column, this.member); |
96 | 94 |
97 String toString() => '$location in $member'; | 95 String toString() => '$location in $member'; |
98 } | 96 } |
OLD | NEW |