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

Unified Diff: pkg/analyzer/lib/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 | « no previous file | pkg/analyzer/lib/dart/ast/visitor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/dart/ast/ast.dart
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 7ec7be4964446c543bd9d04335d84b043ea7cad1..b027e4cab14089edde6ed6282fa13d0f265c30e3 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -323,29 +323,35 @@ abstract class AsExpression extends Expression {
}
/**
- * An assert statement.
+ * An assert in the initializer list of a constructor.
*
- * assertStatement ::=
- * 'assert' '(' [Expression] ')' ';'
+ * assertInitializer ::=
+ * 'assert' '(' [Expression] (',' [Expression])? ')'
*
* Clients may not extend, implement or mix-in this class.
*/
-abstract class AssertStatement extends Statement {
+abstract class AssertInitializer implements Assertion, ConstructorInitializer {
/**
- * Initialize a newly created assert statement. The [comma] and [message] can
- * be `null` if there is no message.
+ * Initialize a newly created assert initializer. The [comma] and [message]
+ * can be `null` if there is no message.
*/
- factory AssertStatement(
+ factory AssertInitializer(
Token assertKeyword,
Token leftParenthesis,
Expression condition,
Token comma,
Expression message,
- Token rightParenthesis,
- Token semicolon) =>
- new AssertStatementImpl(assertKeyword, leftParenthesis, condition, comma,
- message, rightParenthesis, semicolon);
+ Token rightParenthesis) =>
+ new AssertInitializerImpl(assertKeyword, leftParenthesis, condition,
+ comma, message, rightParenthesis);
+}
+/**
+ * An assertion, either in a block or in the initializer list of a constructor.
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+abstract class Assertion implements AstNode {
/**
* Return the token representing the 'assert' keyword.
*/
@@ -363,7 +369,8 @@ abstract class AssertStatement extends Statement {
Token get comma;
/**
- * Set the comma between the [condition] and the [message] to the given [token].
+ * Set the comma between the [condition] and the [message] to the given
+ * [token].
*/
void set comma(Token token);
@@ -409,6 +416,31 @@ abstract class AssertStatement extends Statement {
* Set the right parenthesis to the given [token].
*/
void set rightParenthesis(Token token);
+}
+
+/**
+ * An assert statement.
+ *
+ * assertStatement ::=
+ * 'assert' '(' [Expression] (',' [Expression])? ')' ';'
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+abstract class AssertStatement implements Assertion, Statement {
+ /**
+ * Initialize a newly created assert statement. The [comma] and [message] can
+ * be `null` if there is no message.
+ */
+ factory AssertStatement(
+ Token assertKeyword,
+ Token leftParenthesis,
+ Expression condition,
+ Token comma,
+ Expression message,
+ Token rightParenthesis,
+ Token semicolon) =>
+ new AssertStatementImpl(assertKeyword, leftParenthesis, condition, comma,
+ message, rightParenthesis, semicolon);
/**
* Return the semicolon terminating the statement.
@@ -638,6 +670,8 @@ abstract class AstVisitor<R> {
R visitAsExpression(AsExpression node);
+ R visitAssertInitializer(AssertInitializer node);
+
R visitAssertStatement(AssertStatement assertStatement);
R visitAssignmentExpression(AssignmentExpression node);
« no previous file with comments | « no previous file | pkg/analyzer/lib/dart/ast/visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698