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

Unified Diff: pkg/compiler/lib/src/io/source_information.dart

Issue 1139693002: Compute better names for source maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | tests/compiler/dart2js/source_map_name_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/io/source_information.dart
diff --git a/pkg/compiler/lib/src/io/source_information.dart b/pkg/compiler/lib/src/io/source_information.dart
index 601256d2acc247629dde299635a654542a3631f2..e7b23eabf16033c2644321dc6abb60cc3aef99d4 100644
--- a/pkg/compiler/lib/src/io/source_information.dart
+++ b/pkg/compiler/lib/src/io/source_information.dart
@@ -5,7 +5,9 @@
library dart2js.source_information;
import '../dart2jslib.dart' show SourceSpan, MessageKind;
-import '../elements/elements.dart' show AstElement;
+import '../elements/elements.dart' show
+ AstElement,
+ LocalElement;
import '../scanner/scannerlib.dart' show Token;
import '../tree/tree.dart' show Node;
import '../js/js.dart' show JavaScriptNodeSourceInformation;
@@ -103,7 +105,7 @@ class StartEndSourceInformation extends SourceInformation {
AstElement implementation = element.implementation;
SourceFile sourceFile = implementation.compilationUnit.script.file;
- String name = element.name;
+ String name = computeElementNameForSourceMaps(element);
Node node = implementation.node;
Token beginToken;
Token endToken;
@@ -156,7 +158,7 @@ class StartEndSourceInformationBuilder extends SourceInformationBuilder {
StartEndSourceInformationBuilder(AstElement element)
: sourceFile = element.compilationUnit.script.file,
- name = element.name;
+ name = computeElementNameForSourceMaps(element);
SourceInformation buildDeclaration(AstElement element) {
return StartEndSourceInformation.computeSourceInformation(element);
@@ -339,7 +341,7 @@ class PositionSourceInformationBuilder implements SourceInformationBuilder {
PositionSourceInformationBuilder(AstElement element)
: sourceFile = element.implementation.compilationUnit.script.file,
- name = element.name;
+ name = computeElementNameForSourceMaps(element);
SourceInformation buildDeclaration(AstElement element) {
if (element.isSynthesized) {
@@ -379,3 +381,32 @@ class PositionSourceInformationBuilder implements SourceInformationBuilder {
return new PositionSourceInformationBuilder(element);
}
}
+
+/// Compute the source map name for [element].
+String computeElementNameForSourceMaps(AstElement element) {
+ if (element.isClosure) {
+ return computeElementNameForSourceMaps(element.enclosingElement);
+ } else if (element.isClass) {
+ return element.name;
+ } else if (element.isConstructor || element.isGenerativeConstructorBody) {
+ String className = element.enclosingClass.name;
+ if (element.name == '') {
+ return className;
+ }
+ return '$className.${element.name}';
+ } else if (element.isLocal) {
+ LocalElement local = element;
+ String name = local.name;
+ if (name == '') {
+ name = '<anonymous function>';
+ }
+ return '${computeElementNameForSourceMaps(local.executableContext)}.$name';
+ } else if (element.enclosingClass != null) {
+ if (element.enclosingClass.isClosure) {
+ return computeElementNameForSourceMaps(element.enclosingClass);
+ }
+ return '${element.enclosingClass.name}.${element.name}';
+ } else {
+ return element.name;
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | tests/compiler/dart2js/source_map_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698