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

Unified Diff: compiler/java/com/google/dart/compiler/ast/viz/DotWriter.java

Issue 8905021: Dartest CL - Please review (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
Index: compiler/java/com/google/dart/compiler/ast/viz/DotWriter.java
===================================================================
--- compiler/java/com/google/dart/compiler/ast/viz/DotWriter.java (revision 2358)
+++ compiler/java/com/google/dart/compiler/ast/viz/DotWriter.java (working copy)
@@ -72,26 +72,32 @@
}
protected void write(String nodeType, DartNode node, String data) {
- String nodeData = node.getSourceLine() + ":" + node.getSourceStart() + ":"
- + node.getSourceLength() + "_" + nodeType;
- nodeMap.put(node, nodeData);
+ String nodeId = node.getObjectIdentifier();
Kelly Norton 2011/12/16 20:01:17 tabs.
+ nodeMap.put(node, nodeId);
DartNode parent = node.getParent();
if (parent == null) {
parent = currentUnit;
}
String styleAttr = getStyleAttr(nodeType, node);
String label = getLabel(nodeType, node, data);
- nodes.append(String.format("\t\"%s\" [label=\"%s\"%s];\n", nodeData, label, styleAttr));
- edges.append(String.format("\t\"%s\" -> \"%s\";\n", nodeMap.get(parent), nodeData));
+ nodes.append(String.format("\t\"%s\" [label=\"%s\"%s];\n", nodeId, label, styleAttr));
+ edges.append(String.format("\t\"%s\" -> \"%s\";\n", nodeMap.get(parent), nodeId));
}
private String getLabel(String nodeType, DartNode node, String data) {
StringBuffer label = new StringBuffer(nodeType);
if (printDataNodes.contains(nodeType) || node instanceof DartExpression) {
- label.append(String.format("\\n%s", data.replaceAll("\"", "'")));
+ label.append(String.format("\\n%s", escape(data)));
}
return label.toString();
}
+
+ private String escape(String data){
+ data = data.replaceAll("\"", "'");
zundel 2011/12/16 20:49:05 odd indentation
+ data = data.replaceAll("\n", "\\n");
+ data = data.replaceAll("\r", "\\r");
zundel 2011/12/16 20:49:05 this is a bit optimisitc. If you already have a s
+ return data;
+ }
private String getStyleAttr(String nodeType, DartNode node) {
StringBuffer style = new StringBuffer();
@@ -102,6 +108,11 @@
} else if ("DartMethodDefinition".equals(nodeType)) {
style.append(", color=blue");
}
+
+ if(node.isInstrumentedNode()){
+ style.append(", style=filled, fillcolor=yellow");
+ }
+
return style.toString();
}

Powered by Google App Engine
This is Rietveld 408576698