Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: pkg/stack_trace/lib/src/frame.dart

Issue 13191011: Be more careful about converting between file URIs and paths. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/stack_trace/test/frame_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import 'trace.dart'; 11 import 'trace.dart';
12 import 'utils.dart';
12 13
13 final _nativeFrameRegExp = new RegExp( 14 final _nativeFrameRegExp = new RegExp(
14 r'^#\d+\s+([^\s].*) \((.+):(\d+):(\d+)\)$'); 15 r'^#\d+\s+([^\s].*) \((.+):(\d+):(\d+)\)$');
15 16
16 /// A single stack frame. Each frame points to a precise location in Dart code. 17 /// A single stack frame. Each frame points to a precise location in Dart code.
17 class Frame { 18 class Frame {
18 /// The URI of the file in which the code is located. 19 /// The URI of the file in which the code is located.
19 /// 20 ///
20 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`. 21 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`.
21 final Uri uri; 22 final Uri uri;
(...skipping 13 matching lines...) Expand all
35 bool get isCore => uri.scheme == 'dart'; 36 bool get isCore => uri.scheme == 'dart';
36 37
37 /// Returns a human-friendly description of the library that this stack frame 38 /// Returns a human-friendly description of the library that this stack frame
38 /// comes from. 39 /// comes from.
39 /// 40 ///
40 /// 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
41 /// used if possible. 42 /// used if possible.
42 String get library { 43 String get library {
43 // 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.
44 if (uri.scheme != 'file') return uri.toString(); 45 if (uri.scheme != 'file') return uri.toString();
45 return path.relative(uri.path); 46 return path.relative(fileUriToPath(uri));
46 } 47 }
47 48
48 /// A human-friendly description of the code location. 49 /// A human-friendly description of the code location.
49 /// 50 ///
50 /// For Dart core libraries, this will omit the line and column information, 51 /// For Dart core libraries, this will omit the line and column information,
51 /// since those are useless for baked-in libraries. 52 /// since those are useless for baked-in libraries.
52 String get location { 53 String get location {
53 if (isCore) return library; 54 if (isCore) return library;
54 return '$library $line:$column'; 55 return '$library $line:$column';
55 } 56 }
(...skipping 23 matching lines...) Expand all
79 80
80 var uri = new Uri.fromString(match[2]); 81 var uri = new Uri.fromString(match[2]);
81 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); 82 var member = match[1].replaceAll("<anonymous closure>", "<fn>");
82 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); 83 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member);
83 } 84 }
84 85
85 Frame(this.uri, this.line, this.column, this.member); 86 Frame(this.uri, this.line, this.column, this.member);
86 87
87 String toString() => '$location in $member'; 88 String toString() => '$location in $member';
88 } 89 }
OLDNEW
« no previous file with comments | « no previous file | pkg/stack_trace/test/frame_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698