Skip to content

Commit 077a4c3

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate SinceSdkVersionComputer.
Change-Id: Iecc9e796903e3c3791db42b4678ee2511477e7fb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403928 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 22fe194 commit 077a4c3

File tree

6 files changed

+175
-171
lines changed

6 files changed

+175
-171
lines changed

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

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ abstract class ClassFragment implements InterfaceFragment {
256256
/// type.
257257
///
258258
/// Clients may not extend, implement or mix-in this class.
259-
abstract class ConstructorElement2 implements ExecutableElement2 {
259+
abstract class ConstructorElement2
260+
implements ExecutableElement2, HasSinceSdkVersion {
260261
@override
261262
ConstructorElement2 get baseElement;
262263

@@ -845,7 +846,11 @@ abstract class FieldFragment implements PropertyInducingFragment {
845846
///
846847
/// Clients may not extend, implement or mix-in this class.
847848
abstract class FormalParameterElement
848-
implements PromotableElement2, Annotatable, LocalElement2 {
849+
implements
850+
PromotableElement2,
851+
Annotatable,
852+
HasSinceSdkVersion,
853+
LocalElement2 {
849854
@override
850855
FormalParameterElement get baseElement;
851856

@@ -1140,11 +1145,35 @@ abstract class GetterFragment implements PropertyAccessorFragment {
11401145
// GetterElement get element;
11411146
}
11421147

1148+
/// The interface that is implemented by elements that can have `@Since()`
1149+
/// annotation.
1150+
abstract class HasSinceSdkVersion {
1151+
/// The version where the associated SDK API was added.
1152+
///
1153+
/// A `@Since()` annotation can be applied to a library declaration,
1154+
/// any public declaration in a library, or in a class, or to an optional
1155+
/// parameter, etc.
1156+
///
1157+
/// The returned version is "effective", so that if a library is annotated
1158+
/// then all elements of the library inherit it; or if a class is annotated
1159+
/// then all members and constructors of the class inherit it.
1160+
///
1161+
/// If multiple `@Since()` annotations apply to the same element, the latest
1162+
/// version takes precedence.
1163+
///
1164+
/// Returns `null` if the element is not declared in the SDK, or doesn't have
1165+
/// a `@Since()` annotation applied to it.
1166+
Version? get sinceSdkVersion;
1167+
}
1168+
11431169
/// An element whose instance members can refer to `this`.
11441170
///
11451171
/// Clients may not extend, implement or mix-in this class.
11461172
abstract class InstanceElement2
1147-
implements TypeDefiningElement2, TypeParameterizedElement2 {
1173+
implements
1174+
TypeDefiningElement2,
1175+
TypeParameterizedElement2,
1176+
HasSinceSdkVersion {
11481177
@override
11491178
LibraryElement2 get enclosingElement2;
11501179

@@ -1474,7 +1503,8 @@ abstract class LabelFragment implements Fragment {
14741503
/// A library.
14751504
///
14761505
/// Clients may not extend, implement or mix-in this class.
1477-
abstract class LibraryElement2 implements Element2, Annotatable {
1506+
abstract class LibraryElement2
1507+
implements Element2, Annotatable, HasSinceSdkVersion {
14781508
/// The classes defined in this library.
14791509
///
14801510
/// There is no guarantee of the order in which the classes will be returned.
@@ -1958,23 +1988,6 @@ abstract class Metadata {
19581988

19591989
/// Whether the receiver has an annotation of the form `@widgetFactory`.
19601990
bool get hasWidgetFactory;
1961-
1962-
/// The version where the associated SDK API was added.
1963-
///
1964-
/// A `@Since()` annotation can be applied to a library declaration,
1965-
/// any public declaration in a library, or in a class, or to an optional
1966-
/// parameter, etc.
1967-
///
1968-
/// The returned version is "effective", so that if a library is annotated
1969-
/// then all elements of the library inherit it; or if a class is annotated
1970-
/// then all members and constructors of the class inherit it.
1971-
///
1972-
/// If multiple `@Since()` annotations apply to the same element, the latest
1973-
/// version takes precedence.
1974-
///
1975-
/// Returns `null` if the element is not declared in the SDK, or doesn't have
1976-
/// a `@Since()` annotation applied to it.
1977-
Version? get sinceSdkVersion;
19781991
}
19791992

19801993
/// A method.
@@ -1983,7 +1996,8 @@ abstract class Metadata {
19831996
/// method.
19841997
///
19851998
/// Clients may not extend, implement or mix-in this class.
1986-
abstract class MethodElement2 implements ExecutableElement2 {
1999+
abstract class MethodElement2
2000+
implements ExecutableElement2, HasSinceSdkVersion {
19872001
/// The name of the method that can be implemented by a class to allow its
19882002
/// instances to be invoked as if they were a function.
19892003
static final String CALL_METHOD_NAME = "call";
@@ -2277,7 +2291,7 @@ abstract class PropertyAccessorFragment implements ExecutableFragment {
22772291
///
22782292
/// Clients may not extend, implement or mix-in this class.
22792293
abstract class PropertyInducingElement2
2280-
implements VariableElement2, Annotatable {
2294+
implements VariableElement2, Annotatable, HasSinceSdkVersion {
22812295
@override
22822296
PropertyInducingFragment get firstFragment;
22832297

@@ -2439,7 +2453,8 @@ abstract class SuperFormalParameterFragment implements FormalParameterFragment {
24392453
/// A top-level function.
24402454
///
24412455
/// Clients may not extend, implement or mix-in this class.
2442-
abstract class TopLevelFunctionElement implements ExecutableElement2 {
2456+
abstract class TopLevelFunctionElement
2457+
implements ExecutableElement2, HasSinceSdkVersion {
24432458
@override
24442459
TopLevelFunctionElement get baseElement;
24452460

@@ -2512,7 +2527,10 @@ abstract class TopLevelVariableFragment implements PropertyInducingFragment {
25122527
///
25132528
/// Clients may not extend, implement or mix-in this class.
25142529
abstract class TypeAliasElement2
2515-
implements TypeParameterizedElement2, TypeDefiningElement2 {
2530+
implements
2531+
TypeParameterizedElement2,
2532+
TypeDefiningElement2,
2533+
HasSinceSdkVersion {
25162534
/// If the aliased type has structure, return the corresponding element.
25172535
/// For example, it could be [GenericFunctionTypeElement].
25182536
///

0 commit comments

Comments
 (0)