Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(812)

Unified Diff: lib/compiler/implementation/tree/unparser.dart

Issue 11039020: Properly unparse sequences like x + +1 and x - -1. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/tree/unparser.dart
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index a1d0fad161293cc63ed5aa3fc20af1c23fbcb288..3e868de6db70d8b8a7d1bfe4dc27c7880c6c3cdc 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -279,13 +279,18 @@ class Unparser implements Visitor {
visitSend(Send node) {
Operator op = node.selector.asOperator();
- bool spacesNeeded = op !== null &&
- (op.source.stringValue === 'is' || op.source.stringValue == 'as');
+ String opString = op !== null ? op.source.stringValue : null;
+ bool spacesNeeded = opString === 'is' || opString === 'as';
if (node.isPrefix) visit(node.selector);
unparseSendReceiver(node, spacesNeeded: spacesNeeded);
if (!node.isPrefix && !node.isIndex) visit(node.selector);
if (spacesNeeded) sb.add(' ');
+ // Also add a space for sequences like x + +1 and y - -y.
+ if (opString === '-' || opString === '+') {
+ Token beginToken = node.argumentsNode.getBeginToken();
+ if (beginToken !== null && beginToken.stringValue === opString) sb.add(' ');
Roman 2012/10/02 13:22:24 80 chars
+ }
visit(node.argumentsNode);
}
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698