@@ -7481,30 +7481,14 @@ final class ForEachPartsWithPatternImpl extends ForEachPartsImpl
7481
7481
7482
7482
/// The basic structure of a for element.
7483
7483
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
7484
- abstract final class ForElement implements CollectionElement {
7485
- /// The token representing the `await` keyword, or `null` if there was no
7486
- /// `await` keyword.
7487
- Token? get awaitKeyword;
7488
-
7489
- /// The body of the loop.
7490
- CollectionElement get body;
7491
-
7492
- /// The token representing the `for` keyword.
7493
- Token get forKeyword;
7494
-
7495
- /// The parts of the for element that control the iteration.
7496
- ForLoopParts get forLoopParts;
7497
-
7498
- /// The left parenthesis.
7499
- Token get leftParenthesis;
7500
-
7501
- /// The right parenthesis.
7502
- Token get rightParenthesis;
7503
- }
7484
+ abstract final class ForElement
7485
+ implements CollectionElement, ForLoop<CollectionElement> {}
7504
7486
7505
7487
final class ForElementImpl extends CollectionElementImpl
7506
7488
with AstNodeWithNameScopeMixin
7507
- implements ForElement {
7489
+ implements
7490
+ ForElement,
7491
+ ForLoopImpl<CollectionElement, CollectionElementImpl> {
7508
7492
@override
7509
7493
final Token? awaitKeyword;
7510
7494
@@ -7584,6 +7568,35 @@ final class ForElementImpl extends CollectionElementImpl
7584
7568
}
7585
7569
}
7586
7570
7571
+ /// A for or for-each statement or collection element.
7572
+ @AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
7573
+ sealed class ForLoop<Body extends AstNode> implements AstNode {
7574
+ /// The token representing the `await` keyword, or `null` if there's no
7575
+ /// `await` keyword.
7576
+ Token? get awaitKeyword;
7577
+
7578
+ /// The body of the loop.
7579
+ Body get body;
7580
+
7581
+ /// The token representing the `for` keyword.
7582
+ Token get forKeyword;
7583
+
7584
+ /// The parts of the for element that control the iteration.
7585
+ ForLoopParts get forLoopParts;
7586
+
7587
+ /// The left parenthesis.
7588
+ Token get leftParenthesis;
7589
+
7590
+ /// The right parenthesis.
7591
+ Token get rightParenthesis;
7592
+ }
7593
+
7594
+ sealed class ForLoopImpl<Body extends AstNode, BodyImpl extends Body>
7595
+ implements AstNodeImpl, ForLoop<Body> {
7596
+ @override
7597
+ BodyImpl get body;
7598
+ }
7599
+
7587
7600
/// The parts of a for or for-each loop that control the iteration.
7588
7601
///
7589
7602
/// forLoopParts ::=
@@ -7595,9 +7608,15 @@ final class ForElementImpl extends CollectionElementImpl
7595
7608
/// expressionList ::=
7596
7609
/// [Expression] (',' [Expression])*
7597
7610
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
7598
- sealed class ForLoopParts implements AstNode {}
7611
+ sealed class ForLoopParts implements AstNode {
7612
+ @override
7613
+ ForLoop get parent;
7614
+ }
7599
7615
7600
- sealed class ForLoopPartsImpl extends AstNodeImpl implements ForLoopParts {}
7616
+ sealed class ForLoopPartsImpl extends AstNodeImpl implements ForLoopParts {
7617
+ @override
7618
+ ForLoopImpl get parent => super.parent as ForLoopImpl;
7619
+ }
7601
7620
7602
7621
/// A node representing a parameter to a function.
7603
7622
///
@@ -8094,30 +8113,11 @@ final class ForPartsWithPatternImpl extends ForPartsImpl
8094
8113
/// | [DeclaredIdentifier] 'in' [Expression]
8095
8114
/// | [SimpleIdentifier] 'in' [Expression]
8096
8115
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
8097
- abstract final class ForStatement implements Statement {
8098
- /// The token representing the `await` keyword, or `null` if there's no
8099
- /// `await` keyword.
8100
- Token? get awaitKeyword;
8101
-
8102
- /// The body of the loop.
8103
- Statement get body;
8104
-
8105
- /// The token representing the `for` keyword.
8106
- Token get forKeyword;
8107
-
8108
- /// The parts of the for element that control the iteration.
8109
- ForLoopParts get forLoopParts;
8110
-
8111
- /// The left parenthesis.
8112
- Token get leftParenthesis;
8113
-
8114
- /// The right parenthesis.
8115
- Token get rightParenthesis;
8116
- }
8116
+ abstract final class ForStatement implements Statement, ForLoop<Statement> {}
8117
8117
8118
8118
final class ForStatementImpl extends StatementImpl
8119
8119
with AstNodeWithNameScopeMixin
8120
- implements ForStatement {
8120
+ implements ForStatement, ForLoopImpl<Statement, StatementImpl> {
8121
8121
@override
8122
8122
final Token? awaitKeyword;
8123
8123
0 commit comments