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 String unparse(Node node) { | 5 String unparse(Node node) { |
6 Unparser unparser = new Unparser(); | 6 Unparser unparser = new Unparser(); |
7 unparser.unparse(node); | 7 unparser.unparse(node); |
8 return unparser.result; | 8 return unparser.result; |
9 } | 9 } |
10 | 10 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 sb.add(' '); | 240 sb.add(' '); |
241 } | 241 } |
242 add(node.beginToken.value); | 242 add(node.beginToken.value); |
243 if (node.hasExpression && node.beginToken.stringValue != '=>') { | 243 if (node.hasExpression && node.beginToken.stringValue != '=>') { |
244 sb.add(' '); | 244 sb.add(' '); |
245 } | 245 } |
246 visit(node.expression); | 246 visit(node.expression); |
247 if (node.endToken !== null) add(node.endToken.value); | 247 if (node.endToken !== null) add(node.endToken.value); |
248 } | 248 } |
249 | 249 |
250 unparseSendReceiver(Send node, [bool spacesNeeded=false]) { | 250 unparseSendReceiver(Send node, {bool spacesNeeded: false}) { |
251 if (node.receiver === null) return; | 251 if (node.receiver === null) return; |
252 visit(node.receiver); | 252 visit(node.receiver); |
253 CascadeReceiver asCascadeReceiver = node.receiver.asCascadeReceiver(); | 253 CascadeReceiver asCascadeReceiver = node.receiver.asCascadeReceiver(); |
254 if (asCascadeReceiver !== null) { | 254 if (asCascadeReceiver !== null) { |
255 add(asCascadeReceiver.cascadeOperator.value); | 255 add(asCascadeReceiver.cascadeOperator.value); |
256 } else if (node.selector.asOperator() === null) { | 256 } else if (node.selector.asOperator() === null) { |
257 sb.add('.'); | 257 sb.add('.'); |
258 } else if (spacesNeeded) { | 258 } else if (spacesNeeded) { |
259 sb.add(' '); | 259 sb.add(' '); |
260 } | 260 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 } | 589 } |
590 | 590 |
591 visitStatement(Statement node) { | 591 visitStatement(Statement node) { |
592 throw 'internal error'; // Should not be called. | 592 throw 'internal error'; // Should not be called. |
593 } | 593 } |
594 | 594 |
595 visitStringNode(StringNode node) { | 595 visitStringNode(StringNode node) { |
596 throw 'internal error'; // Should not be called. | 596 throw 'internal error'; // Should not be called. |
597 } | 597 } |
598 } | 598 } |
OLD | NEW |