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

Side by Side Diff: lib/source_map_stack_trace.dart

Issue 2069043004: Properly map function names with named arguments. (Closed) Base URL: git@github.com:dart-lang/source_map_stack_trace.git@master
Patch Set: Created 4 years, 6 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 import 'package:path/path.dart' as p; 5 import 'package:path/path.dart' as p;
6 import 'package:source_maps/source_maps.dart'; 6 import 'package:source_maps/source_maps.dart';
7 import 'package:stack_trace/stack_trace.dart'; 7 import 'package:stack_trace/stack_trace.dart';
8 8
9 /// Convert [stackTrace], a stack trace generated by dart2js-compiled 9 /// Convert [stackTrace], a stack trace generated by dart2js-compiled
10 /// JavaScript, to a native-looking stack trace using [sourceMap]. 10 /// JavaScript, to a native-looking stack trace using [sourceMap].
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // its member names. Use the span's identifier if available, otherwise 74 // its member names. Use the span's identifier if available, otherwise
75 // use the minified member name. 75 // use the minified member name.
76 minified 76 minified
77 ? (span.isIdentifier ? span.text : frame.member) 77 ? (span.isIdentifier ? span.text : frame.member)
78 : _prettifyMember(frame.member)); 78 : _prettifyMember(frame.member));
79 }).where((frame) => frame != null)); 79 }).where((frame) => frame != null));
80 } 80 }
81 81
82 /// Reformats a JS member name to make it look more Dart-like. 82 /// Reformats a JS member name to make it look more Dart-like.
83 String _prettifyMember(String member) { 83 String _prettifyMember(String member) {
84 return member 84 return member
kevmoo 2016/06/15 19:26:10 Orthogonal: How often is this method called? Durin
nweiz 2016/06/15 20:29:09 For now I don't think it's being used anywhere per
85 // Get rid of the noise that Firefox sometimes adds. 85 // Get rid of the noise that Firefox sometimes adds.
86 .replaceAll(new RegExp(r"/?<$"), "") 86 .replaceAll(new RegExp(r"/?<$"), "")
87 // Get rid of arity indicators. 87 // Get rid of arity indicators and named arguments.
88 .replaceAll(new RegExp(r"\$\d+$"), "") 88 .replaceAll(new RegExp(r"\$\d+(\$[a-zA-Z_0-9]+)*$"), "")
89 // Convert closures to <fn>. 89 // Convert closures to <fn>.
90 .replaceAllMapped(new RegExp(r"(_+)closure\d*\.call$"), 90 .replaceAllMapped(new RegExp(r"(_+)closure\d*\.call$"),
91 // The number of underscores before "closure" indicates how nested it 91 // The number of underscores before "closure" indicates how nested it
92 // is. 92 // is.
93 (match) => ".<fn>" * match[1].length) 93 (match) => ".<fn>" * match[1].length)
94 // Get rid of explicitly-generated calls. 94 // Get rid of explicitly-generated calls.
95 .replaceAll(new RegExp(r"\.call$"), "") 95 .replaceAll(new RegExp(r"\.call$"), "")
96 // Get rid of the top-level method prefix. 96 // Get rid of the top-level method prefix.
97 .replaceAll(new RegExp(r"^dart\."), "") 97 .replaceAll(new RegExp(r"^dart\."), "")
98 // Get rid of library namespaces. 98 // Get rid of library namespaces.
99 .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "") 99 .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "")
100 // Get rid of the static method prefix. The class name also exists in the 100 // Get rid of the static method prefix. The class name also exists in the
101 // invocation, so we're not getting rid of any information. 101 // invocation, so we're not getting rid of any information.
102 .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "") 102 .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "")
103 // Convert underscores after identifiers to dots. This runs the risk of 103 // Convert underscores after identifiers to dots. This runs the risk of
104 // incorrectly converting members that contain underscores, but those are 104 // incorrectly converting members that contain underscores, but those are
105 // contrary to the style guide anyway. 105 // contrary to the style guide anyway.
106 .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"), 106 .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"),
107 (match) => match[1] + "."); 107 (match) => match[1] + ".");
108 } 108 }
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