Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Unified Diff: pkg/analyzer/lib/src/dart/ast/ast.dart

Issue 2492633002: Create AST structure for asserts in constructor initializers (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/dart/ast/visitor.dart ('k') | pkg/analyzer/lib/src/dart/ast/utilities.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/ast/ast.dart
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index 930cebfb1b7a9e40e94cbfe3c27ccec78793f501..9275ee54022408949dfd167fcb70c3571ccc0b85 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -558,21 +558,102 @@ class AsExpressionImpl extends ExpressionImpl implements AsExpression {
}
/**
+ * An assert in the initializer list of a constructor.
+ *
+ * assertInitializer ::=
+ * 'assert' '(' [Expression] (',' [Expression])? ')'
+ */
+class AssertInitializerImpl extends ConstructorInitializerImpl
+ implements AssertInitializer {
+ @override
+ Token assertKeyword;
+
+ @override
+ Token leftParenthesis;
+
+ /**
+ * The condition that is being asserted to be `true`.
+ */
+ Expression _condition;
+
+ @override
+ Token comma;
+
+ /**
+ * The message to report if the assertion fails, or `null` if no message was
+ * supplied.
+ */
+ Expression _message;
+
+ @override
+ Token rightParenthesis;
+
+ /**
+ * Initialize a newly created assert initializer.
+ */
+ AssertInitializerImpl(
+ this.assertKeyword,
+ this.leftParenthesis,
+ ExpressionImpl condition,
+ this.comma,
+ ExpressionImpl message,
+ this.rightParenthesis) {
+ _condition = _becomeParentOf(condition);
+ _message = _becomeParentOf(message);
+ }
+
+ @override
+ Token get beginToken => assertKeyword;
+
+ @override
+ Iterable get childEntities => new ChildEntities()
+ ..add(assertKeyword)
+ ..add(leftParenthesis)
+ ..add(_condition)
+ ..add(comma)
+ ..add(_message)
+ ..add(rightParenthesis);
+
+ @override
+ Expression get condition => _condition;
+
+ @override
+ void set condition(Expression condition) {
+ _condition = _becomeParentOf(condition as AstNodeImpl);
+ }
+
+ @override
+ Token get endToken => rightParenthesis;
+
+ @override
+ Expression get message => _message;
+
+ @override
+ void set message(Expression expression) {
+ _message = _becomeParentOf(expression as AstNodeImpl);
+ }
+
+ @override
+ dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) =>
+ visitor.visitAssertInitializer(this);
+
+ @override
+ void visitChildren(AstVisitor visitor) {
+ _condition?.accept(visitor);
+ message?.accept(visitor);
+ }
+}
+
+/**
* An assert statement.
*
* assertStatement ::=
* 'assert' '(' [Expression] ')' ';'
*/
class AssertStatementImpl extends StatementImpl implements AssertStatement {
- /**
- * The token representing the 'assert' keyword.
- */
@override
Token assertKeyword;
- /**
- * The left parenthesis.
- */
@override
Token leftParenthesis;
@@ -581,27 +662,18 @@ class AssertStatementImpl extends StatementImpl implements AssertStatement {
*/
Expression _condition;
- /**
- * The comma, if a message expression was supplied. Otherwise `null`.
- */
@override
Token comma;
/**
- * The message to report if the assertion fails. `null` if no message was
+ * The message to report if the assertion fails, or `null` if no message was
* supplied.
*/
Expression _message;
- /**
- * The right parenthesis.
- */
@override
Token rightParenthesis;
- /**
- * The semicolon terminating the statement.
- */
@override
Token semicolon;
« no previous file with comments | « pkg/analyzer/lib/dart/ast/visitor.dart ('k') | pkg/analyzer/lib/src/dart/ast/utilities.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698