| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /** | 5 /** |
| 6 * Defines the AST model. The AST (Abstract Syntax Tree) model describes the | 6 * Defines the AST model. The AST (Abstract Syntax Tree) model describes the |
| 7 * syntactic (as opposed to semantic) structure of Dart code. The semantic | 7 * syntactic (as opposed to semantic) structure of Dart code. The semantic |
| 8 * structure of the code is modeled by the | 8 * structure of the code is modeled by the |
| 9 * [element model](../element/element.dart). | 9 * [element model](../element/element.dart). |
| 10 * | 10 * |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 * the left-hand-side to the given [element]. | 503 * the left-hand-side to the given [element]. |
| 504 */ | 504 */ |
| 505 void set staticElement(MethodElement element); | 505 void set staticElement(MethodElement element); |
| 506 } | 506 } |
| 507 | 507 |
| 508 /** | 508 /** |
| 509 * A node in the AST structure for a Dart program. | 509 * A node in the AST structure for a Dart program. |
| 510 * | 510 * |
| 511 * Clients may not extend, implement or mix-in this class. | 511 * Clients may not extend, implement or mix-in this class. |
| 512 */ | 512 */ |
| 513 abstract class AstNode { | 513 abstract class AstNode implements SyntacticEntity { |
| 514 /** | 514 /** |
| 515 * An empty list of AST nodes. | 515 * An empty list of AST nodes. |
| 516 */ | 516 */ |
| 517 static const List<AstNode> EMPTY_LIST = const <AstNode>[]; | 517 static const List<AstNode> EMPTY_LIST = const <AstNode>[]; |
| 518 | 518 |
| 519 /** | 519 /** |
| 520 * A comparator that can be used to sort AST nodes in lexical order. In other | 520 * A comparator that can be used to sort AST nodes in lexical order. In other |
| 521 * words, `compare` will return a negative value if the offset of the first | 521 * words, `compare` will return a negative value if the offset of the first |
| 522 * node is less than the offset of the second node, zero (0) if the nodes have | 522 * node is less than the offset of the second node, zero (0) if the nodes have |
| 523 * the same offset, and a positive value if the offset of the first node is | 523 * the same offset, and a positive value if the offset of the first node is |
| 524 * greater than the offset of the second node. | 524 * greater than the offset of the second node. |
| 525 */ | 525 */ |
| 526 static Comparator<AstNode> LEXICAL_ORDER = | 526 static Comparator<AstNode> LEXICAL_ORDER = |
| 527 (AstNode first, AstNode second) => first.offset - second.offset; | 527 (AstNode first, AstNode second) => first.offset - second.offset; |
| 528 | 528 |
| 529 /** | 529 /** |
| 530 * Return the first token included in this node's source range. | 530 * Return the first token included in this node's source range. |
| 531 */ | 531 */ |
| 532 Token get beginToken; | 532 Token get beginToken; |
| 533 | 533 |
| 534 /** | 534 /** |
| 535 * Return an iterator that can be used to iterate through all the entities | 535 * Return an iterator that can be used to iterate through all the entities |
| 536 * (either AST nodes or tokens) that make up the contents of this node, | 536 * (either AST nodes or tokens) that make up the contents of this node, |
| 537 * including doc comments but excluding other comments. | 537 * including doc comments but excluding other comments. |
| 538 */ | 538 */ |
| 539 Iterable /* AstNode | Token */ get childEntities; | 539 Iterable<SyntacticEntity> get childEntities; |
| 540 | 540 |
| 541 /** | 541 /** |
| 542 * Return the offset of the character immediately following the last character | 542 * Return the offset of the character immediately following the last character |
| 543 * of this node's source range. This is equivalent to | 543 * of this node's source range. This is equivalent to |
| 544 * `node.getOffset() + node.getLength()`. For a compilation unit this will be | 544 * `node.getOffset() + node.getLength()`. For a compilation unit this will be |
| 545 * equal to the length of the unit's source. For synthetic nodes this will be | 545 * equal to the length of the unit's source. For synthetic nodes this will be |
| 546 * equivalent to the node's offset (because the length is zero (0) by | 546 * equivalent to the node's offset (because the length is zero (0) by |
| 547 * definition). | 547 * definition). |
| 548 */ | 548 */ |
| 549 @override |
| 549 int get end; | 550 int get end; |
| 550 | 551 |
| 551 /** | 552 /** |
| 552 * Return the last token included in this node's source range. | 553 * Return the last token included in this node's source range. |
| 553 */ | 554 */ |
| 554 Token get endToken; | 555 Token get endToken; |
| 555 | 556 |
| 556 /** | 557 /** |
| 557 * Return `true` if this node is a synthetic node. A synthetic node is a node | 558 * Return `true` if this node is a synthetic node. A synthetic node is a node |
| 558 * that was introduced by the parser in order to recover from an error in the | 559 * that was introduced by the parser in order to recover from an error in the |
| 559 * code. Synthetic nodes always have a length of zero (`0`). | 560 * code. Synthetic nodes always have a length of zero (`0`). |
| 560 */ | 561 */ |
| 561 bool get isSynthetic; | 562 bool get isSynthetic; |
| 562 | 563 |
| 563 /** | 564 @override |
| 564 * Return the number of characters in the node's source range. | |
| 565 */ | |
| 566 int get length; | 565 int get length; |
| 567 | 566 |
| 568 /** | 567 @override |
| 569 * Return the offset from the beginning of the file to the first character in | |
| 570 * the node's source range. | |
| 571 */ | |
| 572 int get offset; | 568 int get offset; |
| 573 | 569 |
| 574 /** | 570 /** |
| 575 * Return this node's parent node, or `null` if this node is the root of an | 571 * Return this node's parent node, or `null` if this node is the root of an |
| 576 * AST structure. | 572 * AST structure. |
| 577 * | 573 * |
| 578 * Note that the relationship between an AST node and its parent node may | 574 * Note that the relationship between an AST node and its parent node may |
| 579 * change over the lifetime of a node. | 575 * change over the lifetime of a node. |
| 580 */ | 576 */ |
| 581 AstNode get parent; | 577 AstNode get parent; |
| (...skipping 7736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8318 /** | 8314 /** |
| 8319 * Return the 'yield' keyword. | 8315 * Return the 'yield' keyword. |
| 8320 */ | 8316 */ |
| 8321 Token get yieldKeyword; | 8317 Token get yieldKeyword; |
| 8322 | 8318 |
| 8323 /** | 8319 /** |
| 8324 * Return the 'yield' keyword to the given [token]. | 8320 * Return the 'yield' keyword to the given [token]. |
| 8325 */ | 8321 */ |
| 8326 void set yieldKeyword(Token token); | 8322 void set yieldKeyword(Token token); |
| 8327 } | 8323 } |
| OLD | NEW |