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

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

Issue 1196433002: Create and test source mapping for invocations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/io/start_end_information.dart ('k') | pkg/compiler/lib/src/js/js_debug.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 2d208a6940a14714429d5c817bc0c1c5c5d0731e..04eb3067087b8c80a8d683bec26134e1aa316aa9 100644
--- a/pkg/compiler/lib/src/js/js.dart
+++ b/pkg/compiler/lib/src/js/js.dart
@@ -7,35 +7,47 @@ library js;
import 'package:js_ast/js_ast.dart';
export 'package:js_ast/js_ast.dart';
-import '../io/code_output.dart' show CodeBuffer;
-import '../io/source_information.dart' show SourceInformation;
+import '../io/code_output.dart' show CodeOutput, CodeBuffer;
import '../js_emitter/js_emitter.dart' show USE_NEW_EMITTER;
import '../dart2jslib.dart' as leg;
-import '../util/util.dart' show NO_LOCATION_SPANNABLE;
+import '../util/util.dart' show NO_LOCATION_SPANNABLE, Indentation, Tagging;
import '../dump_info.dart' show DumpInfoTask;
+import 'js_source_mapping.dart';
-CodeBuffer prettyPrint(Node node, leg.Compiler compiler,
+CodeBuffer prettyPrint(Node node,
+ leg.Compiler compiler,
{DumpInfoTask monitor,
bool allowVariableMinification: true}) {
+ JavaScriptSourceInformationStrategy sourceInformationFactory =
+ compiler.backend.sourceInformationStrategy;
JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(
shouldCompressOutput: compiler.enableMinification,
minifyLocalVariables: allowVariableMinification,
preferSemicolonToNewlineInMinifiedOutput: USE_NEW_EMITTER);
+ CodeBuffer outBuffer = new CodeBuffer();
+ SourceInformationProcessor sourceInformationProcessor =
+ sourceInformationFactory.createProcessor(
+ new SourceLocationsMapper(outBuffer));
Dart2JSJavaScriptPrintingContext context =
- new Dart2JSJavaScriptPrintingContext(compiler, monitor);
+ new Dart2JSJavaScriptPrintingContext(
+ compiler, monitor, outBuffer, sourceInformationProcessor);
Printer printer = new Printer(options, context);
printer.visit(node);
- return context.outBuffer;
+ sourceInformationProcessor.process(node);
+ return outBuffer;
}
class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext {
final leg.Compiler compiler;
final DumpInfoTask monitor;
- final CodeBuffer outBuffer = new CodeBuffer();
- Node rootNode;
+ final CodeBuffer outBuffer;
+ final CodePositionListener codePositionListener;
- Dart2JSJavaScriptPrintingContext(leg.Compiler this.compiler,
- DumpInfoTask this.monitor);
+ Dart2JSJavaScriptPrintingContext(
+ this.compiler,
+ this.monitor,
+ this.outBuffer,
+ this.codePositionListener);
@override
void error(String message) {
@@ -48,40 +60,17 @@ class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext {
}
@override
- void enterNode(Node node, int startPosition) {
- SourceInformation sourceInformation = node.sourceInformation;
- if (sourceInformation != null) {
- if (rootNode == null) {
- rootNode = node;
- }
- if (sourceInformation.startPosition != null) {
- outBuffer.addSourceLocation(
- startPosition, sourceInformation.startPosition);
- }
- }
- }
+ void enterNode(Node, int startPosition) {}
+ @override
void exitNode(Node node,
int startPosition,
int endPosition,
int closingPosition) {
- SourceInformation sourceInformation = node.sourceInformation;
- if (sourceInformation != null) {
- if (closingPosition != null &&
- sourceInformation.closingPosition != null) {
- outBuffer.addSourceLocation(
- closingPosition, sourceInformation.closingPosition);
- }
- 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);
}
+ codePositionListener.onPositions(
+ node, startPosition, endPosition, closingPosition);
}
}
« no previous file with comments | « pkg/compiler/lib/src/io/start_end_information.dart ('k') | pkg/compiler/lib/src/js/js_debug.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698