Skip to content

Commit cd90f27

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
meta: Introduce TargetKind.constructor
Fixes #47421 Doc nits while I was looking: * wrap CHANGELOG to 80 characters * correct docs on field, getter, method, parameter, setter, typedef, type parameter, Change-Id: I97476e08b6773be53dbce190007443f22626d498 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360124 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 833277f commit cd90f27

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

pkg/meta/CHANGELOG.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.14.0-wip
2+
3+
* Introduce `TargetKind.constructor`, to indicate that an annotation is valid on
4+
any constructor.
5+
* Introduce `TargetKind.typeParamteer`, to indicate that an annotation is valid
6+
on any type parameter.
7+
18
## 1.13.0
29

310
* Add type checks for the `@ResourceIdentifier` experimental annotation.
@@ -6,20 +13,19 @@
613

714
* Introduce the `@ResourceIdentifier` experimental annotation for static methods
815
whose constant literal arguments should be collected during compilation.
9-
* Indicate that `@required` and `@Required` are set
10-
to be deprecated for later removal.
16+
* Indicate that `@required` and `@Required` are set to be deprecated for later
17+
removal.
1118

1219
## 1.11.0
1320

14-
* Introduce `TargetKind.extensionType` to indicate that an annotation
15-
is valid on any extension type declaration.
21+
* Introduce `TargetKind.extensionType` to indicate that an annotation is valid
22+
on any extension type declaration.
1623

1724
## 1.10.0
1825

1926
* Introduce `@redeclare` to annotate extension type members that redeclare
2027
members from a superinterface.
21-
* Migrate the `TargetKind` enum to a class to ease the addition of new
22-
kinds.
28+
* Migrate the `TargetKind` enum to a class to ease the addition of new kinds.
2329

2430
## 1.9.1
2531

@@ -64,8 +70,8 @@
6470

6571
* Introduce `TargetKind.topLevelVariable` that indicates that an annotation
6672
is valid on any top-level variable declaration.
67-
* Introduce `@useResult` to annotate methods, fields, or getters that
68-
return values that should be used - stored, passed as arguments, etc.
73+
* Introduce `@useResult` to annotate methods, fields, or getters that return
74+
values that should be used - stored, passed as arguments, etc.
6975
* Updates for documentation.
7076

7177
## 1.3.0
@@ -75,11 +81,11 @@
7581
## 1.3.0-nullsafety.6
7682

7783
* Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release
78-
guidelines.
84+
guidelines.
7985

8086
## 1.3.0-nullsafety.5
8187

82-
* Allow prerelease versions of the `2.12` sdk.
88+
* Allow prerelease versions of the `2.12` SDK.
8389

8490
## 1.3.0-nullsafety.4
8591

@@ -92,11 +98,11 @@
9298

9399
## 1.3.0-nullsafety.2
94100

95-
* Update for the 2.10 dev sdk.
101+
* Update for the 2.10 dev SDK.
96102

97103
## 1.3.0-nullsafety.1
98104

99-
* Allow the <=2.9.10 stable sdk.
105+
* Allow the <=2.9.10 stable SDK.
100106

101107
## 1.3.0-nullsafety
102108

@@ -119,9 +125,9 @@
119125
* Introduce `unawaited` to mark invocations that return a `Future` where it's
120126
intentional that the future is not being awaited. (Moved from
121127
`package:pedantic`.)
122-
* Introduce `@doNotStore` to annotate methods, getters and functions to
123-
indicate that values obtained by invoking them should not be stored in a
124-
field or top-level variable.
128+
* Introduce `@doNotStore` to annotate methods, getters and functions to indicate
129+
that values obtained by invoking them should not be stored in a field or
130+
top-level variable.
125131

126132
## 1.1.8
127133

pkg/meta/lib/meta_meta.dart

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class TargetKind {
4242
/// Indicates that an annotation is valid on any class declaration.
4343
static const classType = TargetKind._('classes', 'classType');
4444

45+
/// Indicates that an annotation is valid on any constructor declaration, both
46+
/// factory and generative constructors, whether it's in a class, enum, or
47+
/// extension type. Extension type primary constructors are not supported,
48+
/// because there is no way to annotate a primary constructor.
49+
static const constructor = TargetKind._('constructors', 'constructor');
50+
4551
/// Indicates that an annotation is valid on any enum declaration.
4652
static const enumType = TargetKind._('enums', 'enumType');
4753

@@ -52,7 +58,8 @@ class TargetKind {
5258
static const extensionType = TargetKind._('extension types', 'extensionType');
5359

5460
/// Indicates that an annotation is valid on any field declaration, both
55-
/// instance and static fields, whether it's in a class, mixin or extension.
61+
/// instance and static fields, whether it's in a class, enum, mixin, or
62+
/// extension.
5663
static const field = TargetKind._('fields', 'field');
5764

5865
/// Indicates that an annotation is valid on any top-level function
@@ -65,24 +72,26 @@ class TargetKind {
6572
static const library = TargetKind._('libraries', 'library');
6673

6774
/// Indicates that an annotation is valid on any getter declaration, both
68-
/// instance or static getters, whether it's in a class, mixin, extension, or
69-
/// at the top-level of a library.
75+
/// instance or static getters, whether it's in a class, enum, mixin,
76+
/// extension, extension type, or at the top-level of a library.
7077
static const getter = TargetKind._('getters', 'getter');
7178

7279
/// Indicates that an annotation is valid on any method declaration, both
73-
/// instance and static methods, whether it's in a class, mixin or extension.
80+
/// instance and static methods, whether it's in a class, enum, mixin,
81+
/// extension, or extension type.
7482
static const method = TargetKind._('methods', 'method');
7583

7684
/// Indicates that an annotation is valid on any mixin declaration.
7785
static const mixinType = TargetKind._('mixins', 'mixinType');
7886

7987
/// Indicates that an annotation is valid on any formal parameter declaration,
80-
/// whether it's in a function (named or anonymous), method, or constructor.
88+
/// whether it's in a constructor, function (named or anonymous), function
89+
/// type, function-typed formal parameter, or method.
8190
static const parameter = TargetKind._('parameters', 'parameter');
8291

8392
/// Indicates that an annotation is valid on any setter declaration, both
84-
/// instance or static setters, whether it's in a class, mixin, extension, or
85-
/// at the top-level of a library.
93+
/// instance or static setters, whether it's in a class, enum, mixin,
94+
/// extension, extension type, or at the top-level of a library.
8695
static const setter = TargetKind._('setters', 'setter');
8796

8897
/// Indicates that an annotation is valid on any top-level variable
@@ -91,24 +100,25 @@ class TargetKind {
91100
TargetKind._('top-level variables', 'topLevelVariable');
92101

93102
/// Indicates that an annotation is valid on any declaration that introduces a
94-
/// type. This includes classes, enums, mixins and typedefs, but does not
103+
/// type. This includes classes, enums, mixins, and typedefs, but does not
95104
/// include extensions because extensions don't introduce a type.
105+
// TODO(srawlins): This should include extension types.
96106
static const type =
97107
TargetKind._('types (classes, enums, mixins, or typedefs)', 'type');
98108

99-
/// Indicates that an annotation is valid on any typedef declaration.`
109+
/// Indicates that an annotation is valid on any typedef declaration.
100110
static const typedefType = TargetKind._('typedefs', 'typedefType');
101111

102112
/// Indicates that an annotation is valid on any type parameter declaration,
103113
/// whether it's on a class, enum, function type, function, mixin, extension,
104114
/// extension type, or typedef.
105-
static const typeParameter = TargetKind._(
106-
'type parameters (classes, enums, mixins, or typedefs)', 'typeParameter');
115+
static const typeParameter = TargetKind._('type parameters', 'typeParameter');
107116

108117
/// All current [TargetKind] values of targets to
109118
/// which an annotation can be applied.
110119
static const values = [
111120
classType,
121+
constructor,
112122
enumType,
113123
extension,
114124
extensionType,
@@ -122,8 +132,8 @@ class TargetKind {
122132
setter,
123133
topLevelVariable,
124134
type,
125-
typeParameter,
126135
typedefType,
136+
typeParameter,
127137
];
128138

129139
/// A user visible string used to describe this target kind.

pkg/meta/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: meta
22
# Note, because version `2.0.0` was mistakenly released,
33
# the next major version must be `3.x.y`.
4-
version: 1.13.0
4+
version: 1.14.0-wip
55
description: >-
66
Annotations used to express developer intentions that can't otherwise be
77
deduced by statically analyzing source code.

0 commit comments

Comments
 (0)