| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 visitSend(Send node) { | 263 visitSend(Send node) { |
| 264 Operator op = node.selector.asOperator(); | 264 Operator op = node.selector.asOperator(); |
| 265 String opString = op !== null ? op.source.stringValue : null; | 265 String opString = op !== null ? op.source.stringValue : null; |
| 266 bool spacesNeeded = opString === 'is' || opString === 'as'; | 266 bool spacesNeeded = opString === 'is' || opString === 'as'; |
| 267 | 267 |
| 268 if (node.isPrefix) visit(node.selector); | 268 if (node.isPrefix) visit(node.selector); |
| 269 unparseSendReceiver(node, spacesNeeded: spacesNeeded); | 269 unparseSendReceiver(node, spacesNeeded: spacesNeeded); |
| 270 if (!node.isPrefix && !node.isIndex) visit(node.selector); | 270 if (!node.isPrefix && !node.isIndex) visit(node.selector); |
| 271 if (spacesNeeded) sb.add(' '); | 271 if (spacesNeeded) sb.add(' '); |
| 272 // Also add a space for sequences like x + +1 and y - -y. | 272 // Also add a space for sequences like x + +1 and y - -y. |
| 273 if (opString === '-' || opString === '+') { | 273 // TODO(ahe): remove case for '+' when we drop the support for it. |
| 274 if (node.argumentsNode != null && (opString === '-' || opString === '+')) { |
| 274 Token beginToken = node.argumentsNode.getBeginToken(); | 275 Token beginToken = node.argumentsNode.getBeginToken(); |
| 275 if (beginToken !== null && beginToken.stringValue === opString) { | 276 if (beginToken !== null && beginToken.stringValue === opString) { |
| 276 sb.add(' '); | 277 sb.add(' '); |
| 277 } | 278 } |
| 278 } | 279 } |
| 279 visit(node.argumentsNode); | 280 visit(node.argumentsNode); |
| 280 } | 281 } |
| 281 | 282 |
| 282 visitSendSet(SendSet node) { | 283 visitSendSet(SendSet node) { |
| 283 if (node.isPrefix) { | 284 if (node.isPrefix) { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 589 } |
| 589 | 590 |
| 590 visitStatement(Statement node) { | 591 visitStatement(Statement node) { |
| 591 throw 'internal error'; // Should not be called. | 592 throw 'internal error'; // Should not be called. |
| 592 } | 593 } |
| 593 | 594 |
| 594 visitStringNode(StringNode node) { | 595 visitStringNode(StringNode node) { |
| 595 throw 'internal error'; // Should not be called. | 596 throw 'internal error'; // Should not be called. |
| 596 } | 597 } |
| 597 } | 598 } |
| OLD | NEW |