| 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 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 visitReturn(Return node) { | 180 visitReturn(Return node) { |
| 181 add(node.beginToken.value); | 181 add(node.beginToken.value); |
| 182 if (node.hasExpression) { | 182 if (node.hasExpression) { |
| 183 sb.add(' '); | 183 sb.add(' '); |
| 184 visit(node.expression); | 184 visit(node.expression); |
| 185 } | 185 } |
| 186 if (node.endToken !== null) add(node.endToken.value); | 186 if (node.endToken !== null) add(node.endToken.value); |
| 187 } | 187 } |
| 188 | 188 |
| 189 unparseSendPart(Send node) { | 189 unparseSendPart(Send node) { |
| 190 Operator op = node.selector.asOperator(); |
| 191 bool isCheck = op !== null && op.source.stringValue == 'is'; |
| 192 |
| 190 if (node.isPrefix) { | 193 if (node.isPrefix) { |
| 191 visit(node.selector); | 194 visit(node.selector); |
| 192 } | 195 } |
| 193 if (node.receiver !== null) { | 196 if (node.receiver !== null) { |
| 194 visit(node.receiver); | 197 visit(node.receiver); |
| 195 if (node.selector is !Operator) sb.add('.'); | 198 if (op === null) { |
| 199 sb.add('.'); |
| 200 } else if (isCheck) { |
| 201 sb.add(' '); |
| 202 } |
| 196 } | 203 } |
| 197 if (!node.isPrefix && !node.isIndex) { | 204 if (!node.isPrefix && !node.isIndex) { |
| 198 visit(node.selector); | 205 visit(node.selector); |
| 199 } | 206 } |
| 207 if (isCheck) { |
| 208 sb.add(' '); |
| 209 } |
| 200 } | 210 } |
| 201 | 211 |
| 202 visitSend(Send node) { | 212 visitSend(Send node) { |
| 203 unparseSendPart(node); | 213 unparseSendPart(node); |
| 204 visit(node.argumentsNode); | 214 visit(node.argumentsNode); |
| 205 } | 215 } |
| 206 | 216 |
| 207 /** | 217 /** |
| 208 * Special case for assignments like "list[0] = 1". | 218 * Special case for assignments like "list[0] = 1". |
| 209 */ | 219 */ |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 sb.add(' '); | 435 sb.add(' '); |
| 426 } | 436 } |
| 427 visit(node.name); | 437 visit(node.name); |
| 428 if (node.typeParameters !== null) { | 438 if (node.typeParameters !== null) { |
| 429 visit(node.typeParameters); | 439 visit(node.typeParameters); |
| 430 } | 440 } |
| 431 visit(node.formals); | 441 visit(node.formals); |
| 432 add(node.endToken.value); | 442 add(node.endToken.value); |
| 433 } | 443 } |
| 434 } | 444 } |
| OLD | NEW |