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 library analyzer.src.dart.ast.ast; | 5 library analyzer.src.dart.ast.ast; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; | 10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 visitor.visitAsExpression(this); | 551 visitor.visitAsExpression(this); |
552 | 552 |
553 @override | 553 @override |
554 void visitChildren(AstVisitor visitor) { | 554 void visitChildren(AstVisitor visitor) { |
555 _expression?.accept(visitor); | 555 _expression?.accept(visitor); |
556 _type?.accept(visitor); | 556 _type?.accept(visitor); |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 /** | 560 /** |
| 561 * An assert in the initializer list of a constructor. |
| 562 * |
| 563 * assertInitializer ::= |
| 564 * 'assert' '(' [Expression] (',' [Expression])? ')' |
| 565 */ |
| 566 class AssertInitializerImpl extends ConstructorInitializerImpl |
| 567 implements AssertInitializer { |
| 568 @override |
| 569 Token assertKeyword; |
| 570 |
| 571 @override |
| 572 Token leftParenthesis; |
| 573 |
| 574 /** |
| 575 * The condition that is being asserted to be `true`. |
| 576 */ |
| 577 Expression _condition; |
| 578 |
| 579 @override |
| 580 Token comma; |
| 581 |
| 582 /** |
| 583 * The message to report if the assertion fails, or `null` if no message was |
| 584 * supplied. |
| 585 */ |
| 586 Expression _message; |
| 587 |
| 588 @override |
| 589 Token rightParenthesis; |
| 590 |
| 591 /** |
| 592 * Initialize a newly created assert initializer. |
| 593 */ |
| 594 AssertInitializerImpl( |
| 595 this.assertKeyword, |
| 596 this.leftParenthesis, |
| 597 ExpressionImpl condition, |
| 598 this.comma, |
| 599 ExpressionImpl message, |
| 600 this.rightParenthesis) { |
| 601 _condition = _becomeParentOf(condition); |
| 602 _message = _becomeParentOf(message); |
| 603 } |
| 604 |
| 605 @override |
| 606 Token get beginToken => assertKeyword; |
| 607 |
| 608 @override |
| 609 Iterable get childEntities => new ChildEntities() |
| 610 ..add(assertKeyword) |
| 611 ..add(leftParenthesis) |
| 612 ..add(_condition) |
| 613 ..add(comma) |
| 614 ..add(_message) |
| 615 ..add(rightParenthesis); |
| 616 |
| 617 @override |
| 618 Expression get condition => _condition; |
| 619 |
| 620 @override |
| 621 void set condition(Expression condition) { |
| 622 _condition = _becomeParentOf(condition as AstNodeImpl); |
| 623 } |
| 624 |
| 625 @override |
| 626 Token get endToken => rightParenthesis; |
| 627 |
| 628 @override |
| 629 Expression get message => _message; |
| 630 |
| 631 @override |
| 632 void set message(Expression expression) { |
| 633 _message = _becomeParentOf(expression as AstNodeImpl); |
| 634 } |
| 635 |
| 636 @override |
| 637 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => |
| 638 visitor.visitAssertInitializer(this); |
| 639 |
| 640 @override |
| 641 void visitChildren(AstVisitor visitor) { |
| 642 _condition?.accept(visitor); |
| 643 message?.accept(visitor); |
| 644 } |
| 645 } |
| 646 |
| 647 /** |
561 * An assert statement. | 648 * An assert statement. |
562 * | 649 * |
563 * assertStatement ::= | 650 * assertStatement ::= |
564 * 'assert' '(' [Expression] ')' ';' | 651 * 'assert' '(' [Expression] ')' ';' |
565 */ | 652 */ |
566 class AssertStatementImpl extends StatementImpl implements AssertStatement { | 653 class AssertStatementImpl extends StatementImpl implements AssertStatement { |
567 /** | |
568 * The token representing the 'assert' keyword. | |
569 */ | |
570 @override | 654 @override |
571 Token assertKeyword; | 655 Token assertKeyword; |
572 | 656 |
573 /** | |
574 * The left parenthesis. | |
575 */ | |
576 @override | 657 @override |
577 Token leftParenthesis; | 658 Token leftParenthesis; |
578 | 659 |
579 /** | 660 /** |
580 * The condition that is being asserted to be `true`. | 661 * The condition that is being asserted to be `true`. |
581 */ | 662 */ |
582 Expression _condition; | 663 Expression _condition; |
583 | 664 |
584 /** | |
585 * The comma, if a message expression was supplied. Otherwise `null`. | |
586 */ | |
587 @override | 665 @override |
588 Token comma; | 666 Token comma; |
589 | 667 |
590 /** | 668 /** |
591 * The message to report if the assertion fails. `null` if no message was | 669 * The message to report if the assertion fails, or `null` if no message was |
592 * supplied. | 670 * supplied. |
593 */ | 671 */ |
594 Expression _message; | 672 Expression _message; |
595 | 673 |
596 /** | |
597 * The right parenthesis. | |
598 */ | |
599 @override | 674 @override |
600 Token rightParenthesis; | 675 Token rightParenthesis; |
601 | 676 |
602 /** | |
603 * The semicolon terminating the statement. | |
604 */ | |
605 @override | 677 @override |
606 Token semicolon; | 678 Token semicolon; |
607 | 679 |
608 /** | 680 /** |
609 * Initialize a newly created assert statement. | 681 * Initialize a newly created assert statement. |
610 */ | 682 */ |
611 AssertStatementImpl( | 683 AssertStatementImpl( |
612 this.assertKeyword, | 684 this.assertKeyword, |
613 this.leftParenthesis, | 685 this.leftParenthesis, |
614 ExpressionImpl condition, | 686 ExpressionImpl condition, |
(...skipping 10511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11126 | 11198 |
11127 @override | 11199 @override |
11128 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => | 11200 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => |
11129 visitor.visitYieldStatement(this); | 11201 visitor.visitYieldStatement(this); |
11130 | 11202 |
11131 @override | 11203 @override |
11132 void visitChildren(AstVisitor visitor) { | 11204 void visitChildren(AstVisitor visitor) { |
11133 _expression?.accept(visitor); | 11205 _expression?.accept(visitor); |
11134 } | 11206 } |
11135 } | 11207 } |
OLD | NEW |