|
36 | 36 | /// represented by an element. |
37 | 37 | library; |
38 | 38 |
|
39 | | -import 'package:analyzer/dart/analysis/session.dart'; |
40 | 39 | import 'package:analyzer/dart/constant/value.dart'; |
41 | 40 | import 'package:analyzer/dart/element/element2.dart'; |
42 | | -import 'package:analyzer/dart/element/nullability_suffix.dart'; |
43 | 41 | import 'package:analyzer/error/error.dart'; |
44 | 42 | import 'package:analyzer/source/source.dart'; |
45 | 43 | import 'package:analyzer/src/dart/constant/evaluation.dart'; |
46 | | -import 'package:analyzer/src/dart/element/element.dart' |
47 | | - show elementModelDeprecationMsg; |
48 | | -import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
49 | | -// ignore: deprecated_member_use_from_same_package |
50 | | -import 'package:analyzer/src/task/api/model.dart' show AnalysisTarget; |
51 | 44 | import 'package:meta/meta.dart'; |
52 | 45 | import 'package:pub_semver/pub_semver.dart'; |
53 | 46 |
|
@@ -98,263 +91,6 @@ abstract class DirectiveUriWithUnit extends DirectiveUriWithSource { |
98 | 91 | LibraryFragment get libraryFragment; |
99 | 92 | } |
100 | 93 |
|
101 | | -/// The base class for all of the elements in the element model. Generally |
102 | | -/// speaking, the element model is a semantic model of the program that |
103 | | -/// represents things that are declared with a name and hence can be referenced |
104 | | -/// elsewhere in the code. |
105 | | -/// |
106 | | -/// There are two exceptions to the general case. First, there are elements in |
107 | | -/// the element model that are created for the convenience of various kinds of |
108 | | -/// analysis but that do not have any corresponding declaration within the |
109 | | -/// source code. Such elements are marked as being <i>synthetic</i>. Examples of |
110 | | -/// synthetic elements include |
111 | | -/// * default constructors in classes that do not define any explicit |
112 | | -/// constructors, |
113 | | -/// * getters and setters that are induced by explicit field declarations, |
114 | | -/// * fields that are induced by explicit declarations of getters and setters, |
115 | | -/// and |
116 | | -/// * functions representing the initialization expression for a variable. |
117 | | -/// |
118 | | -/// Second, there are elements in the element model that do not have a name. |
119 | | -/// These correspond to unnamed functions and exist in order to more accurately |
120 | | -/// represent the semantic structure of the program. |
121 | | -/// |
122 | | -/// Clients may not extend, implement or mix-in this class. |
123 | | -@Deprecated(elementModelDeprecationMsg) |
124 | | -abstract class Element implements AnalysisTarget { |
125 | | - /// The analysis context in which this element is defined. |
126 | | - AnalysisContext get context; |
127 | | - |
128 | | - /// The declaration of this element. |
129 | | - /// |
130 | | - /// If the element is a view on an element, e.g. a method from an interface |
131 | | - /// type, with substituted type parameters, return the corresponding element |
132 | | - /// from the class, without any substitutions. If this element is already a |
133 | | - /// declaration (or a synthetic element, e.g. a synthetic property accessor), |
134 | | - /// return itself. |
135 | | - @Deprecated(elementModelDeprecationMsg) |
136 | | - Element? get declaration; |
137 | | - |
138 | | - /// The display name of this element, possibly the empty string if the |
139 | | - /// element does not have a name. |
140 | | - /// |
141 | | - /// In most cases the name and the display name are the same. Differences |
142 | | - /// though are cases such as setters where the name of some setter `set f(x)` |
143 | | - /// is `f=`, instead of `f`. |
144 | | - String get displayName; |
145 | | - |
146 | | - /// The content of the documentation comment (including delimiters) for this |
147 | | - /// element, or `null` if this element does not or cannot have documentation. |
148 | | - String? get documentationComment; |
149 | | - |
150 | | - /// The element that either physically or logically encloses this element. |
151 | | - /// |
152 | | - /// For [LibraryElement] returns `null`, because libraries are the top-level |
153 | | - /// elements in the model. |
154 | | - /// |
155 | | - /// For [CompilationUnitElement] returns the [CompilationUnitElement] that |
156 | | - /// uses `part` directive to include this element, or `null` if this element |
157 | | - /// is the defining unit of the library. |
158 | | - @Deprecated('Use Element2.enclosingElement2 instead or ' |
159 | | - 'Fragment.enclosingFragment instead') |
160 | | - Element? get enclosingElement3; |
161 | | - |
162 | | - /// Whether the element has an annotation of the form `@alwaysThrows`. |
163 | | - bool get hasAlwaysThrows; |
164 | | - |
165 | | - /// Whether the element has an annotation of the form `@deprecated` |
166 | | - /// or `@Deprecated('..')`. |
167 | | - bool get hasDeprecated; |
168 | | - |
169 | | - /// Whether the element has an annotation of the form `@doNotStore`. |
170 | | - bool get hasDoNotStore; |
171 | | - |
172 | | - /// Whether the element has an annotation of the form `@doNotSubmit`. |
173 | | - bool get hasDoNotSubmit; |
174 | | - |
175 | | - /// Whether the element has an annotation of the form `@factory`. |
176 | | - bool get hasFactory; |
177 | | - |
178 | | - /// Whether the element has an annotation of the form `@immutable`. |
179 | | - bool get hasImmutable; |
180 | | - |
181 | | - /// Whether the element has an annotation of the form `@internal`. |
182 | | - bool get hasInternal; |
183 | | - |
184 | | - /// Whether the element has an annotation of the form `@isTest`. |
185 | | - bool get hasIsTest; |
186 | | - |
187 | | - /// Whether the element has an annotation of the form `@isTestGroup`. |
188 | | - bool get hasIsTestGroup; |
189 | | - |
190 | | - /// Whether the element has an annotation of the form `@JS(..)`. |
191 | | - bool get hasJS; |
192 | | - |
193 | | - /// Whether the element has an annotation of the form `@literal`. |
194 | | - bool get hasLiteral; |
195 | | - |
196 | | - /// Whether the element has an annotation of the form `@mustBeConst`. |
197 | | - bool get hasMustBeConst; |
198 | | - |
199 | | - /// Whether the element has an annotation of the form `@mustBeOverridden`. |
200 | | - bool get hasMustBeOverridden; |
201 | | - |
202 | | - /// Whether the element has an annotation of the form `@mustCallSuper`. |
203 | | - bool get hasMustCallSuper; |
204 | | - |
205 | | - /// Whether the element has an annotation of the form `@nonVirtual`. |
206 | | - bool get hasNonVirtual; |
207 | | - |
208 | | - /// Whether the element has an annotation of the form `@optionalTypeArgs`. |
209 | | - bool get hasOptionalTypeArgs; |
210 | | - |
211 | | - /// Whether the element has an annotation of the form `@override`. |
212 | | - bool get hasOverride; |
213 | | - |
214 | | - /// Whether the element has an annotation of the form `@protected`. |
215 | | - bool get hasProtected; |
216 | | - |
217 | | - /// Whether the element has an annotation of the form `@redeclare`. |
218 | | - bool get hasRedeclare; |
219 | | - |
220 | | - /// Whether the element has an annotation of the form `@reopen`. |
221 | | - bool get hasReopen; |
222 | | - |
223 | | - /// Whether the element has an annotation of the form `@required`. |
224 | | - bool get hasRequired; |
225 | | - |
226 | | - /// Whether the element has an annotation of the form `@sealed`. |
227 | | - bool get hasSealed; |
228 | | - |
229 | | - /// Whether the element has an annotation of the form `@useResult` |
230 | | - /// or `@UseResult('..')`. |
231 | | - bool get hasUseResult; |
232 | | - |
233 | | - /// Whether the element has an annotation of the form `@visibleForOverriding`. |
234 | | - bool get hasVisibleForOverriding; |
235 | | - |
236 | | - /// Whether the element has an annotation of the form `@visibleForTemplate`. |
237 | | - bool get hasVisibleForTemplate; |
238 | | - |
239 | | - /// Whether the element has an annotation of the form `@visibleForTesting`. |
240 | | - bool get hasVisibleForTesting; |
241 | | - |
242 | | - /// Whether the element has an annotation of the form |
243 | | - /// `@visibleOutsideTemplate`. |
244 | | - bool get hasVisibleOutsideTemplate; |
245 | | - |
246 | | - /// The unique integer identifier of this element. |
247 | | - int get id; |
248 | | - |
249 | | - /// Whether the element is private. |
250 | | - /// |
251 | | - /// Private elements are visible only within the library in which they are |
252 | | - /// declared. |
253 | | - bool get isPrivate; |
254 | | - |
255 | | - /// Whether the element is public. |
256 | | - /// |
257 | | - /// Public elements are visible within any library that imports the library |
258 | | - /// in which they are declared. |
259 | | - bool get isPublic; |
260 | | - |
261 | | - /// Whether the element is synthetic. |
262 | | - /// |
263 | | - /// A synthetic element is an element that is not represented in the source |
264 | | - /// code explicitly, but is implied by the source code, such as the default |
265 | | - /// constructor for a class that does not explicitly define any constructors. |
266 | | - bool get isSynthetic; |
267 | | - |
268 | | - /// The kind of element that this is. |
269 | | - ElementKind get kind; |
270 | | - |
271 | | - /// The location of this element in the element model. |
272 | | - /// |
273 | | - /// The object can be used to locate this element at a later time. |
274 | | - ElementLocation? get location; |
275 | | - |
276 | | - /// All of the metadata associated with this element. |
277 | | - /// |
278 | | - /// The array will be empty if the element does not have any metadata or if |
279 | | - /// the library containing this element has not yet been resolved. |
280 | | - List<ElementAnnotation> get metadata; |
281 | | - |
282 | | - /// The name of this element, or `null` if this element does not have a name. |
283 | | - String? get name; |
284 | | - |
285 | | - /// The length of the name of this element in the file that contains the |
286 | | - /// declaration of this element, or `0` if this element does not have a name. |
287 | | - int get nameLength; |
288 | | - |
289 | | - /// The offset of the name of this element in the file that contains the |
290 | | - /// declaration of this element, or `-1` if this element is synthetic, does |
291 | | - /// not have a name, or otherwise does not have an offset. |
292 | | - int get nameOffset; |
293 | | - |
294 | | - /// The non-synthetic element that caused this element to be created. |
295 | | - /// |
296 | | - /// If this element is not synthetic, then the element itself is returned. |
297 | | - /// |
298 | | - /// If this element is synthetic, then the corresponding non-synthetic |
299 | | - /// element is returned. For example, for a synthetic getter of a |
300 | | - /// non-synthetic field the field is returned; for a synthetic constructor |
301 | | - /// the enclosing class is returned. |
302 | | - @Deprecated(elementModelDeprecationMsg) |
303 | | - Element get nonSynthetic; |
304 | | - |
305 | | - /// The analysis session in which this element is defined. |
306 | | - AnalysisSession? get session; |
307 | | - |
308 | | - /// The version where this SDK API was added. |
309 | | - /// |
310 | | - /// A `@Since()` annotation can be applied to a library declaration, |
311 | | - /// any public declaration in a library, or in a class, or to an optional |
312 | | - /// parameter, etc. |
313 | | - /// |
314 | | - /// The returned version is "effective", so that if a library is annotated |
315 | | - /// then all elements of the library inherit it; or if a class is annotated |
316 | | - /// then all members and constructors of the class inherit it. |
317 | | - /// |
318 | | - /// If multiple `@Since()` annotations apply to the same element, the latest |
319 | | - /// version takes precedence. |
320 | | - /// |
321 | | - /// Returns `null` if the element is not declared in SDK, or does not have |
322 | | - /// a `@Since()` annotation applicable to it. |
323 | | - Version? get sinceSdkVersion; |
324 | | - |
325 | | - @override |
326 | | - Source? get source; |
327 | | - |
328 | | - /// Returns the presentation of this element as it should appear when |
329 | | - /// presented to users. |
330 | | - /// |
331 | | - /// If [withNullability] is `true`, then [NullabilitySuffix.question] and |
332 | | - /// [NullabilitySuffix.star] in types will be represented as `?` and `*`. |
333 | | - /// [NullabilitySuffix.none] does not have any explicit presentation. |
334 | | - /// |
335 | | - /// If [withNullability] is `false`, nullability suffixes will not be |
336 | | - /// included into the presentation. |
337 | | - /// |
338 | | - /// If [multiline] is `true`, the string may be wrapped over multiple lines |
339 | | - /// with newlines to improve formatting. For example function signatures may |
340 | | - /// be formatted as if they had trailing commas. |
341 | | - /// |
342 | | - /// Clients should not depend on the content of the returned value as it will |
343 | | - /// be changed if doing so would improve the UX. |
344 | | - String getDisplayString({ |
345 | | - @Deprecated('Only non-nullable by default mode is supported') |
346 | | - bool withNullability = true, |
347 | | - bool multiline = false, |
348 | | - }); |
349 | | - |
350 | | - /// Returns a display name for the given element that includes the path to the |
351 | | - /// compilation unit in which the type is defined. If [shortName] is `null` |
352 | | - /// then [displayName] will be used as the name of this element. Otherwise |
353 | | - /// the provided name will be used. |
354 | | - // TODO(brianwilkerson): Make the parameter optional. |
355 | | - String getExtendedDisplayName(String? shortName); |
356 | | -} |
357 | | - |
358 | 94 | /// A single annotation associated with an element. |
359 | 95 | /// |
360 | 96 | /// Clients may not extend, implement or mix-in this class. |
|
0 commit comments