Skip to content

Commit 5d175fa

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Deprecate InterfaceElement.constructors2, use constructors.
Change-Id: I78faea1fdbc55e46cdb7fc0b187d12561736cec2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429822 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent e8f4712 commit 5d175fa

32 files changed

+95
-70
lines changed

pkg/analysis_server/lib/src/cider/local_library_contributor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class LibraryElementSuggestionBuilder
193193
return;
194194
}
195195

196-
for (var constructor in element.constructors2) {
196+
for (var constructor in element.constructors) {
197197
if (constructor.isPrivate) {
198198
continue;
199199
}

pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class DeclarationHelper {
162162

163163
/// Add suggestions for all constructors of [element].
164164
void addConstructorNamesForElement({required InterfaceElement element}) {
165-
var constructors = element.constructors2;
165+
var constructors = element.constructors;
166166
for (var constructor in constructors) {
167167
_suggestConstructor(
168168
constructor,
@@ -610,7 +610,7 @@ class DeclarationHelper {
610610
var typeSystem = library.typeSystem;
611611
for (var classElement in library.classes) {
612612
if (typeSystem.isSubtypeOf(classElement.thisType, classType)) {
613-
for (var constructor in classElement.constructors2) {
613+
for (var constructor in classElement.constructors) {
614614
if (constructor != redirectingConstructor &&
615615
constructor.isAccessibleIn2(library)) {
616616
_suggestConstructor(
@@ -638,7 +638,7 @@ class DeclarationHelper {
638638
_addStaticMembers(
639639
getters: element.getters,
640640
setters: element.setters,
641-
constructors: element.constructors2,
641+
constructors: element.constructors,
642642
containingElement: element,
643643
fields: element.fields,
644644
methods: element.methods,
@@ -656,7 +656,7 @@ class DeclarationHelper {
656656
_addStaticMembers(
657657
getters: element.getters,
658658
setters: element.setters,
659-
constructors: element.constructors2,
659+
constructors: element.constructors,
660660
containingElement: element,
661661
fields: element.fields,
662662
methods: element.methods,
@@ -669,16 +669,16 @@ class DeclarationHelper {
669669
void _addConstructors(LibraryElement library, ImportData importData) {
670670
for (var element in library.classes) {
671671
_suggestConstructors(
672-
element.constructors2,
672+
element.constructors,
673673
importData,
674674
allowNonFactory: !element.isAbstract,
675675
);
676676
}
677677
for (var element in library.enums) {
678-
_suggestConstructors(element.constructors2, importData);
678+
_suggestConstructors(element.constructors, importData);
679679
}
680680
for (var element in library.extensionTypes) {
681-
_suggestConstructors(element.constructors2, importData);
681+
_suggestConstructors(element.constructors, importData);
682682
}
683683
for (var element in library.typeAliases) {
684684
_addConstructorsForAliasedElement(element, importData);
@@ -694,14 +694,14 @@ class DeclarationHelper {
694694
var aliasedElement = alias.aliasedElement2;
695695
if (aliasedElement is ClassElement) {
696696
_suggestConstructors(
697-
aliasedElement.constructors2,
697+
aliasedElement.constructors,
698698
importData,
699699
allowNonFactory: !aliasedElement.isAbstract,
700700
);
701701
} else if (aliasedElement is ExtensionTypeElement) {
702-
_suggestConstructors(aliasedElement.constructors2, importData);
702+
_suggestConstructors(aliasedElement.constructors, importData);
703703
} else if (aliasedElement is MixinElement) {
704-
_suggestConstructors(aliasedElement.constructors2, importData);
704+
_suggestConstructors(aliasedElement.constructors, importData);
705705
}
706706
}
707707

@@ -721,12 +721,12 @@ class DeclarationHelper {
721721
switch (element) {
722722
case ClassElement():
723723
_suggestConstructors(
724-
element.constructors2,
724+
element.constructors,
725725
importData,
726726
allowNonFactory: !element.isAbstract,
727727
);
728728
case ExtensionTypeElement():
729-
_suggestConstructors(element.constructors2, importData);
729+
_suggestConstructors(element.constructors, importData);
730730
case TypeAliasElement():
731731
_addConstructorsForAliasedElement(element, importData);
732732
}
@@ -1694,7 +1694,7 @@ class DeclarationHelper {
16941694
if (!mustBeType) {
16951695
_suggestStaticFields(element.fields, importData);
16961696
_suggestConstructors(
1697-
element.constructors2,
1697+
element.constructors,
16981698
importData,
16991699
allowNonFactory: !element.isAbstract,
17001700
);
@@ -1799,7 +1799,7 @@ class DeclarationHelper {
17991799
if (!mustBeType) {
18001800
_suggestStaticFields(element.fields, importData);
18011801
_suggestConstructors(
1802-
element.constructors2,
1802+
element.constructors,
18031803
importData,
18041804
allowNonFactory: false,
18051805
);
@@ -1852,7 +1852,7 @@ class DeclarationHelper {
18521852
}
18531853
if (!mustBeType) {
18541854
_suggestStaticFields(element.fields, importData);
1855-
_suggestConstructors(element.constructors2, importData);
1855+
_suggestConstructors(element.constructors, importData);
18561856
}
18571857
}
18581858
}

pkg/analysis_server/lib/src/services/flutter/property.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class _EdgeInsetsProperty {
486486
}
487487
}
488488

489-
onlyConstructor = classEdgeInsets.constructors2.firstWhereOrNull(
489+
onlyConstructor = classEdgeInsets.constructors.firstWhereOrNull(
490490
(e) => e.name3 == 'only',
491491
);
492492

pkg/analysis_server/lib/src/services/refactoring/legacy/rename_class_member.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class RenameClassMemberRefactoringImpl extends RenameRefactoringImpl {
106106
if (!newName.startsWith('_')) {
107107
var interfaceElement = renameElement.enclosingElement;
108108
if (interfaceElement is InterfaceElement) {
109-
for (var constructor in interfaceElement.constructors2) {
109+
for (var constructor in interfaceElement.constructors) {
110110
for (var parameter in constructor.formalParameters) {
111111
if (parameter is FieldFormalParameterElement &&
112112
parameter.field2 == renameElement) {

pkg/analysis_server/lib/src/services/search/hierarchy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ getHierarchyMembersAndParameters(
171171
}
172172

173173
if (includeParametersForFields && member2 is FieldElement) {
174-
for (var constructor in subClass.constructors2) {
174+
for (var constructor in subClass.constructors) {
175175
for (var parameter in constructor.formalParameters) {
176176
if (parameter is FieldFormalParameterElement &&
177177
parameter.field2 == member2) {

pkg/analysis_server/test/services/search/hierarchy_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class B extends A {
3838
''');
3939
var classA = findElement2.class_('A');
4040
var classB = findElement2.class_('B');
41-
var memberA = classA.constructors2[0];
42-
var memberB = classB.constructors2[0];
41+
var memberA = classA.constructors[0];
42+
var memberB = classB.constructors[0];
4343
var futureA = getHierarchyMembers(searchEngine, memberA).then((members) {
4444
expect(members, unorderedEquals([memberA]));
4545
});

pkg/analyzer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* Deprecate `InstanceElement.getMethod2`, use `getMethod` instead.
3030
* Deprecate `InstanceFragment.fields2`, use `fields` instead.
3131
* Deprecate `InstanceFragment.methods2`, use `methods` instead.
32+
* Deprecate `InterfaceElement.constructors2`, use `constructors` instead.
33+
* Deprecate `InterfaceFragment.constructors2`, use `constructors` instead.
3234

3335
## 7.4.1
3436
* Restore `InstanceElement.augmented` getter.

pkg/analyzer/api.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,7 +3405,8 @@ package:analyzer/dart/element/element.dart:
34053405
InterfaceElement (class extends Object implements InstanceElement):
34063406
new (constructor: InterfaceElement Function())
34073407
allSupertypes (getter: List<InterfaceType>)
3408-
constructors2 (getter: List<ConstructorElement>)
3408+
constructors (getter: List<ConstructorElement>)
3409+
constructors2 (getter: List<ConstructorElement>, deprecated)
34093410
firstFragment (getter: InterfaceFragment)
34103411
fragments (getter: List<InterfaceFragment>)
34113412
inheritedConcreteMembers (getter: Map<Name, ExecutableElement>)
@@ -3426,7 +3427,8 @@ package:analyzer/dart/element/element.dart:
34263427
lookUpInheritedMethod2 (method: MethodElement? Function({required LibraryElement library, required String methodName}))
34273428
InterfaceFragment (class extends Object implements InstanceFragment):
34283429
new (constructor: InterfaceFragment Function())
3429-
constructors2 (getter: List<ConstructorFragment>)
3430+
constructors (getter: List<ConstructorFragment>)
3431+
constructors2 (getter: List<ConstructorFragment>, deprecated)
34303432
element (getter: InterfaceElement)
34313433
interfaces (getter: List<InterfaceType>)
34323434
mixins (getter: List<InterfaceType>)

pkg/analyzer/doc/tutorial/element.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ it might look something like this:
7373
void printMembers(LibraryElement libraryElement) {
7474
for (ClassElement classElement in libraryElement.classes) {
7575
print(classElement.name3);
76-
for (ConstructorElement constructorElement in classElement.constructors2) {
76+
for (ConstructorElement constructorElement in classElement.constructors) {
7777
if (!constructorElement.isSynthetic) {
7878
print(' ${constructorElement.displayName}');
7979
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,12 @@ abstract class InterfaceElement implements InstanceElement {
19861986
/// The constructors defined for this element.
19871987
///
19881988
/// The list is empty for [MixinElement].
1989+
List<ConstructorElement> get constructors;
1990+
1991+
/// The constructors defined for this element.
1992+
///
1993+
/// The list is empty for [MixinElement].
1994+
@Deprecated('Use constructors instead')
19891995
List<ConstructorElement> get constructors2;
19901996

19911997
@override
@@ -2123,7 +2129,7 @@ abstract class InterfaceElement implements InstanceElement {
21232129
/// since it does not need to consider all possible interface names.
21242130
ExecutableElement? getInterfaceMember(Name name);
21252131

2126-
/// Returns the constructor from [constructors2] that has the given [name].
2132+
/// Returns the constructor from [constructors] that has the given [name].
21272133
ConstructorElement? getNamedConstructor2(String name);
21282134

21292135
/// Returns all members of mixins, superclasses, and interfaces that a member
@@ -2202,6 +2208,12 @@ abstract class InterfaceFragment implements InstanceFragment {
22022208
/// The constructors declared in this fragment.
22032209
///
22042210
/// The list is empty for [MixinFragment].
2211+
List<ConstructorFragment> get constructors;
2212+
2213+
/// The constructors declared in this fragment.
2214+
///
2215+
/// The list is empty for [MixinFragment].
2216+
@Deprecated('Use constructors instead')
22052217
List<ConstructorFragment> get constructors2;
22062218

22072219
@override

0 commit comments

Comments
 (0)