Skip to content

Commit 275d280

Browse files
committed
Re-enable source maps
This appears to have bit-rotted. Fixes #384 [email protected] Review URL: https://codereview.chromium.org/1425313003 .
1 parent bceee1d commit 275d280

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

pkg/dev_compiler/lib/src/codegen/js_printer.dart

+17-9
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,21 @@ class SourceMapPrintingContext extends JS.JavaScriptPrintingContext {
7070
printer.add(string);
7171
}
7272

73+
AstNode _currentTopLevelDeclaration;
74+
7375
void enterNode(JS.Node jsNode) {
7476
AstNode node = jsNode.sourceInformation;
75-
if (node is CompilationUnit) {
76-
unit = node;
77+
if (node == null || node.offset == -1) return;
78+
if (unit == null) {
79+
// This is a top-level declaration. Note: consecutive top-level
80+
// declarations may come from different compilation units due to
81+
// parts.
82+
_currentTopLevelDeclaration = node;
83+
unit = node.getAncestor((n) => n is CompilationUnit);
7784
uri = _makeRelativeUri(unit.element.source.uri);
78-
return;
7985
}
80-
if (unit == null || node == null || node.offset == -1) return;
8186

87+
assert(unit != null);
8288
var loc = _location(node.offset);
8389
var name = _getIdentifier(node);
8490
if (name != null) {
@@ -100,15 +106,17 @@ class SourceMapPrintingContext extends JS.JavaScriptPrintingContext {
100106

101107
void exitNode(JS.Node jsNode) {
102108
AstNode node = jsNode.sourceInformation;
103-
if (node is CompilationUnit) {
104-
unit = null;
105-
uri = null;
106-
return;
107-
}
108109
if (unit == null || node == null || node.offset == -1) return;
109110

110111
// TODO(jmesserly): in many cases marking the end will be unnecessary.
111112
printer.mark(_location(node.end));
113+
114+
if (_currentTopLevelDeclaration == node) {
115+
unit = null;
116+
uri = null;
117+
_currentTopLevelDeclaration == null;
118+
return;
119+
}
112120
}
113121

114122
String _getIdentifier(AstNode node) {

pkg/dev_compiler/test/codegen/expect/map_keys.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)