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

Unified Diff: lib/compiler/implementation/tree/prettyprint.dart

Issue 10532150: PrettyPrinter: add an ability to prefix node fields, so instead of: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/tree/prettyprint.dart
diff --git a/lib/compiler/implementation/tree/prettyprint.dart b/lib/compiler/implementation/tree/prettyprint.dart
index 2c7bb33a26dbcb3cf7f4fb8838e3460c76e1ac32..cb2eab34dd9f96c44c1cf77409481e67db438295 100644
--- a/lib/compiler/implementation/tree/prettyprint.dart
+++ b/lib/compiler/implementation/tree/prettyprint.dart
@@ -15,6 +15,8 @@ class PrettyPrinter implements Visitor {
StringBuffer sb;
int depth;
+ /** Prefix for the type passed to the next [openNode()] call. */
+ String nextTypePrefix;
PrettyPrinter() : sb = new StringBuffer(), depth = 0;
@@ -61,6 +63,10 @@ class PrettyPrinter implements Visitor {
}
void addTypeWithParams(String type, [Map params]) {
+ if (nextTypePrefix !== null) {
+ sb.add(nextTypePrefix);
+ nextTypePrefix = null;
+ }
sb.add("${type}");
if (params != null) {
// TODO(smok): Escape doublequotes in values.
@@ -242,12 +248,34 @@ class PrettyPrinter implements Visitor {
visitNodeWithChildren(node, "ScriptTag");
}
+ /** Custom helper to visit given node and print its type with prefix. */
+ visitWithPrefix(Node node, String prefix) {
+ nextTypePrefix = prefix;
+ node.accept(this);
+ }
+
+ openSendNodeWithFields(Send node, String type) {
+ openNode(type, {
+ "isPrefix" : "${node.isPrefix}",
+ "isPostfix" : "${node.isPostfix}",
+ "isIndex" : "${node.isIndex}"
+ });
+ if (node.receiver !== null) visitWithPrefix(node.receiver, "receiver:");
+ if (node.selector !== null) visitWithPrefix(node.selector, "selector:");
+ if (node.argumentsNode !== null)
+ visitWithPrefix(node.argumentsNode, "argumentsNode:");
+ }
+
visitSend(Send node) {
- visitNodeWithChildren(node, "Send");
+ openSendNodeWithFields(node, "Send");
+ closeNode("Send");
}
visitSendSet(SendSet node) {
- visitNodeWithChildren(node, "SendSet");
+ openSendNodeWithFields(node, "SendSet");
+ if (node.assignmentOperator !== null)
+ visitWithPrefix(node.assignmentOperator, "assignmentOperator:");
+ closeNode("SendSet");
}
visitStringInterpolation(StringInterpolation node) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698