Skip to content

Commit 93f4539

Browse files
scheglovCommit Queue
authored andcommitted
Make 'token' a required named formal parameter of SimpleIdentifierImpl constructor.
For consistency. Change-Id: I1b391353cffc0ad41cb81df51cd5a57fb9207c5c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428080 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent c9dcebc commit 93f4539

File tree

12 files changed

+54
-42
lines changed

12 files changed

+54
-42
lines changed

pkg/analysis_server/lib/src/services/correction/util.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class _ElementReferenceCollector extends RecursiveAstVisitor<void> {
448448
@override
449449
void visitImportPrefixReference(ImportPrefixReference node) {
450450
if (node.element2 == element) {
451-
references.add(SimpleIdentifierImpl(node.name));
451+
references.add(SimpleIdentifierImpl(token: node.name));
452452
}
453453
}
454454

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17477,7 +17477,7 @@ final class SimpleIdentifierImpl extends IdentifierImpl
1747717477
ScopeLookupResult? scopeLookupResult;
1747817478

1747917479
/// Initializes a newly created identifier.
17480-
SimpleIdentifierImpl(this.token);
17480+
SimpleIdentifierImpl({required this.token});
1748117481

1748217482
/// The cascade that contains this [SimpleIdentifier].
1748317483
CascadeExpressionImpl? get ancestorCascade {

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,7 +2986,7 @@ class _InstanceCreationEvaluator {
29862986
if (parameter is SuperFormalParameterElementOrMember) {
29872987
var value =
29882988
SimpleIdentifierImpl(
2989-
StringToken(
2989+
token: StringToken(
29902990
TokenType.STRING,
29912991
parameter.name,
29922992
parameter.nameOffset,
@@ -3001,7 +3001,7 @@ class _InstanceCreationEvaluator {
30013001
NamedExpressionImpl(
30023002
name: LabelImpl(
30033003
label: SimpleIdentifierImpl(
3004-
StringToken(
3004+
token: StringToken(
30053005
TokenType.STRING,
30063006
parameter.name,
30073007
parameter.nameOffset,

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,11 @@ class ClassFragmentImpl extends ClassOrMixinFragmentImpl
655655
implicitParameters.add(implicitParameter);
656656
argumentsForSuperInvocation.add(
657657
SimpleIdentifierImpl(
658-
StringToken(TokenType.STRING, implicitParameter.name, -1),
658+
token: StringToken(
659+
TokenType.STRING,
660+
implicitParameter.name,
661+
-1,
662+
),
659663
)
660664
..element = implicitParameter.asElement2
661665
..setPseudoExpressionStaticType(implicitParameter.type),
@@ -677,7 +681,7 @@ class ClassFragmentImpl extends ClassOrMixinFragmentImpl
677681
constructorName:
678682
isNamed
679683
? (SimpleIdentifierImpl(
680-
StringToken(
684+
token: StringToken(
681685
TokenType.STRING,
682686
superclassConstructor.name,
683687
-1,

pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class AstRewriter {
5151
if (element is ExecutableElement) {
5252
return _toMethodInvocationOfFunctionReference(
5353
node: node,
54-
function: SimpleIdentifierImpl(typeNode.name),
54+
function: SimpleIdentifierImpl(token: typeNode.name),
5555
);
5656
} else if (element is TypeAliasElementImpl2 &&
5757
element.aliasedElement2 is GenericFunctionTypeElement) {
5858
return _toMethodInvocationOfAliasedTypeLiteral(
5959
node: node,
60-
function: SimpleIdentifierImpl(typeNode.name),
60+
function: SimpleIdentifierImpl(token: typeNode.name),
6161
element: element,
6262
);
6363
}
@@ -71,19 +71,19 @@ class AstRewriter {
7171
return _toMethodInvocationOfFunctionReference(
7272
node: node,
7373
function: PrefixedIdentifierImpl(
74-
prefix: SimpleIdentifierImpl(importPrefix.name),
74+
prefix: SimpleIdentifierImpl(token: importPrefix.name),
7575
period: importPrefix.period,
76-
identifier: SimpleIdentifierImpl(typeNode.name),
76+
identifier: SimpleIdentifierImpl(token: typeNode.name),
7777
),
7878
);
7979
} else if (element is TypeAliasElementImpl2 &&
8080
element.aliasedElement2 is GenericFunctionTypeElement) {
8181
return _toMethodInvocationOfAliasedTypeLiteral(
8282
node: node,
8383
function: PrefixedIdentifierImpl(
84-
prefix: SimpleIdentifierImpl(importPrefix.name),
84+
prefix: SimpleIdentifierImpl(token: importPrefix.name),
8585
period: importPrefix.period,
86-
identifier: SimpleIdentifierImpl(typeNode.name),
86+
identifier: SimpleIdentifierImpl(token: typeNode.name),
8787
),
8888
element: element,
8989
);
@@ -107,9 +107,9 @@ class AstRewriter {
107107
return _toMethodInvocationOfFunctionReference(
108108
node: node,
109109
function: PrefixedIdentifierImpl(
110-
prefix: SimpleIdentifierImpl(importPrefix.name),
110+
prefix: SimpleIdentifierImpl(token: importPrefix.name),
111111
period: importPrefix.period,
112-
identifier: SimpleIdentifierImpl(typeNode.name),
112+
identifier: SimpleIdentifierImpl(token: typeNode.name),
113113
),
114114
);
115115
}

pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class NamedTypeResolver with ScopeHelpers {
375375

376376
constructorName.type = namedType;
377377
constructorName.period = importPrefix.period;
378-
constructorName.name = SimpleIdentifierImpl(nameToken);
378+
constructorName.name = SimpleIdentifierImpl(token: nameToken);
379379

380380
rewriteResult = constructorName;
381381
return;

pkg/analyzer/lib/src/fasta/ast_builder.dart

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ class AstBuilder extends StackListener {
936936
token,
937937
token,
938938
);
939-
SimpleIdentifierImpl identifier = SimpleIdentifierImpl(token);
939+
SimpleIdentifierImpl identifier = SimpleIdentifierImpl(token: token);
940940
push(
941941
PropertyAccessImpl(
942942
target: receiver,
@@ -1055,7 +1055,7 @@ class AstBuilder extends StackListener {
10551055
}
10561056
push(
10571057
FunctionExpressionInvocationImpl(
1058-
function: SimpleIdentifierImpl(assertKeyword),
1058+
function: SimpleIdentifierImpl(token: assertKeyword),
10591059
typeArguments: null,
10601060
argumentList: ArgumentListImpl(
10611061
leftParenthesis: leftParenthesis,
@@ -3197,7 +3197,7 @@ class AstBuilder extends StackListener {
31973197

31983198
var expression = fields.firstOrNull;
31993199
expression ??= SimpleIdentifierImpl(
3200-
parser.rewriter.insertSyntheticIdentifier(leftParenthesis),
3200+
token: parser.rewriter.insertSyntheticIdentifier(leftParenthesis),
32013201
);
32023202

32033203
push(
@@ -3885,10 +3885,10 @@ class AstBuilder extends StackListener {
38853885
push(
38863886
ExpressionStatementImpl(
38873887
expression: PrefixedIdentifierImpl(
3888-
prefix: SimpleIdentifierImpl(importPrefix.name),
3888+
prefix: SimpleIdentifierImpl(token: importPrefix.name),
38893889
period: importPrefix.period,
38903890
identifier: SimpleIdentifierImpl(
3891-
parser.rewriter.insertSyntheticIdentifier(
3891+
token: parser.rewriter.insertSyntheticIdentifier(
38923892
importPrefix.period,
38933893
),
38943894
),
@@ -3918,9 +3918,9 @@ class AstBuilder extends StackListener {
39183918
push(
39193919
ExpressionStatementImpl(
39203920
expression: PrefixedIdentifierImpl(
3921-
prefix: SimpleIdentifierImpl(importPrefix.name),
3921+
prefix: SimpleIdentifierImpl(token: importPrefix.name),
39223922
period: importPrefix.period,
3923-
identifier: SimpleIdentifierImpl(type.name),
3923+
identifier: SimpleIdentifierImpl(token: type.name),
39243924
),
39253925
semicolon: semicolon2,
39263926
),
@@ -4684,7 +4684,9 @@ class AstBuilder extends StackListener {
46844684
if (!leftParenthesis.next!.isIdentifier) {
46854685
parser.rewriter.insertSyntheticIdentifier(leftParenthesis);
46864686
}
4687-
variableOrDeclaration = SimpleIdentifierImpl(leftParenthesis.next!);
4687+
variableOrDeclaration = SimpleIdentifierImpl(
4688+
token: leftParenthesis.next!,
4689+
);
46884690
}
46894691
forLoopParts = ForEachPartsWithIdentifierImpl(
46904692
identifier: variableOrDeclaration,
@@ -4792,7 +4794,7 @@ class AstBuilder extends StackListener {
47924794
}
47934795
}
47944796

4795-
var identifier = SimpleIdentifierImpl(token);
4797+
var identifier = SimpleIdentifierImpl(token: token);
47964798
if (context.inLibraryOrPartOfDeclaration) {
47974799
if (!context.isContinuation) {
47984800
push([identifier]);
@@ -4955,7 +4957,7 @@ class AstBuilder extends StackListener {
49554957
assert(optional('operator', operatorKeyword));
49564958
debugEvent("InvalidOperatorName");
49574959

4958-
push(_OperatorName(operatorKeyword, SimpleIdentifierImpl(token)));
4960+
push(_OperatorName(operatorKeyword, SimpleIdentifierImpl(token: token)));
49594961
}
49604962

49614963
@override
@@ -5300,7 +5302,7 @@ class AstBuilder extends StackListener {
53005302
nameCandidate,
53015303
ParserErrorCode.INVALID_USE_OF_IDENTIFIER_AUGMENTED,
53025304
);
5303-
name = SimpleIdentifierImpl(nameCandidate.augmentedKeyword);
5305+
name = SimpleIdentifierImpl(token: nameCandidate.augmentedKeyword);
53045306
} else {
53055307
name = nameCandidate as SimpleIdentifierImpl;
53065308
}
@@ -5415,7 +5417,7 @@ class AstBuilder extends StackListener {
54155417
debugEvent("NoTypeNameInConstructorReference");
54165418
var builder = _classLikeBuilder as _EnumDeclarationBuilder;
54175419

5418-
push(SimpleIdentifierImpl(builder.name));
5420+
push(SimpleIdentifierImpl(token: builder.name));
54195421
}
54205422

54215423
@override
@@ -5522,7 +5524,7 @@ class AstBuilder extends StackListener {
55225524
assert(token.type.isUserDefinableOperator);
55235525
debugEvent("OperatorName");
55245526

5525-
push(_OperatorName(operatorKeyword, SimpleIdentifierImpl(token)));
5527+
push(_OperatorName(operatorKeyword, SimpleIdentifierImpl(token: token)));
55265528
}
55275529

55285530
@override
@@ -5914,7 +5916,7 @@ class AstBuilder extends StackListener {
59145916
nameCandidate,
59155917
ParserErrorCode.INVALID_USE_OF_IDENTIFIER_AUGMENTED,
59165918
);
5917-
name = SimpleIdentifierImpl(nameCandidate.augmentedKeyword);
5919+
name = SimpleIdentifierImpl(token: nameCandidate.augmentedKeyword);
59185920
} else {
59195921
name = nameCandidate as IdentifierImpl;
59205922
}
@@ -6215,7 +6217,7 @@ class AstBuilder extends StackListener {
62156217
externalKeyword: modifiers?.externalKeyword,
62166218
constKeyword: modifiers?.finalConstOrVarKeyword,
62176219
factoryKeyword: null,
6218-
returnType: SimpleIdentifierImpl(prefixOrName.token),
6220+
returnType: SimpleIdentifierImpl(token: prefixOrName.token),
62196221
period: period,
62206222
name: nameOrNull?.token,
62216223
parameters: parameters,
@@ -6292,7 +6294,7 @@ class AstBuilder extends StackListener {
62926294
externalKeyword: modifiers?.externalKeyword,
62936295
constKeyword: modifiers?.finalConstOrVarKeyword,
62946296
factoryKeyword: factoryKeyword,
6295-
returnType: SimpleIdentifierImpl(returnType.token),
6297+
returnType: SimpleIdentifierImpl(token: returnType.token),
62966298
period: period,
62976299
name: nameToken,
62986300
parameters: parameters,
@@ -6404,7 +6406,9 @@ class AstBuilder extends StackListener {
64046406
}
64056407

64066408
SimpleIdentifierImpl _tmpSimpleIdentifier() {
6407-
return SimpleIdentifierImpl(StringToken(TokenType.STRING, '__tmp', -1));
6409+
return SimpleIdentifierImpl(
6410+
token: StringToken(TokenType.STRING, '__tmp', -1),
6411+
);
64086412
}
64096413

64106414
ParameterKind _toAnalyzerParameterKind(FormalParameterKind type) {

pkg/analyzer/lib/src/fasta/doc_comment_builder.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,12 +723,12 @@ final class DocCommentBuilder {
723723
token = token.next!;
724724
} while (!token.isEof);
725725

726-
var identifier = SimpleIdentifierImpl(identifierOrOperator);
726+
var identifier = SimpleIdentifierImpl(token: identifierOrOperator);
727727
if (firstToken != null) {
728728
var target = PrefixedIdentifierImpl(
729-
prefix: SimpleIdentifierImpl(firstToken),
729+
prefix: SimpleIdentifierImpl(token: firstToken),
730730
period: firstPeriod!,
731-
identifier: SimpleIdentifierImpl(secondToken!),
731+
identifier: SimpleIdentifierImpl(token: secondToken!),
732732
);
733733
var expression = PropertyAccessImpl(
734734
target: target,
@@ -742,7 +742,7 @@ final class DocCommentBuilder {
742742
);
743743
} else if (secondToken != null) {
744744
var expression = PrefixedIdentifierImpl(
745-
prefix: SimpleIdentifierImpl(secondToken),
745+
prefix: SimpleIdentifierImpl(token: secondToken),
746746
period: secondPeriod!,
747747
identifier: identifier,
748748
);

pkg/analyzer/lib/src/summary2/ast_binary_reader.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,9 @@ class AstBinaryReader {
952952
NamedExpression _readNamedExpression() {
953953
var name = _readStringReference();
954954
var nameNode = LabelImpl(
955-
label: SimpleIdentifierImpl(StringToken(TokenType.STRING, name, -1)),
955+
label: SimpleIdentifierImpl(
956+
token: StringToken(TokenType.STRING, name, -1),
957+
),
956958
colon: Tokens.colon(),
957959
);
958960
var expression = readNode() as ExpressionImpl;
@@ -1251,7 +1253,9 @@ class AstBinaryReader {
12511253

12521254
SimpleIdentifier _readSimpleIdentifier() {
12531255
var name = _readStringReference();
1254-
var node = SimpleIdentifierImpl(StringToken(TokenType.STRING, name, -1));
1256+
var node = SimpleIdentifierImpl(
1257+
token: StringToken(TokenType.STRING, name, -1),
1258+
);
12551259
node.element = _reader.readElement2();
12561260
node.tearOffTypeArgumentTypes = _reader.readOptionalTypeList();
12571261
_readExpressionResolution(node);

pkg/analyzer/lib/src/summary2/element_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
382382
name:
383383
constructorName != null
384384
? SimpleIdentifierImpl(
385-
StringToken(TokenType.STRING, constructorName, -1),
385+
token: StringToken(TokenType.STRING, constructorName, -1),
386386
)
387387
: null,
388388
),
@@ -417,7 +417,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
417417
holder.addNonSyntheticField(refName, field);
418418

419419
valuesElements.add(
420-
SimpleIdentifierImpl(StringToken(TokenType.STRING, name, -1)),
420+
SimpleIdentifierImpl(token: StringToken(TokenType.STRING, name, -1)),
421421
);
422422
valuesNames.add(name);
423423
}

0 commit comments

Comments
 (0)