Skip to content

Commit 2402179

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove V1 ExecutableElement.
Change-Id: Ib73c335b05649547a5ae797d033cedbeb22212ef Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423210 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 7ec3326 commit 2402179

File tree

7 files changed

+119
-104
lines changed

7 files changed

+119
-104
lines changed

pkg/analyzer/api.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,6 @@ package:analyzer/dart/constant/value.dart:
29572957
getField (method: DartObject? Function(String))
29582958
toBoolValue (method: bool? Function())
29592959
toDoubleValue (method: double? Function())
2960-
toFunctionValue (method: ExecutableElement? Function(), deprecated)
29612960
toFunctionValue2 (method: ExecutableElement2? Function(), experimental)
29622961
toIntValue (method: int? Function())
29632962
toListValue (method: List<DartObject>? Function())
@@ -3144,22 +3143,6 @@ package:analyzer/dart/element/element.dart:
31443143
new (constructor: ElementLocation Function())
31453144
components (getter: List<String>)
31463145
encoding (getter: String)
3147-
ExecutableElement (class extends Object implements FunctionTypedElement, deprecated):
3148-
new (constructor: ExecutableElement Function())
3149-
declaration (getter: ExecutableElement)
3150-
displayName (getter: String)
3151-
enclosingElement3 (getter: Element)
3152-
hasImplicitReturnType (getter: bool)
3153-
isAbstract (getter: bool)
3154-
isAsynchronous (getter: bool)
3155-
isAugmentation (getter: bool)
3156-
isExtensionTypeMember (getter: bool)
3157-
isExternal (getter: bool)
3158-
isGenerator (getter: bool)
3159-
isOperator (getter: bool)
3160-
isStatic (getter: bool)
3161-
isSynchronous (getter: bool)
3162-
name (getter: String)
31633146
FunctionTypedElement (class extends Object implements TypeParameterizedElement, deprecated):
31643147
new (constructor: FunctionTypedElement Function())
31653148
parameters (getter: List<ParameterElement>)

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ abstract class DartObject {
100100
/// * the value of the object being represented is `null`.
101101
double? toDoubleValue();
102102

103-
/// Return an element corresponding to the value of the object being
104-
/// represented, or `null`
105-
/// if
106-
/// * this object is not of a function type,
107-
/// * the value of the object being represented is not known, or
108-
/// * the value of the object being represented is `null`.
109-
@Deprecated('Use toFunctionValue2() instead')
110-
ExecutableElement? toFunctionValue();
111-
112103
/// Return an element corresponding to the value of the object being
113104
/// represented, or `null`
114105
/// if

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

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -798,70 +798,6 @@ abstract class ElementLocation {
798798
String get encoding;
799799
}
800800

801-
/// An element representing an executable object, including functions, methods,
802-
/// constructors, getters, and setters.
803-
///
804-
/// Clients may not extend, implement or mix-in this class.
805-
@Deprecated('Use ExecutableElement2 instead')
806-
abstract class ExecutableElement implements FunctionTypedElement {
807-
@override
808-
ExecutableElement get declaration;
809-
810-
@override
811-
String get displayName;
812-
813-
@override
814-
Element get enclosingElement3;
815-
816-
/// Whether the executable element did not have an explicit return type
817-
/// specified for it in the original source.
818-
bool get hasImplicitReturnType;
819-
820-
/// Whether the executable element is abstract.
821-
///
822-
/// Executable elements are abstract if they are not external, and have no
823-
/// body.
824-
bool get isAbstract;
825-
826-
/// Whether the executable element has body marked as being asynchronous.
827-
bool get isAsynchronous;
828-
829-
/// Whether the element is an augmentation.
830-
///
831-
/// If `true`, declaration has the explicit `augment` modifier.
832-
bool get isAugmentation;
833-
834-
/// Whether the executable element is an extension type member.
835-
bool get isExtensionTypeMember;
836-
837-
/// Whether the executable element is external.
838-
///
839-
/// Executable elements are external if they are explicitly marked as such
840-
/// using the 'external' keyword.
841-
bool get isExternal;
842-
843-
/// Whether the executable element has a body marked as being a generator.
844-
bool get isGenerator;
845-
846-
/// Whether the executable element is an operator.
847-
///
848-
/// The test may be based on the name of the executable element, in which
849-
/// case the result will be correct when the name is legal.
850-
bool get isOperator;
851-
852-
/// Whether the element is a static element.
853-
///
854-
/// A static element is an element that is not associated with a particular
855-
/// instance, but rather with an entire library or class.
856-
bool get isStatic;
857-
858-
/// Whether the executable element has a body marked as being synchronous.
859-
bool get isSynchronous;
860-
861-
@override
862-
String get name;
863-
}
864-
865801
/// An element that has a [FunctionType] as its [type].
866802
///
867803
/// This also provides convenient access to the parameters and return type.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,12 @@ class DartObjectImpl implements DartObject, Constant {
899899
return null;
900900
}
901901

902-
@override
902+
/// Return an element corresponding to the value of the object being
903+
/// represented, or `null`
904+
/// if
905+
/// * this object is not of a function type,
906+
/// * the value of the object being represented is not known, or
907+
/// * the value of the object being represented is `null`.
903908
ExecutableElementOrMember? toFunctionValue() {
904909
return toFunctionValue2()?.asElement;
905910
}

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

Lines changed: 111 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,51 @@ class ElementLocationImpl implements ElementLocation {
33783378

33793379
/// A shared internal interface of `Element` and [Member].
33803380
/// Used during migration to avoid referencing `Element`.
3381-
abstract class ElementOrMember {}
3381+
abstract class ElementOrMember {
3382+
/// The declaration of this element.
3383+
///
3384+
/// If the element is a view on an element, e.g. a method from an interface
3385+
/// type, with substituted type parameters, return the corresponding element
3386+
/// from the class, without any substitutions. If this element is already a
3387+
/// declaration (or a synthetic element, e.g. a synthetic property accessor),
3388+
/// return itself.
3389+
ElementOrMember? get declaration;
3390+
3391+
/// The display name of this element, possibly the empty string if the
3392+
/// element does not have a name.
3393+
///
3394+
/// In most cases the name and the display name are the same. Differences
3395+
/// though are cases such as setters where the name of some setter `set f(x)`
3396+
/// is `f=`, instead of `f`.
3397+
String get displayName;
3398+
3399+
/// The element that either physically or logically encloses this element.
3400+
///
3401+
/// For [LibraryElement] returns `null`, because libraries are the top-level
3402+
/// elements in the model.
3403+
///
3404+
/// For [CompilationUnitElement] returns the [CompilationUnitElement] that
3405+
/// uses `part` directive to include this element, or `null` if this element
3406+
/// is the defining unit of the library.
3407+
@Deprecated('Use Element2.enclosingElement2 instead or '
3408+
'Fragment.enclosingFragment instead')
3409+
Element? get enclosingElement3;
3410+
3411+
/// The kind of element that this is.
3412+
ElementKind get kind;
3413+
3414+
/// The name of this element, or `null` if this element does not have a name.
3415+
String? get name;
3416+
3417+
/// The length of the name of this element in the file that contains the
3418+
/// declaration of this element, or `0` if this element does not have a name.
3419+
int get nameLength;
3420+
3421+
/// The offset of the name of this element in the file that contains the
3422+
/// declaration of this element, or `-1` if this element is synthetic, does
3423+
/// not have a name, or otherwise does not have an offset.
3424+
int get nameOffset;
3425+
}
33823426

33833427
/// An [InterfaceElementImpl] which is an enum.
33843428
class EnumElementImpl extends InterfaceElementImpl implements EnumFragment {
@@ -3734,21 +3778,79 @@ abstract class ExecutableElementImpl2 extends FunctionTypedElementImpl2
37343778

37353779
/// Common base class for all analyzer-internal classes that implement
37363780
/// `ExecutableElement`.
3737-
abstract class ExecutableElementOrMember
3738-
implements
3739-
// ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
3740-
ExecutableElement,
3741-
ElementOrMember {
3781+
abstract class ExecutableElementOrMember implements ElementOrMember {
37423782
@override
3743-
List<ParameterElementMixin> get parameters;
3783+
ExecutableElementOrMember get declaration;
37443784

37453785
@override
3746-
TypeImpl get returnType;
3786+
String get displayName;
3787+
3788+
/// Whether the executable element did not have an explicit return type
3789+
/// specified for it in the original source.
3790+
bool get hasImplicitReturnType;
3791+
3792+
/// Whether the executable element is abstract.
3793+
///
3794+
/// Executable elements are abstract if they are not external, and have no
3795+
/// body.
3796+
bool get isAbstract;
3797+
3798+
/// Whether the executable element has body marked as being asynchronous.
3799+
bool get isAsynchronous;
37473800

3801+
/// Whether the element is an augmentation.
3802+
///
3803+
/// If `true`, declaration has the explicit `augment` modifier.
3804+
bool get isAugmentation;
3805+
3806+
/// Whether the executable element is an extension type member.
3807+
bool get isExtensionTypeMember;
3808+
3809+
/// Whether the executable element is external.
3810+
///
3811+
/// Executable elements are external if they are explicitly marked as such
3812+
/// using the 'external' keyword.
3813+
bool get isExternal;
3814+
3815+
/// Whether the executable element has a body marked as being a generator.
3816+
bool get isGenerator;
3817+
3818+
/// Whether the executable element is an operator.
3819+
///
3820+
/// The test may be based on the name of the executable element, in which
3821+
/// case the result will be correct when the name is legal.
3822+
bool get isOperator;
3823+
3824+
/// Whether the element is a static element.
3825+
///
3826+
/// A static element is an element that is not associated with a particular
3827+
/// instance, but rather with an entire library or class.
3828+
bool get isStatic;
3829+
3830+
/// Whether the executable element has a body marked as being synchronous.
3831+
bool get isSynchronous;
3832+
3833+
/// The name of this element, or `null` if this element does not have a name.
37483834
@override
3835+
String get name;
3836+
3837+
/// The parameters defined by this executable element.
3838+
List<ParameterElementMixin> get parameters;
3839+
3840+
/// The return type defined by this element.
3841+
TypeImpl get returnType;
3842+
3843+
/// Return the source associated with this target, or `null` if this target is
3844+
/// not associated with a source.
3845+
Source get source;
3846+
3847+
/// The type defined by this element.
37493848
FunctionTypeImpl get type;
37503849

3751-
@override
3850+
/// The type parameters declared by this element directly.
3851+
///
3852+
/// This does not include type parameters that are declared by any enclosing
3853+
/// elements.
37523854
List<TypeParameterElementImpl> get typeParameters;
37533855
}
37543856

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ class GetterMember extends PropertyAccessorMember
672672
if (setter is SetterMember) {
673673
return setter;
674674
}
675-
return setter.asElement2 as SetterElementImpl?;
675+
return setter?.asElement2 as SetterElementImpl?;
676676
}
677677

678678
@override
@@ -1416,7 +1416,7 @@ class SetterMember extends PropertyAccessorMember
14161416
if (getter is GetterMember) {
14171417
return getter;
14181418
}
1419-
return getter.asElement2 as GetterElementImpl?;
1419+
return getter?.asElement2 as GetterElementImpl?;
14201420
}
14211421

14221422
@override

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ extension Element2OrNullExtension on Element2? {
188188
return element2.asElement;
189189
case DynamicElementImpl2():
190190
return self.firstFragment;
191-
case ExecutableMember element2:
192-
return element2.asElement;
193191
case ExtensionElementImpl2 element2:
194192
return element2.asElement;
195193
case FieldElementImpl2 element2:

0 commit comments

Comments
 (0)