Chromium Code Reviews| Index: lib/compiler/implementation/tree/nodes.dart |
| diff --git a/lib/compiler/implementation/tree/nodes.dart b/lib/compiler/implementation/tree/nodes.dart |
| index f5aa5adcded14326fc9d60e49603f1ca1b960fd2..3888cabe23dbb564a407b1b9cddf1e44a819b57e 100644 |
| --- a/lib/compiler/implementation/tree/nodes.dart |
| +++ b/lib/compiler/implementation/tree/nodes.dart |
| @@ -90,16 +90,30 @@ class Node implements Hashable { |
| abstract visitChildren(Visitor visitor); |
| + /** |
| + * Returns this node unparsed to Dart source string. |
| + */ |
| toString() => unparse(false); |
| + /** |
| + * Returns Xml-like tree representation of this node |
| + * and Dart source string of this node. |
| + */ |
| toDebugString() => unparse(true); |
| String getObjectDescription() => super.toString(); |
| String unparse(bool printDebugInfo) { |
|
Anton Muhin
2012/06/05 09:35:19
do we really need to bundle both?
I'd rather have
Roman
2012/06/05 11:09:07
I'd rather too, but there was a usage in tests tha
|
| - Unparser unparser = new Unparser(printDebugInfo); |
| + StringBuffer sb = new StringBuffer(); |
| + if (printDebugInfo) { |
| + PrettyPrinter prettyPrinter = new PrettyPrinter(); |
| + sb.add(prettyPrinter.prettyprint(this)); |
| + sb.add('\n'); |
| + } |
| + Unparser unparser = new Unparser(); |
| try { |
| - return unparser.unparse(this); |
| + sb.add(unparser.unparse(this)); |
| + return sb.toString(); |
| } catch (var e, var trace) { |
| print(trace); |
| return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>'; |