OLD | NEW |
---|---|
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Constants for use in metadata annotations. | 5 /// Constants for use in metadata annotations. |
6 /// | 6 /// |
7 /// See also `@deprecated` and `@override` in the `dart:core` library. | 7 /// See also `@deprecated` and `@override` in the `dart:core` library. |
8 /// | 8 /// |
9 /// Annotations provide semantic information that tools can use to provide a | 9 /// Annotations provide semantic information that tools can use to provide a |
10 /// better user experience. For example, an IDE might not autocomplete the name | 10 /// better user experience. For example, an IDE might not autocomplete the name |
11 /// of a function that's been marked `@deprecated`, or it might display the | 11 /// of a function that's been marked `@deprecated`, or it might display the |
12 /// function's name differently. | 12 /// function's name differently. |
13 /// | 13 /// |
14 /// For information on installing and importing this library, see the | 14 /// For information on installing and importing this library, see the |
15 /// [meta package on pub.dartlang.org] (http://pub.dartlang.org/packages/meta). | 15 /// [meta package on pub.dartlang.org] (http://pub.dartlang.org/packages/meta). |
16 /// For examples of using annotations, see | 16 /// For examples of using annotations, see |
17 /// [Metadata](https://www.dartlang.org/docs/dart-up-and-running/ch02.html#metad ata) | 17 /// [Metadata](https://www.dartlang.org/docs/dart-up-and-running/ch02.html#metad ata) |
18 /// in the language tour. | 18 /// in the language tour. |
19 library meta; | 19 library meta; |
20 | 20 |
21 /// Used to annotate a parameter of an instance method that overrides another | |
22 /// method. | |
23 /// | |
24 /// Indicates that this parameter may have a tighter type than the parameter on | |
25 /// its superclass. The actual argument will be checked at runtime to ensure it | |
26 /// is a subtype of the overridden parameter type. | |
27 const _Checked checked = const _Checked(); | |
28 | |
21 /// Used to annotate an instance or static method `m`. Indicates that `m` must | 29 /// Used to annotate an instance or static method `m`. Indicates that `m` must |
22 /// either be abstract or must return a newly allocated object or `null`. In | 30 /// either be abstract or must return a newly allocated object or `null`. In |
23 /// addition, every method that either implements or overrides `m` is implicitly | 31 /// addition, every method that either implements or overrides `m` is implicitly |
24 /// annotated with this same annotation. | 32 /// annotated with this same annotation. |
25 /// | 33 /// |
26 /// Tools, such as the analyzer, can provide feedback if | 34 /// Tools, such as the analyzer, can provide feedback if |
27 /// | 35 /// |
28 /// * the annotation is associated with anything other than a method, or | 36 /// * the annotation is associated with anything other than a method, or |
29 /// * the annotation is associated with a method that has this annotation that | 37 /// * the annotation is associated with a method that has this annotation that |
30 /// can return anything other than a newly allocated object or `null`. | 38 /// can return anything other than a newly allocated object or `null`. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 /// Tools, such as the analyzer, can provide feedback if | 98 /// Tools, such as the analyzer, can provide feedback if |
91 /// | 99 /// |
92 /// * the annotation is associated with anything other than a named parameter, | 100 /// * the annotation is associated with anything other than a named parameter, |
93 /// * the annotation is associated with a named parameter in a method `m1` that | 101 /// * the annotation is associated with a named parameter in a method `m1` that |
94 /// overrides a method `m0` and `m0` defines a named parameter with the same | 102 /// overrides a method `m0` and `m0` defines a named parameter with the same |
95 /// name that does not have this annotation, or | 103 /// name that does not have this annotation, or |
96 /// * an invocation of a method or function does not include an argument | 104 /// * an invocation of a method or function does not include an argument |
97 /// corresponding to a named parameter that has this annotation. | 105 /// corresponding to a named parameter that has this annotation. |
98 const Required required = const Required(); | 106 const Required required = const Required(); |
99 | 107 |
108 /// Used to annotate a field that is allowed to be overridden in Strong Mode. | |
109 const _Virtual virtual = const _Virtual(); | |
Alexei Diaz
2016/10/13 16:36:58
Could this somehow be extended to methods? Like th
Brian Wilkerson
2016/10/13 18:17:00
This annotation (which wasn't added by this CL, me
| |
110 | |
111 /// Used to annotate an instance member that was made public so that it could be | |
112 /// overridden but that is not intended to be referenced from outside the | |
113 /// defining library. | |
114 /// | |
115 /// Tools, such as the analyzer, can provide feedback if | |
116 /// | |
117 /// * the annotation is associated with a declaration other than a public | |
118 /// instance member in a class, or | |
119 /// * the member is referenced outside of the defining library. | |
120 const _VisibleForOverriding visibleForOverriding = | |
121 const _VisibleForOverriding(); | |
122 | |
100 /// Used to annotate a declaration was made public, so that it is more visible | 123 /// Used to annotate a declaration was made public, so that it is more visible |
101 /// than otherwise necessary, to make code testable. | 124 /// than otherwise necessary, to make code testable. |
102 /// | 125 /// |
103 /// Tools, such as the analyzer, can provide feedback if | 126 /// Tools, such as the analyzer, can provide feedback if |
104 /// | 127 /// |
105 /// * the annotation is associated with a declaration not in the `lib` folder | 128 /// * the annotation is associated with a declaration not in the `lib` folder |
106 /// of a package; | 129 /// of a package; |
107 /// or | 130 /// or |
108 /// * the declaration is referenced outside of its the defining library or a | 131 /// * the declaration is referenced outside of its the defining library or a |
109 /// library which is in the `test` folder of the defining package. | 132 /// library which is in the `test` folder of the defining package. |
(...skipping 11 matching lines...) Expand all Loading... | |
121 /// @Required('Buttons must do something when pressed') | 144 /// @Required('Buttons must do something when pressed') |
122 /// Function onPressed, | 145 /// Function onPressed, |
123 /// ... | 146 /// ... |
124 /// }) ... | 147 /// }) ... |
125 final String reason; | 148 final String reason; |
126 | 149 |
127 /// Initialize a newly created instance to have the given [reason]. | 150 /// Initialize a newly created instance to have the given [reason]. |
128 const Required([this.reason]); | 151 const Required([this.reason]); |
129 } | 152 } |
130 | 153 |
131 /// Used to annotate a parameter of an instance method that overrides another | |
132 /// method. | |
133 /// | |
134 /// Indicates that this parameter may have a tighter type than the parameter on | |
135 /// its superclass. The actual argument will be checked at runtime to ensure it | |
136 /// is a subtype of the overridden parameter type. | |
137 const _Checked checked = const _Checked(); | |
138 | |
139 /// Used to annotate a field is allowed to be overridden in Strong Mode. | |
140 const _Virtual virtual = const _Virtual(); | |
141 | |
142 class _Checked { | 154 class _Checked { |
143 const _Checked(); | 155 const _Checked(); |
144 } | 156 } |
145 | 157 |
146 class _Factory { | 158 class _Factory { |
147 const _Factory(); | 159 const _Factory(); |
148 } | 160 } |
149 | 161 |
150 class _Literal { | 162 class _Literal { |
151 const _Literal(); | 163 const _Literal(); |
152 } | 164 } |
153 | 165 |
154 class _MustCallSuper { | 166 class _MustCallSuper { |
155 const _MustCallSuper(); | 167 const _MustCallSuper(); |
156 } | 168 } |
157 | 169 |
158 class _OptionalTypeArgs { | 170 class _OptionalTypeArgs { |
159 const _OptionalTypeArgs(); | 171 const _OptionalTypeArgs(); |
160 } | 172 } |
161 | 173 |
162 class _Protected { | 174 class _Protected { |
163 const _Protected(); | 175 const _Protected(); |
164 } | 176 } |
165 | 177 |
166 class _Virtual { | 178 class _Virtual { |
167 const _Virtual(); | 179 const _Virtual(); |
168 } | 180 } |
169 | 181 |
182 class _VisibleForOverriding { | |
183 const _VisibleForOverriding(); | |
184 } | |
185 | |
170 class _VisibleForTesting { | 186 class _VisibleForTesting { |
171 const _VisibleForTesting(); | 187 const _VisibleForTesting(); |
172 } | 188 } |
OLD | NEW |