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

Side by Side Diff: lib/source_map_stack_trace.dart

Issue 1111223003: Prefer "dart:" URLs to "package:" URLs. (Closed) Base URL: git@github.com:dart-lang/source_map_stack_trace.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 source_map_stack_trace; 5 library source_map_stack_trace;
6 6
7 import 'package:path/path.dart' as p; 7 import 'package:path/path.dart' as p;
8 import 'package:source_maps/source_maps.dart'; 8 import 'package:source_maps/source_maps.dart';
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Subtract 1 because stack traces use 1-indexed lines and columns and 55 // Subtract 1 because stack traces use 1-indexed lines and columns and
56 // source maps uses 0-indexed. 56 // source maps uses 0-indexed.
57 var span = sourceMap.spanFor(frame.line - 1, column - 1); 57 var span = sourceMap.spanFor(frame.line - 1, column - 1);
58 58
59 // If we can't find a source span, ignore the frame. It's probably something 59 // If we can't find a source span, ignore the frame. It's probably something
60 // internal that the user doesn't care about. 60 // internal that the user doesn't care about.
61 if (span == null) return null; 61 if (span == null) return null;
62 62
63 var sourceUrl = span.sourceUrl.toString(); 63 var sourceUrl = span.sourceUrl.toString();
64 if (packageRoot != null && p.url.isWithin(packageRoot, sourceUrl)) { 64 if (sdkRoot != null && p.url.isWithin(sdkLib, sourceUrl)) {
65 sourceUrl = "dart:" + p.url.relative(sourceUrl, from: sdkLib);
66 } else if (packageRoot != null && p.url.isWithin(packageRoot, sourceUrl)) {
65 sourceUrl = "package:" + 67 sourceUrl = "package:" +
66 p.url.relative(sourceUrl, from: packageRoot); 68 p.url.relative(sourceUrl, from: packageRoot);
67 } else if (sdkRoot != null && p.url.isWithin(sdkLib, sourceUrl)) {
68 sourceUrl = "dart:" + p.url.relative(sourceUrl, from: sdkLib);
69 } 69 }
70 70
71 return new Frame( 71 return new Frame(
72 Uri.parse(sourceUrl), 72 Uri.parse(sourceUrl),
73 span.start.line + 1, 73 span.start.line + 1,
74 span.start.column + 1, 74 span.start.column + 1,
75 // If the dart2js output is minified, there's no use trying to prettify 75 // If the dart2js output is minified, there's no use trying to prettify
76 // its member names. Use the span's identifier if available, otherwise 76 // its member names. Use the span's identifier if available, otherwise
77 // use the minified member name. 77 // use the minified member name.
78 minified 78 minified
(...skipping 22 matching lines...) Expand all
101 .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "") 101 .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "")
102 // Get rid of the static method prefix. The class name also exists in the 102 // Get rid of the static method prefix. The class name also exists in the
103 // invocation, so we're not getting rid of any information. 103 // invocation, so we're not getting rid of any information.
104 .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.static."), "") 104 .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.static."), "")
105 // Convert underscores after identifiers to dots. This runs the risk of 105 // Convert underscores after identifiers to dots. This runs the risk of
106 // incorrectly converting members that contain underscores, but those are 106 // incorrectly converting members that contain underscores, but those are
107 // contrary to the style guide anyway. 107 // contrary to the style guide anyway.
108 .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"), 108 .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"),
109 (match) => match[1] + "."); 109 (match) => match[1] + ".");
110 } 110 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698