| 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) { | 7 String unparse(Node node) { |
| 8 Unparser unparser = new Unparser(); | 8 Unparser unparser = new Unparser(); |
| 9 unparser.unparse(node); | 9 unparser.unparse(node); |
| 10 return unparser.result; | 10 return unparser.result; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } else if (spacesNeeded) { | 294 } else if (spacesNeeded) { |
| 295 sb.write(' '); | 295 sb.write(' '); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 visitSend(Send node) { | 299 visitSend(Send node) { |
| 300 Operator op = node.selector.asOperator(); | 300 Operator op = node.selector.asOperator(); |
| 301 String opString = op != null ? op.source : null; | 301 String opString = op != null ? op.source : null; |
| 302 bool spacesNeeded = identical(opString, 'is') || identical(opString, 'as'); | 302 bool spacesNeeded = identical(opString, 'is') || identical(opString, 'as'); |
| 303 | 303 |
| 304 if (node.isPrefix) visit(node.selector); | 304 if (node.isPrefix) { |
| 305 visit(node.selector); |
| 306 // Add a space for sequences like - -x (double unary minus). |
| 307 if (identical(opString, '-')) { |
| 308 Token beginToken = node.receiver.getBeginToken(); |
| 309 if (identical(beginToken.stringValue, opString)) { |
| 310 sb.write(' '); |
| 311 } |
| 312 } |
| 313 } |
| 305 unparseSendReceiver(node, spacesNeeded: spacesNeeded); | 314 unparseSendReceiver(node, spacesNeeded: spacesNeeded); |
| 306 if (!node.isPrefix && !node.isIndex) visit(node.selector); | 315 if (!node.isPrefix && !node.isIndex) visit(node.selector); |
| 307 if (spacesNeeded) sb.write(' '); | 316 if (spacesNeeded) sb.write(' '); |
| 308 // Also add a space for sequences like x + +1 and y - -y. | 317 // Also add a space for sequences like y - -y. |
| 309 // TODO(ahe): remove case for '+' when we drop the support for it. | 318 if (node.argumentsNode != null && identical(opString, '-')) { |
| 310 if (node.argumentsNode != null && (identical(opString, '-') | |
| 311 || identical(opString, '+'))) { | |
| 312 Token beginToken = node.argumentsNode.getBeginToken(); | 319 Token beginToken = node.argumentsNode.getBeginToken(); |
| 313 if (beginToken != null && identical(beginToken.stringValue, opString)) { | 320 if (beginToken != null && identical(beginToken.stringValue, opString)) { |
| 314 sb.write(' '); | 321 sb.write(' '); |
| 315 } | 322 } |
| 316 } | 323 } |
| 317 visit(node.argumentsNode); | 324 visit(node.argumentsNode); |
| 318 } | 325 } |
| 319 | 326 |
| 320 visitSendSet(SendSet node) { | 327 visitSendSet(SendSet node) { |
| 321 if (node.isPrefix) { | 328 if (node.isPrefix) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 624 } |
| 618 | 625 |
| 619 visitStatement(Statement node) { | 626 visitStatement(Statement node) { |
| 620 throw 'internal error'; // Should not be called. | 627 throw 'internal error'; // Should not be called. |
| 621 } | 628 } |
| 622 | 629 |
| 623 visitStringNode(StringNode node) { | 630 visitStringNode(StringNode node) { |
| 624 throw 'internal error'; // Should not be called. | 631 throw 'internal error'; // Should not be called. |
| 625 } | 632 } |
| 626 } | 633 } |
| OLD | NEW |