Skip to content

Commit de8f201

Browse files
scheglovCommit Queue
authored andcommitted
DeCo. Use ConstructorDeclaration.typeName in analyzer tests.
In a future CL I plan to make `Identifier get returnType` property deprecated, and this would touch a lot of code, so I try to reduce it by doing some parts in advance. Bug: #61701 Change-Id: Id95d5494081592b58af2835812f817fddc2f87ab Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463467 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 323bd09 commit de8f201

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

pkg/analyzer/test/dart/element/fragment_offset_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class C {
170170
checkOffset<ConstructorFragment>(
171171
constructorDeclaration,
172172
constructorDeclaration.declaredFragment!,
173-
constructorDeclaration.returnType.offset,
173+
constructorDeclaration.typeName!.offset,
174174
);
175175
}
176176

pkg/analyzer/test/generated/class_member_parser_test.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ClassMemberParserTest extends FastaParserTestCase
4141
expect(constructor.name, isNull);
4242
expect(constructor.parameters, isNotNull);
4343
expect(constructor.period, isNull);
44-
expect(constructor.returnType, isNotNull);
44+
expect(constructor.typeName, isNotNull);
4545
expect(constructor.initializers, hasLength(2));
4646

4747
{
@@ -294,7 +294,7 @@ class ClassMemberParserTest extends FastaParserTestCase
294294
expect(constructor.name, isNull);
295295
expect(constructor.parameters, isNotNull);
296296
expect(constructor.period, isNull);
297-
expect(constructor.returnType, isNotNull);
297+
expect(constructor.typeName, isNotNull);
298298
expect(constructor.initializers, hasLength(1));
299299

300300
var x = constructor.initializers[0] as ConstructorFieldInitializer;
@@ -388,7 +388,7 @@ class ClassMemberParserTest extends FastaParserTestCase
388388
expect(constructor.name, isNull);
389389
expect(constructor.parameters, isNotNull);
390390
expect(constructor.period, isNull);
391-
expect(constructor.returnType, isNotNull);
391+
expect(constructor.typeName, isNotNull);
392392
expect(constructor.initializers, hasLength(1));
393393
}
394394

@@ -1393,7 +1393,7 @@ void Function<A>(core.List<core.int> x) m() => null;
13931393
expect(constructor.externalKeyword, isNull);
13941394
expect(constructor.constKeyword!.keyword, Keyword.CONST);
13951395
expect(constructor.factoryKeyword!.keyword, Keyword.FACTORY);
1396-
expect(constructor.returnType.name, 'C');
1396+
expect(constructor.typeName!.name, 'C');
13971397
expect(constructor.period, isNull);
13981398
expect(constructor.name, isNull);
13991399
expect(constructor.parameters, isNotNull);
@@ -1419,7 +1419,7 @@ void Function<A>(core.List<core.int> x) m() => null;
14191419
expect(constructor.externalKeyword, isNull);
14201420
expect(constructor.constKeyword, isNull);
14211421
expect(constructor.factoryKeyword!.keyword, Keyword.FACTORY);
1422-
expect(constructor.returnType.name, 'C');
1422+
expect(constructor.typeName!.name, 'C');
14231423
expect(constructor.period, isNull);
14241424
expect(constructor.name, isNull);
14251425
expect(constructor.parameters, isNotNull);
@@ -1446,7 +1446,7 @@ void Function<A>(core.List<core.int> x) m() => null;
14461446
expect(constructor.externalKeyword, isNull);
14471447
expect(constructor.constKeyword, isNull);
14481448
expect(constructor.factoryKeyword!.keyword, Keyword.FACTORY);
1449-
expect(constructor.returnType.name, 'C');
1449+
expect(constructor.typeName!.name, 'C');
14501450
expect(constructor.period, isNull);
14511451
expect(constructor.name, isNull);
14521452
expect(constructor.parameters, isNotNull);
@@ -1494,7 +1494,7 @@ void Function<A>(core.List<core.int> x) m() => null;
14941494
expect(constructor.externalKeyword, isNull);
14951495
expect(constructor.constKeyword, isNull);
14961496
expect(constructor.factoryKeyword, isNotNull);
1497-
expect(constructor.returnType.name, 'C');
1497+
expect(constructor.typeName!.name, 'C');
14981498
expect(constructor.period!.type, TokenType.PERIOD);
14991499
expect(constructor.name!.lexeme, 'foo');
15001500
expect(constructor.parameters, isNotNull);
@@ -1548,7 +1548,7 @@ void Function<A>(core.List<core.int> x) m() => null;
15481548
expect(constructor.externalKeyword, isNull);
15491549
expect(constructor.constKeyword, isNull);
15501550
expect(constructor.factoryKeyword, isNull);
1551-
expect(constructor.returnType.name, 'C');
1551+
expect(constructor.typeName!.name, 'C');
15521552
expect(constructor.period!.type, TokenType.PERIOD);
15531553
expect(constructor.name!.lexeme, 'foo');
15541554
expect(constructor.parameters, isNotNull);
@@ -1605,7 +1605,7 @@ void Function<A>(core.List<core.int> x) m() => null;
16051605
expect(constructor.externalKeyword, isNull);
16061606
expect(constructor.constKeyword, isNull);
16071607
expect(constructor.factoryKeyword, isNull);
1608-
expect(constructor.returnType.name, 'C');
1608+
expect(constructor.typeName!.name, 'C');
16091609
expect(constructor.name, isNull);
16101610
expect(constructor.parameters, isNotNull);
16111611
expect(constructor.parameters.parameters, isEmpty);
@@ -1628,7 +1628,7 @@ void Function<A>(core.List<core.int> x) m() => null;
16281628
expect(constructor.externalKeyword, isNull);
16291629
expect(constructor.constKeyword, isNull);
16301630
expect(constructor.factoryKeyword, isNull);
1631-
expect(constructor.returnType.name, 'C');
1631+
expect(constructor.typeName!.name, 'C');
16321632
expect(constructor.name, isNull);
16331633
expect(constructor.parameters, isNotNull);
16341634
expect(constructor.parameters.parameters, isEmpty);
@@ -1649,7 +1649,7 @@ void Function<A>(core.List<core.int> x) m() => null;
16491649
expect(constructor.externalKeyword, isNull);
16501650
expect(constructor.constKeyword, isNull);
16511651
expect(constructor.factoryKeyword, isNull);
1652-
expect(constructor.returnType.name, 'C');
1652+
expect(constructor.typeName!.name, 'C');
16531653
expect(constructor.period, isNull);
16541654
expect(constructor.name, isNull);
16551655
expect(constructor.parameters, isNotNull);
@@ -2014,7 +2014,7 @@ void Function<A>(core.List<core.int> x) m() => null;
20142014
expect(constructor.externalKeyword, isNull);
20152015
expect(constructor.name, isNull);
20162016
expect(constructor.parameters, isNotNull);
2017-
expect(constructor.returnType, isNotNull);
2017+
expect(constructor.typeName, isNotNull);
20182018
}
20192019

20202020
void test_parseGetter_nonStatic() {

pkg/analyzer/test/generated/utilities_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,7 @@ class B {
472472
_assertReplacementForChildren<ConstructorDeclaration>(
473473
destination: findNode.constructor('A.named'),
474474
source: findNode.constructor('B.named'),
475-
childAccessors: [
476-
(node) => node.body,
477-
(node) => node.parameters,
478-
(node) => node.returnType,
479-
],
475+
childAccessors: [(node) => node.body, (node) => node.parameters],
480476
);
481477
_assertAnnotatedNode(findNode.constructor('A.named'));
482478
}

pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ class A {
153153
var result = await getFragmentDeclaration(element);
154154
var node = result!.node as ConstructorDeclaration;
155155
expect(node.name, isNull);
156-
expect(node.returnType.offset, this.result.content.indexOf('A(); // 1'));
156+
expect(node.typeName!.offset, this.result.content.indexOf('A(); // 1'));
157157
}
158158

159159
{
160160
var element = findNode.constructor('A(); // 2').declaredFragment!;
161161
var result = await getFragmentDeclaration(element);
162162
var node = result!.node as ConstructorDeclaration;
163163
expect(node.name, isNull);
164-
expect(node.returnType.offset, this.result.content.indexOf('A(); // 2'));
164+
expect(node.typeName!.offset, this.result.content.indexOf('A(); // 2'));
165165
}
166166
}
167167

0 commit comments

Comments
 (0)