OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of tree; | 5 part of tree; |
6 | 6 |
7 String unparse(Node node, {minify: true}) { | 7 String unparse(Node node, {minify: true}) { |
8 Unparser unparser = new Unparser(minify: minify); | 8 Unparser unparser = new Unparser(minify: minify); |
9 unparser.unparse(node); | 9 unparser.unparse(node); |
10 return unparser.result; | 10 return unparser.result; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 sb.write(s); | 51 sb.write(s); |
52 onEmptyLine = false; | 52 onEmptyLine = false; |
53 } | 53 } |
54 | 54 |
55 unparse(Node node) { visit(node); } | 55 unparse(Node node) { visit(node); } |
56 | 56 |
57 visit(Node node) { | 57 visit(Node node) { |
58 if (node != null) node.accept(this); | 58 if (node != null) node.accept(this); |
59 } | 59 } |
60 | 60 |
61 visitAssert(Assert node) { | |
62 write(node.assertToken.value); | |
63 write('('); | |
64 visit(node.condition); | |
65 if (node.hasMessage) { | |
66 write(','); | |
67 space(); | |
68 visit(node.message); | |
69 } | |
70 write(');'); | |
71 } | |
72 | |
73 visitBlock(Block node) => unparseBlockStatements(node.statements); | 61 visitBlock(Block node) => unparseBlockStatements(node.statements); |
74 | 62 |
75 unparseBlockStatements(NodeList statements) { | 63 unparseBlockStatements(NodeList statements) { |
76 addToken(statements.beginToken); | 64 addToken(statements.beginToken); |
77 | 65 |
78 Link<Node> nodes = statements.nodes; | 66 Link<Node> nodes = statements.nodes; |
79 if (nodes != null && !nodes.isEmpty) { | 67 if (nodes != null && !nodes.isEmpty) { |
80 indentMore(); | 68 indentMore(); |
81 newline(); | 69 newline(); |
82 visit(nodes.head); | 70 visit(nodes.head); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 } | 855 } |
868 | 856 |
869 visitStatement(Statement node) { | 857 visitStatement(Statement node) { |
870 throw 'internal error'; // Should not be called. | 858 throw 'internal error'; // Should not be called. |
871 } | 859 } |
872 | 860 |
873 visitStringNode(StringNode node) { | 861 visitStringNode(StringNode node) { |
874 throw 'internal error'; // Should not be called. | 862 throw 'internal error'; // Should not be called. |
875 } | 863 } |
876 } | 864 } |
OLD | NEW |