Skip to content

Commit 04ec005

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove V1 ConstructorElement.
Change-Id: Idc28a2ec5571bf2740932466f0ddff5eb3b14c84 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423062 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 969eeaa commit 04ec005

File tree

9 files changed

+22
-220
lines changed

9 files changed

+22
-220
lines changed

pkg/analyzer/api.txt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,13 +2985,10 @@ package:analyzer/dart/element/element.dart:
29852985
lookUpSetter (method: PropertyAccessorElement? Function({required LibraryElement library, required String name}))
29862986
AugmentedInterfaceElement (class extends Object implements AugmentedInstanceElement, deprecated):
29872987
new (constructor: AugmentedInterfaceElement Function())
2988-
constructors (getter: List<ConstructorElement>)
29892988
firstFragment (getter: InterfaceElement)
29902989
interfaces (getter: List<InterfaceType>)
29912990
mixins (getter: List<InterfaceType>)
29922991
thisType (getter: InterfaceType)
2993-
unnamedConstructor (getter: ConstructorElement?)
2994-
getNamedConstructor (method: ConstructorElement? Function(String))
29952992
AugmentedMixinElement (class extends AugmentedInterfaceElement, deprecated):
29962993
new (constructor: AugmentedMixinElement Function())
29972994
superclassConstraints (getter: List<InterfaceType>)
@@ -3015,21 +3012,6 @@ package:analyzer/dart/element/element.dart:
30153012
session (getter: AnalysisSession)
30163013
topLevelVariables (getter: List<TopLevelVariableElement>)
30173014
typeAliases (getter: List<TypeAliasElement>)
3018-
ConstructorElement (class extends Object implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget, deprecated):
3019-
new (constructor: ConstructorElement Function())
3020-
declaration (getter: ConstructorElement)
3021-
displayName (getter: String)
3022-
enclosingElement3 (getter: InterfaceElement)
3023-
isConst (getter: bool)
3024-
isDefaultConstructor (getter: bool)
3025-
isFactory (getter: bool)
3026-
isGenerative (getter: bool)
3027-
name (getter: String)
3028-
nameEnd (getter: int?)
3029-
periodOffset (getter: int?)
3030-
redirectedConstructor (getter: ConstructorElement?)
3031-
returnType (getter: InterfaceType)
3032-
superConstructor (getter: ConstructorElement?)
30333015
DeferredImportElementPrefix (class extends Object implements ImportElementPrefix, deprecated):
30343016
new (constructor: DeferredImportElementPrefix Function())
30353017
DirectiveUri (class extends Object):
@@ -3253,17 +3235,14 @@ package:analyzer/dart/element/element.dart:
32533235
new (constructor: InterfaceElement Function())
32543236
allSupertypes (getter: List<InterfaceType>)
32553237
augmented (getter: AugmentedInterfaceElement, deprecated)
3256-
constructors (getter: List<ConstructorElement>, deprecated)
32573238
interfaces (getter: List<InterfaceType>)
32583239
mixins (getter: List<InterfaceType>, deprecated)
32593240
name (getter: String)
32603241
supertype (getter: InterfaceType?, deprecated)
32613242
thisType (getter: InterfaceType)
3262-
unnamedConstructor (getter: ConstructorElement?, deprecated)
32633243
getField (method: FieldElement? Function(String))
32643244
getGetter (method: PropertyAccessorElement? Function(String))
32653245
getMethod (method: MethodElement? Function(String))
3266-
getNamedConstructor (method: ConstructorElement? Function(String), deprecated)
32673246
getSetter (method: PropertyAccessorElement? Function(String))
32683247
instantiate (method: InterfaceType Function({required NullabilitySuffix nullabilitySuffix, required List<DartType> typeArguments}))
32693248
lookUpConcreteMethod (method: MethodElement? Function(String, LibraryElement))
@@ -4281,7 +4260,6 @@ package:analyzer/dart/element/type.dart:
42814260
new (constructor: InterfaceType Function())
42824261
accessors (getter: List<PropertyAccessorElement>, deprecated)
42834262
allSupertypes (getter: List<InterfaceType>)
4284-
constructors (getter: List<ConstructorElement>, deprecated)
42854263
constructors2 (getter: List<ConstructorElement2>, experimental)
42864264
element (getter: InterfaceElement, deprecated)
42874265
element3 (getter: InterfaceElement2, experimental)
@@ -4299,7 +4277,6 @@ package:analyzer/dart/element/type.dart:
42994277
getMethod2 (method: MethodElement2? Function(String))
43004278
getSetter (method: PropertyAccessorElement? Function(String), deprecated)
43014279
getSetter2 (method: SetterElement? Function(String))
4302-
lookUpConstructor (method: ConstructorElement? Function(String?, LibraryElement), deprecated)
43034280
lookUpConstructor2 (method: ConstructorElement2? Function(String?, LibraryElement2))
43044281
lookUpGetter2 (method: PropertyAccessorElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}), deprecated)
43054282
lookUpGetter3 (method: GetterElement? Function(String, LibraryElement2, {bool concrete, bool inherited, bool recoveryStatic}))

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

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ abstract class AugmentedInstanceElement {
146146
/// Clients may not extend, implement or mix-in this class.
147147
@Deprecated(elementModelDeprecationMsg)
148148
abstract class AugmentedInterfaceElement implements AugmentedInstanceElement {
149-
/// The constructors declared in this element.
150-
///
151-
/// `ConstructorAugmentationElement`s replace corresponding elements,
152-
/// other [ConstructorElement]s are appended.
153-
List<ConstructorElement> get constructors;
154-
155149
@override
156150
InterfaceElement get firstFragment;
157151

@@ -169,12 +163,6 @@ abstract class AugmentedInterfaceElement implements AugmentedInstanceElement {
169163

170164
@override
171165
InterfaceType get thisType;
172-
173-
/// The unnamed constructor from [constructors].
174-
ConstructorElement? get unnamedConstructor;
175-
176-
/// Returns the constructor from [constructors] that has the given [name].
177-
ConstructorElement? getNamedConstructor(String name);
178166
}
179167

180168
/// The result of applying augmentations to a [MixinElement].
@@ -270,62 +258,6 @@ abstract class CompilationUnitElement implements UriReferencedElement {
270258
List<TypeAliasElement> get typeAliases;
271259
}
272260

273-
/// An element representing a constructor or a factory method defined within a
274-
/// class.
275-
///
276-
/// Clients may not extend, implement or mix-in this class.
277-
@Deprecated('Use ConstructorElement2 instead')
278-
abstract class ConstructorElement
279-
implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget {
280-
@override
281-
ConstructorElement get declaration;
282-
283-
@override
284-
String get displayName;
285-
286-
@override
287-
InterfaceElement get enclosingElement3;
288-
289-
/// Whether the constructor is a const constructor.
290-
bool get isConst;
291-
292-
/// Whether the constructor can be used as a default constructor - unnamed,
293-
/// and has no required parameters.
294-
bool get isDefaultConstructor;
295-
296-
/// Whether the constructor represents a factory constructor.
297-
bool get isFactory;
298-
299-
/// Whether the constructor represents a generative constructor.
300-
bool get isGenerative;
301-
302-
@override
303-
String get name;
304-
305-
/// The offset of the character immediately following the last character of
306-
/// this constructor's name, or `null` if not named.
307-
///
308-
// TODO(migration): encapsulate [nameEnd] and [periodOffset]?
309-
int? get nameEnd;
310-
311-
/// The offset of the `.` before this constructor name, or `null` if not
312-
/// named.
313-
int? get periodOffset;
314-
315-
/// The constructor to which this constructor is redirecting, or `null` if
316-
/// this constructor does not redirect to another constructor or if the
317-
/// library containing this constructor has not yet been resolved.
318-
ConstructorElement? get redirectedConstructor;
319-
320-
@override
321-
InterfaceType get returnType;
322-
323-
/// The constructor of the superclass that this constructor invokes, or
324-
/// `null` if this constructor redirects to another constructor, or if the
325-
/// library containing this constructor has not yet been resolved.
326-
ConstructorElement? get superConstructor;
327-
}
328-
329261
/// [ImportElementPrefix] that is used together with `deferred`.
330262
///
331263
/// Clients may not extend, implement or mix-in this class.
@@ -1236,12 +1168,6 @@ abstract class InterfaceElement implements InstanceElement {
12361168
@override
12371169
AugmentedInterfaceElement get augmented;
12381170

1239-
/// The declared constructors.
1240-
///
1241-
/// The list is empty for [MixinElement].
1242-
@Deprecated(elementModelDeprecationMsg)
1243-
List<ConstructorElement> get constructors;
1244-
12451171
/// The interfaces that are implemented by this class.
12461172
///
12471173
/// <b>Note:</b> Because the element model represents the state of the code,
@@ -1290,14 +1216,6 @@ abstract class InterfaceElement implements InstanceElement {
12901216
@override
12911217
InterfaceType get thisType;
12921218

1293-
/// The unnamed constructor declared directly in this class.
1294-
///
1295-
/// If the class does not declare any constructors, a synthetic default
1296-
/// constructor will be returned.
1297-
// TODO(scheglov): Deprecate and remove it.
1298-
@Deprecated(elementModelDeprecationMsg)
1299-
ConstructorElement? get unnamedConstructor;
1300-
13011219
/// The field (synthetic or explicit) defined directly in this class or
13021220
/// augmentation that has the given [name].
13031221
// TODO(scheglov): Deprecate and remove it.
@@ -1313,12 +1231,6 @@ abstract class InterfaceElement implements InstanceElement {
13131231
// TODO(scheglov): Deprecate and remove it.
13141232
MethodElement? getMethod(String name);
13151233

1316-
/// The constructor defined directly in this class or augmentation
1317-
/// that has the given [name].
1318-
// TODO(scheglov): Deprecate and remove it.
1319-
@Deprecated(elementModelDeprecationMsg)
1320-
ConstructorElement? getNamedConstructor(String name);
1321-
13221234
/// The setter (synthetic or explicit) defined directly in this class or
13231235
/// augmentation that has the given [name].
13241236
// TODO(scheglov): Deprecate and remove it.

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ abstract class InterfaceType implements ParameterizedType {
352352
/// includes superclasses, mixins, interfaces, and superclass constraints.
353353
List<InterfaceType> get allSupertypes;
354354

355-
/// Return a list containing all of the constructors declared in this type.
356-
@Deprecated('Use constructors2 instead')
357-
List<ConstructorElement> get constructors;
358-
359355
/// Return a list containing all of the constructors declared in this type.
360356
@experimental
361357
List<ConstructorElement2> get constructors2;
@@ -442,19 +438,6 @@ abstract class InterfaceType implements ParameterizedType {
442438
/// with the given name.
443439
SetterElement? getSetter2(String name);
444440

445-
/// Return the element representing the constructor that results from looking
446-
/// up the constructor with the given [name] in this class with respect to the
447-
/// given [library], or `null` if the look up fails. The behavior of this
448-
/// method is defined by the Dart Language Specification in section 12.11.1:
449-
/// <blockquote>
450-
/// If <i>e</i> is of the form <b>new</b> <i>T.id()</i> then let <i>q<i> be
451-
/// the constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor
452-
/// <i>T<i>. Otherwise, if <i>q</i> is not defined or not accessible, a
453-
/// NoSuchMethodException is thrown.
454-
/// </blockquote>
455-
@Deprecated('Use lookUpConstructor2() instead')
456-
ConstructorElement? lookUpConstructor(String? name, LibraryElement library);
457-
458441
/// Return the element representing the constructor that results from looking
459442
/// up the constructor with the given [name] in this class with respect to the
460443
/// given [library], or `null` if the look up fails. The behavior of this

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:analyzer/dart/analysis/features.dart';
1313
import 'package:analyzer/dart/ast/ast.dart';
1414
import 'package:analyzer/dart/ast/syntactic_entity.dart';
1515
import 'package:analyzer/dart/constant/value.dart';
16-
import 'package:analyzer/dart/element/element.dart';
1716
import 'package:analyzer/dart/element/element2.dart';
1817
import 'package:analyzer/dart/element/type.dart';
1918
import 'package:analyzer/diagnostic/diagnostic.dart';
@@ -157,9 +156,6 @@ class ConstructorInvocation {
157156
ConstructorInvocation(
158157
this.constructor2, this._argumentValues, this.namedArguments);
159158

160-
@Deprecated('Use constructor2 instead')
161-
ConstructorElement get constructor => constructor2.asElement;
162-
163159
/// The positional arguments passed to the constructor.
164160
List<DartObjectImpl> get positionalArguments {
165161
var result = <DartObjectImpl>[];

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

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ class AugmentedInterfaceElementImpl extends AugmentedInstanceElementImpl
165165
implements AugmentedInterfaceElement {
166166
AugmentedInterfaceElementImpl(super.firstFragment);
167167

168-
@override
169-
List<ConstructorElement> get constructors => firstFragment.constructors;
170-
171168
@override
172169
InterfaceElementImpl get firstFragment {
173170
return super.firstFragment as InterfaceElementImpl;
@@ -183,15 +180,6 @@ class AugmentedInterfaceElementImpl extends AugmentedInstanceElementImpl
183180
InterfaceType get thisType {
184181
return super.thisType as InterfaceType;
185182
}
186-
187-
@override
188-
ConstructorElement? get unnamedConstructor =>
189-
firstFragment.unnamedConstructor;
190-
191-
@override
192-
ConstructorElement? getNamedConstructor(String name) {
193-
return constructors.firstWhereOrNull((e) => e.name == name);
194-
}
195183
}
196184

197185
class BindPatternVariableElementImpl extends PatternVariableElementImpl
@@ -1386,12 +1374,8 @@ class ConstLocalVariableElementImpl extends LocalVariableElementImpl
13861374

13871375
/// A concrete implementation of a [ConstructorFragment].
13881376
class ConstructorElementImpl extends ExecutableElementImpl
1389-
with
1390-
ConstructorElementMixin
1391-
implements
1392-
// ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
1393-
ConstructorElement,
1394-
ConstructorFragment {
1377+
with ConstructorElementMixin
1378+
implements ConstructorFragment {
13951379
late final ConstructorElementImpl2 element =
13961380
ConstructorElementImpl2(name.ifNotEmptyOrElse('new'), this);
13971381

@@ -1419,7 +1403,6 @@ class ConstructorElementImpl extends ExecutableElementImpl
14191403
@override
14201404
int? periodOffset;
14211405

1422-
@override
14231406
int? nameEnd;
14241407

14251408
@override
@@ -1559,7 +1542,6 @@ class ConstructorElementImpl extends ExecutableElementImpl
15591542
assert(false);
15601543
}
15611544

1562-
@override
15631545
ConstructorElementMixin? get superConstructor {
15641546
linkedData?.read(this);
15651547
return _superConstructor;
@@ -1728,17 +1710,18 @@ class ConstructorElementImpl2 extends ExecutableElementImpl2
17281710
}
17291711

17301712
mixin ConstructorElementMixin
1731-
implements
1732-
// ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
1733-
ConstructorElement,
1734-
ExecutableElementOrMember {
1713+
implements ConstantEvaluationTarget, ExecutableElementOrMember {
17351714
@override
17361715
ConstructorElementImpl get declaration;
17371716

17381717
@override
17391718
InterfaceElementImpl get enclosingElement3;
17401719

1741-
@override
1720+
/// Whether the constructor is a const constructor.
1721+
bool get isConst;
1722+
1723+
/// Whether the constructor can be used as a default constructor - unnamed,
1724+
/// and has no required parameters.
17421725
bool get isDefaultConstructor {
17431726
// unnamed
17441727
if (name.isNotEmpty) {
@@ -1754,15 +1737,17 @@ mixin ConstructorElementMixin
17541737
return true;
17551738
}
17561739

1757-
@override
1740+
/// Whether the constructor represents a factory constructor.
1741+
bool get isFactory;
1742+
1743+
/// Whether the constructor represents a generative constructor.
17581744
bool get isGenerative {
17591745
return !isFactory;
17601746
}
17611747

17621748
@override
17631749
LibraryElementImpl get library;
17641750

1765-
@override
17661751
ConstructorElementMixin? get redirectedConstructor;
17671752

17681753
@override
@@ -6012,7 +5997,6 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
60125997
...typeParameters,
60135998
];
60145999

6015-
@override
60166000
List<ConstructorElementImpl> get constructors {
60176001
if (!identical(_constructors, _Sentinel.constructorElement)) {
60186002
return _constructors;
@@ -6126,11 +6110,6 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
61266110
return element.thisType;
61276111
}
61286112

6129-
@override
6130-
ConstructorElementMixin? get unnamedConstructor {
6131-
return constructors.firstWhereOrNull((element) => element.name.isEmpty);
6132-
}
6133-
61346113
@Deprecated(elementModelDeprecationMsg)
61356114
@override
61366115
FieldElement? getField(String name) {
@@ -6148,15 +6127,6 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
61486127
return methods.firstWhereOrNull((method) => method.name == methodName);
61496128
}
61506129

6151-
@override
6152-
ConstructorElementMixin? getNamedConstructor(String name) {
6153-
if (name == 'new') {
6154-
// A constructor declared as `C.new` is unnamed, and is modeled as such.
6155-
name = '';
6156-
}
6157-
return constructors.firstWhereOrNull((element) => element.name == name);
6158-
}
6159-
61606130
@override
61616131
PropertyAccessorElementOrMember? getSetter(String setterName) {
61626132
return getSetterFromAccessors(setterName, accessors);

0 commit comments

Comments
 (0)