Skip to content

Commit 7ba2579

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove HasSinceSdkVersion, move 'sinceSdkVersion' into Element.
This simplifies both API and implementation; and unblocks another simplification with removing `TypeDefiningElementImpl`. There are no uses of `HasSinceSdkVersion` interface, and even `sinceSdkVersion` at all in google3. So, we might consider removing it at all. But I imagine that it might be theoretically useful, so maybe not. OTOH, given that its use it so spare, I think that it does not deserve the complexity. To be landed after 7.7.0 from https://dart-review.googlesource.com/c/sdk/+/440683 is published. Change-Id: I69bb2d5aeba8a463b1fb30704f5877527f46e5e9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440600 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 9863bce commit 7ba2579

File tree

8 files changed

+113
-152
lines changed

8 files changed

+113
-152
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Remove deprecated `VariableElement.constantInitializer2`.
1515
* Remove deprecated `VariableFragment.initializer`.
1616
* Remove deprecated `ConstantInitializer`.
17+
* Remove deprecated `HasSinceSdkVersion`.
1718
* `LibraryFragment` is not `Annotatable` anymore.
1819
* Stop implementing `ConstantEvaluationTarget` by `ElementAnnotation`.
1920
This is an internal interface that should not have been exposed.

pkg/analyzer/api.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,7 +3302,7 @@ package:analyzer/dart/element/element.dart:
33023302
element (getter: ClassElement)
33033303
nextFragment (getter: ClassFragment?)
33043304
previousFragment (getter: ClassFragment?)
3305-
ConstructorElement (class extends Object implements ExecutableElement, HasSinceSdkVersion):
3305+
ConstructorElement (class extends Object implements ExecutableElement):
33063306
new (constructor: ConstructorElement Function())
33073307
baseElement (getter: ConstructorElement)
33083308
enclosingElement (getter: InterfaceElement)
@@ -3373,6 +3373,7 @@ package:analyzer/dart/element/element.dart:
33733373
nonSynthetic (getter: Element)
33743374
nonSynthetic2 (getter: Element, deprecated)
33753375
session (getter: AnalysisSession?)
3376+
sinceSdkVersion (getter: Version?)
33763377
accept (method: T? Function<T>(ElementVisitor2<T>))
33773378
accept2 (method: T? Function<T>(ElementVisitor2<T>), deprecated)
33783379
displayString (method: String Function({bool multiline, bool preferTypeAlias}))
@@ -3591,7 +3592,7 @@ package:analyzer/dart/element/element.dart:
35913592
nextFragment (getter: FieldFragment?)
35923593
offset (getter: int)
35933594
previousFragment (getter: FieldFragment?)
3594-
FormalParameterElement (class extends Object implements VariableElement, Annotatable, HasSinceSdkVersion, LocalElement):
3595+
FormalParameterElement (class extends Object implements VariableElement, Annotatable, LocalElement):
35953596
new (constructor: FormalParameterElement Function())
35963597
baseElement (getter: FormalParameterElement)
35973598
defaultValueCode (getter: String?)
@@ -3670,13 +3671,10 @@ package:analyzer/dart/element/element.dart:
36703671
nextFragment (getter: GetterFragment?)
36713672
offset (getter: int)
36723673
previousFragment (getter: GetterFragment?)
3673-
HasSinceSdkVersion (class extends Object):
3674-
new (constructor: HasSinceSdkVersion Function())
3675-
sinceSdkVersion (getter: Version?)
36763674
HideElementCombinator (class extends Object implements NamespaceCombinator):
36773675
new (constructor: HideElementCombinator Function())
36783676
hiddenNames (getter: List<String>)
3679-
InstanceElement (class extends Object implements TypeDefiningElement, TypeParameterizedElement, HasSinceSdkVersion):
3677+
InstanceElement (class extends Object implements TypeDefiningElement, TypeParameterizedElement):
36803678
new (constructor: InstanceElement Function())
36813679
baseElement (getter: InstanceElement)
36823680
enclosingElement (getter: LibraryElement)
@@ -3782,7 +3780,7 @@ package:analyzer/dart/element/element.dart:
37823780
element (getter: LabelElement)
37833781
nextFragment (getter: LabelFragment?)
37843782
previousFragment (getter: LabelFragment?)
3785-
LibraryElement (class extends Object implements Element, Annotatable, HasSinceSdkVersion):
3783+
LibraryElement (class extends Object implements Element, Annotatable):
37863784
new (constructor: LibraryElement Function())
37873785
classes (getter: List<ClassElement>)
37883786
entryPoint (getter: TopLevelFunctionElement?)
@@ -3945,7 +3943,7 @@ package:analyzer/dart/element/element.dart:
39453943
hasVisibleForTesting (getter: bool)
39463944
hasVisibleOutsideTemplate (getter: bool)
39473945
hasWidgetFactory (getter: bool)
3948-
MethodElement (class extends Object implements ExecutableElement, HasSinceSdkVersion):
3946+
MethodElement (class extends Object implements ExecutableElement):
39493947
CALL_METHOD_NAME (static getter: String)
39503948
NO_SUCH_METHOD_METHOD_NAME (static getter: String)
39513949
new (constructor: MethodElement Function())
@@ -4048,7 +4046,7 @@ package:analyzer/dart/element/element.dart:
40484046
element (getter: PropertyAccessorElement)
40494047
nextFragment (getter: PropertyAccessorFragment?)
40504048
previousFragment (getter: PropertyAccessorFragment?)
4051-
PropertyInducingElement (class extends Object implements VariableElement, Annotatable, HasSinceSdkVersion):
4049+
PropertyInducingElement (class extends Object implements VariableElement, Annotatable):
40524050
new (constructor: PropertyInducingElement Function())
40534051
firstFragment (getter: PropertyInducingFragment)
40544052
fragments (getter: List<PropertyInducingFragment>)
@@ -4095,7 +4093,7 @@ package:analyzer/dart/element/element.dart:
40954093
element (getter: SuperFormalParameterElement)
40964094
nextFragment (getter: SuperFormalParameterFragment?)
40974095
previousFragment (getter: SuperFormalParameterFragment?)
4098-
TopLevelFunctionElement (class extends Object implements ExecutableElement, HasSinceSdkVersion):
4096+
TopLevelFunctionElement (class extends Object implements ExecutableElement):
40994097
LOAD_LIBRARY_NAME (static getter: String)
41004098
MAIN_FUNCTION_NAME (static getter: String)
41014099
new (constructor: TopLevelFunctionElement Function())
@@ -4120,7 +4118,7 @@ package:analyzer/dart/element/element.dart:
41204118
element (getter: TopLevelVariableElement)
41214119
nextFragment (getter: TopLevelVariableFragment?)
41224120
previousFragment (getter: TopLevelVariableFragment?)
4123-
TypeAliasElement (class extends Object implements TypeParameterizedElement, TypeDefiningElement, HasSinceSdkVersion):
4121+
TypeAliasElement (class extends Object implements TypeParameterizedElement, TypeDefiningElement):
41244122
new (constructor: TypeAliasElement Function())
41254123
aliasedElement (getter: Element?)
41264124
aliasedElement2 (getter: Element?, deprecated)
@@ -4264,7 +4262,6 @@ package:analyzer/dart/element/element2.dart:
42644262
GenericFunctionTypeFragment (see above)
42654263
GetterElement (see above)
42664264
GetterFragment (see above)
4267-
HasSinceSdkVersion (see above)
42684265
HideElementCombinator (see above)
42694266
InstanceElement (see above)
42704267
InstanceFragment (see above)

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

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ abstract class ClassFragment implements InterfaceFragment {
362362
/// type.
363363
///
364364
/// Clients may not extend, implement or mix-in this class.
365-
abstract class ConstructorElement
366-
implements ExecutableElement, HasSinceSdkVersion {
365+
abstract class ConstructorElement implements ExecutableElement {
367366
@override
368367
ConstructorElement get baseElement;
369368

@@ -716,6 +715,23 @@ abstract class Element {
716715
/// The analysis session in which this element is defined.
717716
AnalysisSession? get session;
718717

718+
/// The version where the associated SDK API was added.
719+
///
720+
/// A `@Since()` annotation can be applied to a library declaration,
721+
/// any public declaration in a library, or in a class, or to an optional
722+
/// parameter, etc.
723+
///
724+
/// The returned version is "effective", so that if a library is annotated
725+
/// then all elements of the library inherit it; or if a class is annotated
726+
/// then all members and constructors of the class inherit it.
727+
///
728+
/// If multiple `@Since()` annotations apply to the same element, the latest
729+
/// version takes precedence.
730+
///
731+
/// Returns `null` if the element is not declared in the SDK, or doesn't have
732+
/// a `@Since()` annotation applied to it.
733+
Version? get sinceSdkVersion;
734+
719735
/// Uses the given [visitor] to visit this element.
720736
///
721737
/// Returns the value returned by the visitor as a result of visiting this
@@ -1565,7 +1581,7 @@ abstract class FieldFragment implements PropertyInducingFragment {
15651581
///
15661582
/// Clients may not extend, implement or mix-in this class.
15671583
abstract class FormalParameterElement
1568-
implements VariableElement, Annotatable, HasSinceSdkVersion, LocalElement {
1584+
implements VariableElement, Annotatable, LocalElement {
15691585
@override
15701586
FormalParameterElement get baseElement;
15711587

@@ -1958,27 +1974,6 @@ abstract class GetterFragment implements PropertyAccessorFragment {
19581974
GetterFragment? get previousFragment;
19591975
}
19601976

1961-
/// The interface that is implemented by elements that can have `@Since()`
1962-
/// annotation.
1963-
abstract class HasSinceSdkVersion {
1964-
/// The version where the associated SDK API was added.
1965-
///
1966-
/// A `@Since()` annotation can be applied to a library declaration,
1967-
/// any public declaration in a library, or in a class, or to an optional
1968-
/// parameter, etc.
1969-
///
1970-
/// The returned version is "effective", so that if a library is annotated
1971-
/// then all elements of the library inherit it; or if a class is annotated
1972-
/// then all members and constructors of the class inherit it.
1973-
///
1974-
/// If multiple `@Since()` annotations apply to the same element, the latest
1975-
/// version takes precedence.
1976-
///
1977-
/// Returns `null` if the element is not declared in the SDK, or doesn't have
1978-
/// a `@Since()` annotation applied to it.
1979-
Version? get sinceSdkVersion;
1980-
}
1981-
19821977
/// A combinator that causes some of the names in a namespace to be hidden when
19831978
/// being imported.
19841979
///
@@ -1993,10 +1988,7 @@ abstract class HideElementCombinator implements NamespaceCombinator {
19931988
///
19941989
/// Clients may not extend, implement or mix-in this class.
19951990
abstract class InstanceElement
1996-
implements
1997-
TypeDefiningElement,
1998-
TypeParameterizedElement,
1999-
HasSinceSdkVersion {
1991+
implements TypeDefiningElement, TypeParameterizedElement {
20001992
@override
20011993
InstanceElement get baseElement;
20021994

@@ -2572,8 +2564,7 @@ abstract class LabelFragment implements Fragment {
25722564
/// A library.
25732565
///
25742566
/// Clients may not extend, implement or mix-in this class.
2575-
abstract class LibraryElement
2576-
implements Element, Annotatable, HasSinceSdkVersion {
2567+
abstract class LibraryElement implements Element, Annotatable {
25772568
/// The classes defined in this library.
25782569
///
25792570
/// There is no guarantee of the order in which the classes will be returned.
@@ -3193,7 +3184,7 @@ abstract class Metadata {
31933184
/// method.
31943185
///
31953186
/// Clients may not extend, implement or mix-in this class.
3196-
abstract class MethodElement implements ExecutableElement, HasSinceSdkVersion {
3187+
abstract class MethodElement implements ExecutableElement {
31973188
/// The name of the method that can be implemented by a class to allow its
31983189
/// instances to be invoked as if they were a function.
31993190
static final String CALL_METHOD_NAME = "call";
@@ -3532,8 +3523,7 @@ abstract class PropertyAccessorFragment implements ExecutableFragment {
35323523
/// [PropertyInducingElement].
35333524
///
35343525
/// Clients may not extend, implement or mix-in this class.
3535-
abstract class PropertyInducingElement
3536-
implements VariableElement, Annotatable, HasSinceSdkVersion {
3526+
abstract class PropertyInducingElement implements VariableElement, Annotatable {
35373527
@override
35383528
PropertyInducingFragment get firstFragment;
35393529

@@ -3730,8 +3720,7 @@ abstract class SuperFormalParameterFragment implements FormalParameterFragment {
37303720
/// A top-level function.
37313721
///
37323722
/// Clients may not extend, implement or mix-in this class.
3733-
abstract class TopLevelFunctionElement
3734-
implements ExecutableElement, HasSinceSdkVersion {
3723+
abstract class TopLevelFunctionElement implements ExecutableElement {
37353724
/// The name of the function used as an entry point.
37363725
static const String MAIN_FUNCTION_NAME = "main";
37373726

@@ -3808,10 +3797,7 @@ abstract class TopLevelVariableFragment implements PropertyInducingFragment {
38083797
///
38093798
/// Clients may not extend, implement or mix-in this class.
38103799
abstract class TypeAliasElement
3811-
implements
3812-
TypeParameterizedElement,
3813-
TypeDefiningElement,
3814-
HasSinceSdkVersion {
3800+
implements TypeParameterizedElement, TypeDefiningElement {
38153801
/// If the aliased type has structure, return the corresponding element.
38163802
/// For example, it could be [GenericFunctionTypeElement].
38173803
///

0 commit comments

Comments
 (0)