@@ -1233,6 +1233,9 @@ abstract class AstVisitor<R> {
1233
1233
1234
1234
R? visitDoStatement(DoStatement node);
1235
1235
1236
+ R? visitDotShorthandConstructorInvocation(
1237
+ DotShorthandConstructorInvocation node);
1238
+
1236
1239
R? visitDotShorthandInvocation(DotShorthandInvocation node);
1237
1240
1238
1241
R? visitDotShorthandPropertyAccess(DotShorthandPropertyAccess node);
@@ -5192,6 +5195,91 @@ final class DoStatementImpl extends StatementImpl implements DoStatement {
5192
5195
}
5193
5196
}
5194
5197
5198
+ /// A node that represents a dot shorthand constructor invocation.
5199
+ ///
5200
+ /// For example, `.fromCharCode(42)`.
5201
+ ///
5202
+ /// dotShorthandHead ::=
5203
+ /// '.' [SimpleIdentifier] [TypeArgumentList]? [ArgumentList]
5204
+ @experimental
5205
+ @AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
5206
+ abstract final class DotShorthandConstructorInvocation
5207
+ extends InvocationExpression implements ConstructorReferenceNode {
5208
+ /// The name of the constructor invocation.
5209
+ SimpleIdentifier get constructorName;
5210
+
5211
+ /// The token representing the period.
5212
+ Token get period;
5213
+ }
5214
+
5215
+ final class DotShorthandConstructorInvocationImpl
5216
+ extends InvocationExpressionImpl
5217
+ implements
5218
+ DotShorthandConstructorInvocation,
5219
+ RewrittenMethodInvocationImpl {
5220
+ @override
5221
+ final Token period;
5222
+
5223
+ SimpleIdentifierImpl _constructorName;
5224
+
5225
+ @override
5226
+ ConstructorElementImpl2? element;
5227
+
5228
+ /// Initializes a newly created dot shorthand constructor invocation.
5229
+ DotShorthandConstructorInvocationImpl({
5230
+ required this.period,
5231
+ required SimpleIdentifierImpl constructorName,
5232
+ required super.typeArguments,
5233
+ required super.argumentList,
5234
+ }) : _constructorName = constructorName {
5235
+ _becomeParentOf(_constructorName);
5236
+ }
5237
+
5238
+ @override
5239
+ Token get beginToken => period;
5240
+
5241
+ @override
5242
+ SimpleIdentifierImpl get constructorName => _constructorName;
5243
+
5244
+ set constructorName(SimpleIdentifierImpl identifier) {
5245
+ _constructorName = _becomeParentOf(identifier);
5246
+ }
5247
+
5248
+ @override
5249
+ Token get endToken => argumentList.endToken;
5250
+
5251
+ @override
5252
+ ExpressionImpl get function => constructorName;
5253
+
5254
+ @override
5255
+ Precedence get precedence => Precedence.postfix;
5256
+
5257
+ @override
5258
+ ChildEntities get _childEntities => ChildEntities()
5259
+ ..addToken('period', period)
5260
+ ..addNode('constructorName', constructorName)
5261
+ ..addNode('typeArguments', typeArguments)
5262
+ ..addNode('argumentList', argumentList);
5263
+
5264
+ @override
5265
+ E? accept<E>(AstVisitor<E> visitor) =>
5266
+ visitor.visitDotShorthandConstructorInvocation(this);
5267
+
5268
+ @override
5269
+ void resolveExpression(ResolverVisitor resolver, TypeImpl contextType) {
5270
+ throw StateError(
5271
+ 'DotShorthandConstructorInvocationImpl should only appear in fully'
5272
+ ' resolved ASTs');
5273
+ }
5274
+
5275
+ @override
5276
+ void visitChildren(AstVisitor visitor) {
5277
+ constructorName.accept(visitor);
5278
+ typeArguments?.accept(visitor);
5279
+ argumentList.accept(visitor);
5280
+ }
5281
+ }
5282
+
5195
5283
/// A node that represents a dot shorthand static method or constructor
5196
5284
/// invocation.
5197
5285
///
@@ -8488,7 +8576,7 @@ abstract final class FunctionExpressionInvocation
8488
8576
8489
8577
final class FunctionExpressionInvocationImpl extends InvocationExpressionImpl
8490
8578
with NullShortableExpressionImpl
8491
- implements FunctionExpressionInvocation {
8579
+ implements FunctionExpressionInvocation, RewrittenMethodInvocationImpl {
8492
8580
ExpressionImpl _function;
8493
8581
8494
8582
@override
@@ -10562,8 +10650,8 @@ final class InterpolationStringImpl extends InterpolationElementImpl
10562
10650
10563
10651
/// The invocation of a function or method.
10564
10652
///
10565
- /// This will either be a [FunctionExpressionInvocation], [MethodInvocation],
10566
- /// or a [DotShorthandInvocation].
10653
+ /// This will either be a [FunctionExpressionInvocation], a [MethodInvocation],
10654
+ /// a [DotShorthandConstructorInvocation], or a [DotShorthandInvocation].
10567
10655
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
10568
10656
abstract final class InvocationExpression implements Expression {
10569
10657
/// The list of arguments to the method.
@@ -15345,6 +15433,12 @@ final class ReturnStatementImpl extends StatementImpl
15345
15433
}
15346
15434
}
15347
15435
15436
+ /// A resolved dot shorthand invocation.
15437
+ ///
15438
+ /// Either a [FunctionExpressionInvocationImpl], a static method invocation, or
15439
+ /// a [DotShorthandConstructorInvocationImpl], a constructor invocation.
15440
+ sealed class RewrittenMethodInvocationImpl implements ExpressionImpl {}
15441
+
15348
15442
/// A script tag that can optionally occur at the beginning of a compilation
15349
15443
/// unit.
15350
15444
///
0 commit comments