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

Unified Diff: lib/src/codegen/js_printer.dart

Issue 1425313003: Re-enable source maps (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments Created 5 years, 1 month 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 | « no previous file | test/codegen/expect/map_keys.js.map » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_printer.dart
diff --git a/lib/src/codegen/js_printer.dart b/lib/src/codegen/js_printer.dart
index e83548776dd33ac94b85b0dfb91f735230b2fdd1..6f8502fcfff23a172b2a3d57ffe1343aaa41d7e6 100644
--- a/lib/src/codegen/js_printer.dart
+++ b/lib/src/codegen/js_printer.dart
@@ -70,15 +70,25 @@ class SourceMapPrintingContext extends JS.JavaScriptPrintingContext {
printer.add(string);
}
+ final _topLevelDeclarations = new Set<AstNode>();
+
void enterNode(JS.Node jsNode) {
AstNode node = jsNode.sourceInformation;
- if (node is CompilationUnit) {
- unit = node;
+ if (node == null || node.offset == -1) return;
+ if (unit == null) {
+ // This is a top-level declaration. Note: consecutive top-level
+ // declarations may come from different compilation units due to
+ // parts.
+ _topLevelDeclarations.add(node);
+ var containingUnit = node;
+ while (containingUnit is! CompilationUnit) {
Jennifer Messerly 2015/11/09 23:21:11 I think this could be node.getAncestor((n) => n is
vsm 2015/11/10 14:35:47 Done - thanks!
+ containingUnit = containingUnit.parent;
+ }
+ unit = containingUnit;
uri = _makeRelativeUri(unit.element.source.uri);
- return;
}
- if (unit == null || node == null || node.offset == -1) return;
+ assert(unit != null);
var loc = _location(node.offset);
var name = _getIdentifier(node);
if (name != null) {
@@ -100,15 +110,16 @@ class SourceMapPrintingContext extends JS.JavaScriptPrintingContext {
void exitNode(JS.Node jsNode) {
AstNode node = jsNode.sourceInformation;
- if (node is CompilationUnit) {
- unit = null;
- uri = null;
- return;
- }
if (unit == null || node == null || node.offset == -1) return;
// TODO(jmesserly): in many cases marking the end will be unnecessary.
printer.mark(_location(node.end));
+
+ if (_topLevelDeclarations.contains(node)) {
Jennifer Messerly 2015/11/09 23:21:11 Could we just have a boolean "_isTopLevel" so we k
vsm 2015/11/10 14:35:47 It does nest - I think it's proper nesting. Modif
+ unit = null;
+ uri = null;
+ return;
+ }
}
String _getIdentifier(AstNode node) {
« no previous file with comments | « no previous file | test/codegen/expect/map_keys.js.map » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698