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

Side by Side Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10383311: Support proper unparse of is and is!. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class Unparser implements Visitor { 5 class Unparser implements Visitor {
6 StringBuffer sb; 6 StringBuffer sb;
7 final bool printDebugInfo; 7 final bool printDebugInfo;
8 8
9 Unparser([this.printDebugInfo = false]); 9 Unparser([this.printDebugInfo = false]);
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 add(node.beginToken.value); 174 add(node.beginToken.value);
175 if (node.hasExpression) { 175 if (node.hasExpression) {
176 sb.add(' '); 176 sb.add(' ');
177 visit(node.expression); 177 visit(node.expression);
178 } 178 }
179 if (node.endToken !== null) add(node.endToken.value); 179 if (node.endToken !== null) add(node.endToken.value);
180 } 180 }
181 181
182 182
183 unparseSendPart(Send node) { 183 unparseSendPart(Send node) {
184 Operator op = node.selector.asOperator();
185 bool isCheck = op !== null && op.source.stringValue == 'is';
186 // is check requires trailing space if it's not is! form.
ahe 2012/05/29 13:40:07 Not a proper sentence. First word should be capita
Anton Muhin 2012/05/31 14:44:44 Now obsolete.
187 bool requiresSpace = isCheck && node.arguments.head is! Send;
ahe 2012/05/29 13:40:07 The style we use is this: node.arguments.head is
Bob Nystrom 2012/05/30 21:46:51 This was a surprise to me. In SEA I think we all u
Anton Muhin 2012/05/31 14:44:44 That was a surprise for me as well. On 2012/05/30
188
184 if (node.isPrefix) { 189 if (node.isPrefix) {
185 visit(node.selector); 190 visit(node.selector);
186 } 191 }
187 if (node.receiver !== null) { 192 if (node.receiver !== null) {
188 visit(node.receiver); 193 visit(node.receiver);
189 if (node.selector is !Operator) sb.add('.'); 194 if (op === null) {
195 sb.add('.');
196 } else if (isCheck) {
197 sb.add(' ');
198 }
190 } 199 }
191 if (!node.isPrefix) { 200 if (!node.isPrefix) {
192 visit(node.selector); 201 visit(node.selector);
193 } 202 }
203 if (requiresSpace) {
ahe 2012/05/29 13:40:07 This expression: 1 is !Object Is printed as: 1
Anton Muhin 2012/05/31 14:44:44 Yes, that was planned as I thought that preferred
204 sb.add(' ');
205 }
194 } 206 }
195 207
196 visitSend(Send node) { 208 visitSend(Send node) {
197 unparseSendPart(node); 209 unparseSendPart(node);
198 visit(node.argumentsNode); 210 visit(node.argumentsNode);
199 } 211 }
200 212
201 visitSendSet(SendSet node) { 213 visitSendSet(SendSet node) {
202 unparseSendPart(node); 214 unparseSendPart(node);
203 add(node.assignmentOperator.token.value); 215 add(node.assignmentOperator.token.value);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 sb.add(' '); 415 sb.add(' ');
404 } 416 }
405 visit(node.name); 417 visit(node.name);
406 if (node.typeParameters !== null) { 418 if (node.typeParameters !== null) {
407 visit(node.typeParameters); 419 visit(node.typeParameters);
408 } 420 }
409 visit(node.formals); 421 visit(node.formals);
410 add(node.endToken.value); 422 add(node.endToken.value);
411 } 423 }
412 } 424 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698