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

Unified Diff: pkg/compiler/lib/src/js/js.dart

Issue 1081313003: Improve precision of JS printer callbacks (2nd try) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 8 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/io/source_information.dart ('k') | pkg/js_ast/lib/src/printer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/js.dart
diff --git a/pkg/compiler/lib/src/js/js.dart b/pkg/compiler/lib/src/js/js.dart
index ec8766a836457af3dfe0b7432ac499c3292616d6..c6a1a2b70203a705cab831e9200ce900f3556065 100644
--- a/pkg/compiler/lib/src/js/js.dart
+++ b/pkg/compiler/lib/src/js/js.dart
@@ -33,6 +33,7 @@ class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext {
final leg.Compiler compiler;
final DumpInfoTask monitor;
final CodeBuffer outBuffer = new CodeBuffer();
+ Node rootNode;
Dart2JSJavaScriptPrintingContext(leg.Compiler this.compiler,
DumpInfoTask this.monitor);
@@ -45,19 +46,35 @@ class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext {
outBuffer.add(string);
}
- void enterNode(Node node) {
+ void enterNode(Node node, int startPosition) {
SourceInformation sourceInformation = node.sourceInformation;
if (sourceInformation != null) {
- sourceInformation.beginMapping(outBuffer);
+ if (rootNode == null) {
+ rootNode = node;
+ }
+ if (sourceInformation.startPosition != null) {
+ outBuffer.addSourceLocation(
+ startPosition, sourceInformation.startPosition);
+ }
}
- if (monitor != null) monitor.enteringAst(node, outBuffer.length);
}
- void exitNode(Node node) {
- if (monitor != null) monitor.exitingAst(node, outBuffer.length);
+ void exitNode(Node node,
+ int startPosition,
+ int endPosition,
+ int closingPosition) {
SourceInformation sourceInformation = node.sourceInformation;
if (sourceInformation != null) {
- sourceInformation.endMapping(outBuffer);
+ if (sourceInformation.endPosition != null) {
+ outBuffer.addSourceLocation(endPosition, sourceInformation.endPosition);
+ }
+ if (rootNode == node) {
+ outBuffer.addSourceLocation(endPosition, null);
+ rootNode = null;
+ }
+ }
+ if (monitor != null) {
+ monitor.recordAstSize(node, endPosition - startPosition);
}
}
}
« no previous file with comments | « pkg/compiler/lib/src/io/source_information.dart ('k') | pkg/js_ast/lib/src/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698