| 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, {minify: true}) { | 7 String unparse(Node node, {minify: true}) { |
| 8 Unparser unparser = new Unparser(minify: minify); | 8 Unparser unparser = new Unparser(minify: minify); |
| 9 unparser.unparse(node); | 9 unparser.unparse(node); |
| 10 return unparser.result; | 10 return unparser.result; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 unparseFunctionName(node.name); | 247 unparseFunctionName(node.name); |
| 248 visit(node.parameters); | 248 visit(node.parameters); |
| 249 if (node.initializers != null) { | 249 if (node.initializers != null) { |
| 250 space(); | 250 space(); |
| 251 write(':'); | 251 write(':'); |
| 252 space(); | 252 space(); |
| 253 unparseNodeListFrom(node.initializers, node.initializers.nodes, | 253 unparseNodeListFrom(node.initializers, node.initializers.nodes, |
| 254 spaces: true); | 254 spaces: true); |
| 255 } | 255 } |
| 256 visit(node.asyncModifier); | 256 if (node.asyncModifier != null) { |
| 257 if (node.body != null && node.body is! EmptyStatement) space(); | 257 if (node.getOrSet != null) { |
| 258 write(' '); |
| 259 } else { |
| 260 // Space is optional if this is not a getter. |
| 261 space(); |
| 262 } |
| 263 visit(node.asyncModifier); |
| 264 } |
| 265 if (node.body != null && node.body is! EmptyStatement) { |
| 266 space(); |
| 267 } |
| 258 visit(node.body); | 268 visit(node.body); |
| 259 } | 269 } |
| 260 | 270 |
| 261 visitIdentifier(Identifier node) { | 271 visitIdentifier(Identifier node) { |
| 262 write(node.token.value); | 272 write(node.token.value); |
| 263 } | 273 } |
| 264 | 274 |
| 265 visitIf(If node) { | 275 visitIf(If node) { |
| 266 write(node.ifToken.value); | 276 write(node.ifToken.value); |
| 267 space(); | 277 space(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 write(node.beginToken.value); | 397 write(node.beginToken.value); |
| 388 if (node.hasExpression && node.beginToken.stringValue != '=>') { | 398 if (node.hasExpression && node.beginToken.stringValue != '=>') { |
| 389 write(' '); | 399 write(' '); |
| 390 } | 400 } |
| 391 if (node.beginToken.stringValue == '=>') space(); | 401 if (node.beginToken.stringValue == '=>') space(); |
| 392 visit(node.expression); | 402 visit(node.expression); |
| 393 if (node.endToken != null) write(node.endToken.value); | 403 if (node.endToken != null) write(node.endToken.value); |
| 394 } | 404 } |
| 395 | 405 |
| 396 visitYield(Yield node) { | 406 visitYield(Yield node) { |
| 397 write(node.yieldToken); | 407 write(node.yieldToken.value); |
| 398 write(node.starToken); | 408 if (node.starToken != null) { |
| 409 write(node.starToken.value); |
| 410 } |
| 399 space(); | 411 space(); |
| 400 visit(node.expression); | 412 visit(node.expression); |
| 401 write(node.endToken); | 413 write(node.endToken.value); |
| 402 } | 414 } |
| 403 | 415 |
| 404 | 416 |
| 405 unparseSendReceiver(Send node, {bool spacesNeeded: false}) { | 417 unparseSendReceiver(Send node, {bool spacesNeeded: false}) { |
| 406 if (node.receiver == null) return; | 418 if (node.receiver == null) return; |
| 407 visit(node.receiver); | 419 visit(node.receiver); |
| 408 CascadeReceiver asCascadeReceiver = node.receiver.asCascadeReceiver(); | 420 CascadeReceiver asCascadeReceiver = node.receiver.asCascadeReceiver(); |
| 409 if (asCascadeReceiver != null) { | 421 if (asCascadeReceiver != null) { |
| 410 newline(); | 422 newline(); |
| 411 indentMore(); | 423 indentMore(); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 } | 840 } |
| 829 | 841 |
| 830 visitStatement(Statement node) { | 842 visitStatement(Statement node) { |
| 831 throw 'internal error'; // Should not be called. | 843 throw 'internal error'; // Should not be called. |
| 832 } | 844 } |
| 833 | 845 |
| 834 visitStringNode(StringNode node) { | 846 visitStringNode(StringNode node) { |
| 835 throw 'internal error'; // Should not be called. | 847 throw 'internal error'; // Should not be called. |
| 836 } | 848 } |
| 837 } | 849 } |
| OLD | NEW |