Remove the analyzer's AST representation for PatternAssignmentStatement.

There's no such node in the grammar.  Pattern assignment statements
are simply expression statements whose expression is a
PatternAssignment (in the same way that a statement like `a = b;` is
an expression statement whose expression is `a = b`).

Change-Id: I09ea7deade3eb942f5ae464f72f3e217c164594e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272384
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2022-11-29 23:24:43 +00:00 committed by Commit Queue
parent 7e97d695f8
commit f28b2d71cd
7 changed files with 0 additions and 115 deletions

View file

@ -567,8 +567,6 @@ abstract class AstVisitor<R> {
R? visitPatternAssignment(PatternAssignment node); R? visitPatternAssignment(PatternAssignment node);
R? visitPatternAssignmentStatement(PatternAssignmentStatement node);
R? visitPatternVariableDeclaration(PatternVariableDeclaration node); R? visitPatternVariableDeclaration(PatternVariableDeclaration node);
R? visitPatternVariableDeclarationStatement( R? visitPatternVariableDeclarationStatement(
@ -4113,20 +4111,6 @@ abstract class PatternAssignment implements Expression {
DartPattern get pattern; DartPattern get pattern;
} }
/// A pattern assignment used as a statement.
///
/// patternAssignmentStatement ::=
/// [PatternAssignment] ';'
///
/// Clients may not extend, implement or mix-in this class.
abstract class PatternAssignmentStatement implements Statement {
/// Return the pattern assignment that comprises the statement.
PatternAssignment get assignment;
/// Return the semicolon terminating the statement.
Token get semicolon;
}
/// A pattern variable declaration. /// A pattern variable declaration.
/// ///
/// patternDeclaration ::= /// patternDeclaration ::=

View file

@ -545,10 +545,6 @@ class GeneralizingAstVisitor<R> implements AstVisitor<R> {
@override @override
R? visitPatternAssignment(PatternAssignment node) => visitExpression(node); R? visitPatternAssignment(PatternAssignment node) => visitExpression(node);
@override
R? visitPatternAssignmentStatement(PatternAssignmentStatement node) =>
visitStatement(node);
@override @override
R? visitPatternVariableDeclaration(PatternVariableDeclaration node) => R? visitPatternVariableDeclaration(PatternVariableDeclaration node) =>
visitNode(node); visitNode(node);
@ -1415,12 +1411,6 @@ class RecursiveAstVisitor<R> implements AstVisitor<R> {
return null; return null;
} }
@override
R? visitPatternAssignmentStatement(PatternAssignmentStatement node) {
node.visitChildren(this);
return null;
}
@override @override
R? visitPatternVariableDeclaration(PatternVariableDeclaration node) { R? visitPatternVariableDeclaration(PatternVariableDeclaration node) {
node.visitChildren(this); node.visitChildren(this);
@ -2089,9 +2079,6 @@ class SimpleAstVisitor<R> implements AstVisitor<R> {
@override @override
R? visitPatternAssignment(PatternAssignment node) => null; R? visitPatternAssignment(PatternAssignment node) => null;
@override
R? visitPatternAssignmentStatement(PatternAssignmentStatement node) => null;
@override @override
R? visitPatternVariableDeclaration(PatternVariableDeclaration node) => null; R? visitPatternVariableDeclaration(PatternVariableDeclaration node) => null;
@ -2611,10 +2598,6 @@ class ThrowingAstVisitor<R> implements AstVisitor<R> {
@override @override
R? visitPatternAssignment(PatternAssignment node) => _throw(node); R? visitPatternAssignment(PatternAssignment node) => _throw(node);
@override
R? visitPatternAssignmentStatement(PatternAssignmentStatement node) =>
_throw(node);
@override @override
R? visitPatternVariableDeclaration(PatternVariableDeclaration node) => R? visitPatternVariableDeclaration(PatternVariableDeclaration node) =>
_throw(node); _throw(node);
@ -3674,14 +3657,6 @@ class TimedAstVisitor<T> implements AstVisitor<T> {
return result; return result;
} }
@override
T? visitPatternAssignmentStatement(PatternAssignmentStatement node) {
stopwatch.start();
T? result = _baseVisitor.visitPatternAssignmentStatement(node);
stopwatch.stop();
return result;
}
@override @override
T? visitPatternVariableDeclaration(PatternVariableDeclaration node) { T? visitPatternVariableDeclaration(PatternVariableDeclaration node) {
stopwatch.start(); stopwatch.start();
@ -4482,10 +4457,6 @@ class UnifyingAstVisitor<R> implements AstVisitor<R> {
@override @override
R? visitPatternAssignment(PatternAssignment node) => visitNode(node); R? visitPatternAssignment(PatternAssignment node) => visitNode(node);
@override
R? visitPatternAssignmentStatement(PatternAssignmentStatement node) =>
visitNode(node);
@override @override
R? visitPatternVariableDeclaration(PatternVariableDeclaration node) => R? visitPatternVariableDeclaration(PatternVariableDeclaration node) =>
visitNode(node); visitNode(node);

View file

@ -9893,46 +9893,6 @@ class PatternAssignmentImpl extends ExpressionImpl
} }
} }
/// A pattern assignment used as a statement.
///
/// patternAssignmentStatement ::=
/// [PatternAssignment] ';'
class PatternAssignmentStatementImpl extends StatementImpl
implements PatternAssignmentStatement {
@override
final PatternAssignmentImpl assignment;
@override
final Token semicolon;
PatternAssignmentStatementImpl({
required this.assignment,
required this.semicolon,
}) {
_becomeParentOf(assignment);
}
@override
Token get beginToken => assignment.beginToken;
@override
Token get endToken => semicolon;
@override
ChildEntities get _childEntities => super._childEntities
..addNode('assignment', assignment)
..addToken('semicolon', semicolon);
@override
E? accept<E>(AstVisitor<E> visitor) =>
visitor.visitPatternAssignmentStatement(this);
@override
void visitChildren(AstVisitor visitor) {
assignment.accept(visitor);
}
}
/// A pattern variable declaration. /// A pattern variable declaration.
/// ///
/// patternDeclaration ::= /// patternDeclaration ::=

View file

@ -952,12 +952,6 @@ class ToSourceVisitor implements AstVisitor<void> {
_visitNode(node.expression); _visitNode(node.expression);
} }
@override
void visitPatternAssignmentStatement(PatternAssignmentStatement node) {
_visitNode(node.assignment);
sink.write(';');
}
@override @override
void visitPatternVariableDeclaration(PatternVariableDeclaration node) { void visitPatternVariableDeclaration(PatternVariableDeclaration node) {
_visitNodeList(node.metadata, separator: ' ', suffix: ' '); _visitNodeList(node.metadata, separator: ' ', suffix: ' ');

View file

@ -1099,13 +1099,6 @@ class AstComparator implements AstVisitor<bool> {
isEqualNodes(node.expression, other.expression); isEqualNodes(node.expression, other.expression);
} }
@override
bool visitPatternAssignmentStatement(PatternAssignmentStatement node) {
var other = _other as PatternAssignmentStatement;
return isEqualNodes(node.assignment, other.assignment) &&
isEqualTokens(node.semicolon, other.semicolon);
}
@override @override
bool visitPatternVariableDeclaration(PatternVariableDeclaration node) { bool visitPatternVariableDeclaration(PatternVariableDeclaration node) {
var other = _other as PatternVariableDeclaration; var other = _other as PatternVariableDeclaration;

View file

@ -671,12 +671,6 @@ class LinterVisitor implements AstVisitor<void> {
node.visitChildren(this); node.visitChildren(this);
} }
@override
void visitPatternAssignmentStatement(PatternAssignmentStatement node) {
_runSubscriptions(node, registry._forPatternAssignmentStatement);
node.visitChildren(this);
}
@override @override
void visitPatternVariableDeclaration(PatternVariableDeclaration node) { void visitPatternVariableDeclaration(PatternVariableDeclaration node) {
_runSubscriptions(node, registry._forPatternVariableDeclaration); _runSubscriptions(node, registry._forPatternVariableDeclaration);
@ -1157,8 +1151,6 @@ class NodeLintRegistry {
final List<_Subscription<PartDirective>> _forPartDirective = []; final List<_Subscription<PartDirective>> _forPartDirective = [];
final List<_Subscription<PartOfDirective>> _forPartOfDirective = []; final List<_Subscription<PartOfDirective>> _forPartOfDirective = [];
final List<_Subscription<PatternAssignment>> _forPatternAssignment = []; final List<_Subscription<PatternAssignment>> _forPatternAssignment = [];
final List<_Subscription<PatternAssignmentStatement>>
_forPatternAssignmentStatement = [];
final List<_Subscription<PatternVariableDeclaration>> final List<_Subscription<PatternVariableDeclaration>>
_forPatternVariableDeclaration = []; _forPatternVariableDeclaration = [];
final List<_Subscription<PatternVariableDeclarationStatement>> final List<_Subscription<PatternVariableDeclarationStatement>>
@ -1708,11 +1700,6 @@ class NodeLintRegistry {
.add(_Subscription(linter, visitor, _getTimer(linter))); .add(_Subscription(linter, visitor, _getTimer(linter)));
} }
void addPatternAssignmentStatement(LintRule linter, AstVisitor visitor) {
_forPatternAssignmentStatement
.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPatternVariableDeclaration(LintRule linter, AstVisitor visitor) { void addPatternVariableDeclaration(LintRule linter, AstVisitor visitor) {
_forPatternVariableDeclaration _forPatternVariableDeclaration
.add(_Subscription(linter, visitor, _getTimer(linter))); .add(_Subscription(linter, visitor, _getTimer(linter)));

View file

@ -521,10 +521,6 @@ class FindNode {
return _node(search, (n) => n is PatternAssignment); return _node(search, (n) => n is PatternAssignment);
} }
PatternAssignmentStatement patternAssignmentStatement(String search) {
return _node(search, (n) => n is PatternAssignmentStatement);
}
PatternVariableDeclaration patternVariableDeclaration(String search) { PatternVariableDeclaration patternVariableDeclaration(String search) {
return _node(search, (n) => n is PatternVariableDeclaration); return _node(search, (n) => n is PatternVariableDeclaration);
} }