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 interface Visitor<R> { | 5 interface Visitor<R> { |
6 R visitBlock(Block node); | 6 R visitBlock(Block node); |
7 R visitBreakStatement(BreakStatement node); | 7 R visitBreakStatement(BreakStatement node); |
8 R visitCascade(Cascade node); | 8 R visitCascade(Cascade node); |
9 R visitCascadeReceiver(CascadeReceiver node); | 9 R visitCascadeReceiver(CascadeReceiver node); |
10 R visitCaseMatch(CaseMatch node); | 10 R visitCaseMatch(CaseMatch node); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 visitChildren(Visitor visitor) { | 379 visitChildren(Visitor visitor) { |
380 if (send !== null) send.accept(visitor); | 380 if (send !== null) send.accept(visitor); |
381 } | 381 } |
382 | 382 |
383 bool isConst() => newToken.stringValue === 'const'; | 383 bool isConst() => newToken.stringValue === 'const'; |
384 | 384 |
385 Token getBeginToken() => newToken; | 385 Token getBeginToken() => newToken; |
386 | 386 |
387 Token getEndToken() => send.getEndToken(); | 387 Token getEndToken() => send.getEndToken(); |
| 388 |
| 389 /** |
| 390 * Returns the type annotation of this new expression. The type annotation |
| 391 * is either the `send.selector` for invocations of unnamed constructors like |
| 392 * `new Class()`, or `send.selector.receiver` for named constructors like |
| 393 * `new Class.named()`. |
| 394 */ |
| 395 TypeAnnotation getTypeAnnotation() { |
| 396 if (send.selector.asTypeAnnotation() !== null) { |
| 397 return send.selector; |
| 398 } else if (send.selector.asSend() !== null) { |
| 399 Send selector = send.selector; |
| 400 if (selector.receiver.asTypeAnnotation() !== null) { |
| 401 return selector.receiver; |
| 402 } |
| 403 } else { |
| 404 return null; |
| 405 } |
| 406 } |
388 } | 407 } |
389 | 408 |
390 class NodeList extends Node implements Iterable<Node> { | 409 class NodeList extends Node implements Iterable<Node> { |
391 final Link<Node> nodes; | 410 final Link<Node> nodes; |
392 final Token beginToken; | 411 final Token beginToken; |
393 final Token endToken; | 412 final Token endToken; |
394 final SourceString delimiter; | 413 final SourceString delimiter; |
395 bool isEmpty() => nodes.isEmpty(); | 414 bool isEmpty() => nodes.isEmpty(); |
396 | 415 |
397 NodeList([this.beginToken, this.nodes, this.endToken, this.delimiter]); | 416 NodeList([this.beginToken, this.nodes, this.endToken, this.delimiter]); |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 * argument). | 1768 * argument). |
1750 * | 1769 * |
1751 * TODO(ahe): This method is controversial, the team needs to discuss | 1770 * TODO(ahe): This method is controversial, the team needs to discuss |
1752 * if top-level methods are acceptable and what naming conventions to | 1771 * if top-level methods are acceptable and what naming conventions to |
1753 * use. | 1772 * use. |
1754 */ | 1773 */ |
1755 initializerDo(Node node, f(Node node)) { | 1774 initializerDo(Node node, f(Node node)) { |
1756 SendSet send = node.asSendSet(); | 1775 SendSet send = node.asSendSet(); |
1757 if (send !== null) return f(send.arguments.head); | 1776 if (send !== null) return f(send.arguments.head); |
1758 } | 1777 } |
OLD | NEW |