OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library analyzer.dart.element.element; |
| 6 |
| 7 import 'package:analyzer/dart/element/type.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/constant.dart' show DartObject; |
| 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| 11 import 'package:analyzer/src/generated/java_core.dart'; |
| 12 import 'package:analyzer/src/generated/java_engine.dart'; |
| 13 import 'package:analyzer/src/generated/resolver.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 16 import 'package:analyzer/src/task/dart.dart'; |
| 17 import 'package:analyzer/task/model.dart' show AnalysisTarget; |
| 18 |
| 19 /** |
| 20 * An element that represents a class. |
| 21 * |
| 22 * Clients may not extend, implement or mix-in this class. |
| 23 */ |
| 24 abstract class ClassElement |
| 25 implements TypeDefiningElement, TypeParameterizedElement { |
| 26 /** |
| 27 * An empty list of class elements. |
| 28 */ |
| 29 static const List<ClassElement> EMPTY_LIST = const <ClassElement>[]; |
| 30 |
| 31 /** |
| 32 * Return a list containing all of the accessors (getters and setters) |
| 33 * declared in this class. |
| 34 */ |
| 35 List<PropertyAccessorElement> get accessors; |
| 36 |
| 37 /** |
| 38 * Return a list containing all the supertypes defined for this class and its |
| 39 * supertypes. This includes superclasses, mixins and interfaces. |
| 40 */ |
| 41 List<InterfaceType> get allSupertypes; |
| 42 |
| 43 /** |
| 44 * Return a list containing all of the constructors declared in this class. |
| 45 */ |
| 46 List<ConstructorElement> get constructors; |
| 47 |
| 48 /** |
| 49 * Return a list containing all of the fields declared in this class. |
| 50 */ |
| 51 List<FieldElement> get fields; |
| 52 |
| 53 /** |
| 54 * Return `true` if this class or its superclass declares a non-final instance |
| 55 * field. |
| 56 */ |
| 57 bool get hasNonFinalField; |
| 58 |
| 59 /** |
| 60 * Return `true` if this class has reference to super (so, for example, cannot |
| 61 * be used as a mixin). |
| 62 */ |
| 63 bool get hasReferenceToSuper; |
| 64 |
| 65 /** |
| 66 * Return `true` if this class declares a static member. |
| 67 */ |
| 68 bool get hasStaticMember; |
| 69 |
| 70 /** |
| 71 * Return a list containing all of the interfaces that are implemented by this |
| 72 * class. |
| 73 * |
| 74 * <b>Note:</b> Because the element model represents the state of the code, it |
| 75 * is possible for it to be semantically invalid. In particular, it is not |
| 76 * safe to assume that the inheritance structure of a class does not contain a |
| 77 * cycle. Clients that traverse the inheritance structure must explicitly |
| 78 * guard against infinite loops. |
| 79 */ |
| 80 List<InterfaceType> get interfaces; |
| 81 |
| 82 /** |
| 83 * Return `true` if this class is abstract. A class is abstract if it has an |
| 84 * explicit `abstract` modifier. Note, that this definition of <i>abstract</i> |
| 85 * is different from <i>has unimplemented members</i>. |
| 86 */ |
| 87 bool get isAbstract; |
| 88 |
| 89 /** |
| 90 * Return `true` if this class is defined by an enum declaration. |
| 91 */ |
| 92 bool get isEnum; |
| 93 |
| 94 /** |
| 95 * Return `true` if this class is a mixin application. A class is a mixin |
| 96 * application if it was declared using the syntax "class A = B with C;". |
| 97 */ |
| 98 bool get isMixinApplication; |
| 99 |
| 100 /** |
| 101 * Return `true` if this class [isProxy], or if it inherits the proxy |
| 102 * annotation from a supertype. |
| 103 */ |
| 104 bool get isOrInheritsProxy; |
| 105 |
| 106 /** |
| 107 * Return `true` if this element has an annotation of the form '@proxy'. |
| 108 */ |
| 109 bool get isProxy; |
| 110 |
| 111 /** |
| 112 * Return `true` if this class can validly be used as a mixin when defining |
| 113 * another class. The behavior of this method is defined by the Dart Language |
| 114 * Specification in section 9: |
| 115 * <blockquote> |
| 116 * It is a compile-time error if a declared or derived mixin refers to super. |
| 117 * It is a compile-time error if a declared or derived mixin explicitly |
| 118 * declares a constructor. It is a compile-time error if a mixin is derived |
| 119 * from a class whose superclass is not Object. |
| 120 * </blockquote> |
| 121 */ |
| 122 bool get isValidMixin; |
| 123 |
| 124 /** |
| 125 * Return a list containing all of the methods declared in this class. |
| 126 */ |
| 127 List<MethodElement> get methods; |
| 128 |
| 129 /** |
| 130 * Return a list containing all of the mixins that are applied to the class |
| 131 * being extended in order to derive the superclass of this class. |
| 132 * |
| 133 * <b>Note:</b> Because the element model represents the state of the code, it |
| 134 * is possible for it to be semantically invalid. In particular, it is not |
| 135 * safe to assume that the inheritance structure of a class does not contain a |
| 136 * cycle. Clients that traverse the inheritance structure must explicitly |
| 137 * guard against infinite loops. |
| 138 */ |
| 139 List<InterfaceType> get mixins; |
| 140 |
| 141 /** |
| 142 * Return the superclass of this class, or `null` if the class represents the |
| 143 * class 'Object'. All other classes will have a non-`null` superclass. If the |
| 144 * superclass was not explicitly declared then the implicit superclass |
| 145 * 'Object' will be returned. |
| 146 * |
| 147 * <b>Note:</b> Because the element model represents the state of the code, it |
| 148 * is possible for it to be semantically invalid. In particular, it is not |
| 149 * safe to assume that the inheritance structure of a class does not contain a |
| 150 * cycle. Clients that traverse the inheritance structure must explicitly |
| 151 * guard against infinite loops. |
| 152 */ |
| 153 InterfaceType get supertype; |
| 154 |
| 155 @override |
| 156 InterfaceType get type; |
| 157 |
| 158 /** |
| 159 * Return the unnamed constructor declared in this class, or `null` if this |
| 160 * class does not declare an unnamed constructor but does declare named |
| 161 * constructors. The returned constructor will be synthetic if this class does |
| 162 * not declare any constructors, in which case it will represent the default |
| 163 * constructor for the class. |
| 164 */ |
| 165 ConstructorElement get unnamedConstructor; |
| 166 |
| 167 @override |
| 168 NamedCompilationUnitMember computeNode(); |
| 169 |
| 170 /** |
| 171 * Return the field (synthetic or explicit) defined in this class that has the |
| 172 * given [name], or `null` if this class does not define a field with the |
| 173 * given name. |
| 174 */ |
| 175 FieldElement getField(String name); |
| 176 |
| 177 /** |
| 178 * Return the element representing the getter with the given [name] that is |
| 179 * declared in this class, or `null` if this class does not declare a getter |
| 180 * with the given name. |
| 181 */ |
| 182 PropertyAccessorElement getGetter(String name); |
| 183 |
| 184 /** |
| 185 * Return the element representing the method with the given [name] that is |
| 186 * declared in this class, or `null` if this class does not declare a method |
| 187 * with the given name. |
| 188 */ |
| 189 MethodElement getMethod(String name); |
| 190 |
| 191 /** |
| 192 * Return the named constructor declared in this class with the given [name], |
| 193 * or `null` if this class does not declare a named constructor with the given |
| 194 * name. |
| 195 */ |
| 196 ConstructorElement getNamedConstructor(String name); |
| 197 |
| 198 /** |
| 199 * Return the element representing the setter with the given [name] that is |
| 200 * declared in this class, or `null` if this class does not declare a setter |
| 201 * with the given name. |
| 202 */ |
| 203 PropertyAccessorElement getSetter(String name); |
| 204 |
| 205 /** |
| 206 * Determine whether the given [constructor], which exists in the superclass |
| 207 * of this class, is accessible to constructors in this class. |
| 208 */ |
| 209 bool isSuperConstructorAccessible(ConstructorElement constructor); |
| 210 |
| 211 /** |
| 212 * Return the element representing the method that results from looking up the |
| 213 * given [methodName] in this class with respect to the given [library], |
| 214 * ignoring abstract methods, or `null` if the look up fails. The behavior of |
| 215 * this method is defined by the Dart Language Specification in section |
| 216 * 16.15.1: |
| 217 * <blockquote> |
| 218 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 219 * library <i>L</i> is: If <i>C</i> declares an instance method named <i>m</i> |
| 220 * that is accessible to <i>L</i>, then that method is the result of the |
| 221 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 222 * of the lookup is the result of looking up method <i>m</i> in <i>S</i> with |
| 223 * respect to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 224 * </blockquote> |
| 225 */ |
| 226 MethodElement lookUpConcreteMethod(String methodName, LibraryElement library); |
| 227 |
| 228 /** |
| 229 * Return the element representing the getter that results from looking up the |
| 230 * given [getterName] in this class with respect to the given [library], or |
| 231 * `null` if the look up fails. The behavior of this method is defined by the |
| 232 * Dart Language Specification in section 16.15.2: |
| 233 * <blockquote> |
| 234 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 235 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 236 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 237 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 238 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 239 * of the lookup is the result of looking up getter (respectively setter) |
| 240 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 241 * lookup has failed. |
| 242 * </blockquote> |
| 243 */ |
| 244 PropertyAccessorElement lookUpGetter( |
| 245 String getterName, LibraryElement library); |
| 246 |
| 247 /** |
| 248 * Return the element representing the getter that results from looking up the |
| 249 * given [getterName] in the superclass of this class with respect to the |
| 250 * given [library], ignoring abstract getters, or `null` if the look up fails. |
| 251 * The behavior of this method is defined by the Dart Language Specification |
| 252 * in section 16.15.2: |
| 253 * <blockquote> |
| 254 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 255 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 256 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 257 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 258 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 259 * of the lookup is the result of looking up getter (respectively setter) |
| 260 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 261 * lookup has failed. |
| 262 * </blockquote> |
| 263 */ |
| 264 PropertyAccessorElement lookUpInheritedConcreteGetter( |
| 265 String getterName, LibraryElement library); |
| 266 |
| 267 /** |
| 268 * Return the element representing the method that results from looking up the |
| 269 * given [methodName] in the superclass of this class with respect to the |
| 270 * given [library], ignoring abstract methods, or `null` if the look up fails. |
| 271 * The behavior of this method is defined by the Dart Language Specification |
| 272 * in section 16.15.1: |
| 273 * <blockquote> |
| 274 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 275 * library <i>L</i> is: If <i>C</i> declares an instance method named |
| 276 * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
| 277 * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
| 278 * result of the lookup is the result of looking up method <i>m</i> in |
| 279 * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
| 280 * failed. |
| 281 * </blockquote> |
| 282 */ |
| 283 MethodElement lookUpInheritedConcreteMethod( |
| 284 String methodName, LibraryElement library); |
| 285 |
| 286 /** |
| 287 * Return the element representing the setter that results from looking up the |
| 288 * given [setterName] in the superclass of this class with respect to the |
| 289 * given [library], ignoring abstract setters, or `null` if the look up fails. |
| 290 * The behavior of this method is defined by the Dart Language Specification |
| 291 * in section 16.15.2: |
| 292 * <blockquote> |
| 293 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 294 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 295 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 296 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 297 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 298 * of the lookup is the result of looking up getter (respectively setter) |
| 299 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 300 * lookup has failed. |
| 301 * </blockquote> |
| 302 */ |
| 303 PropertyAccessorElement lookUpInheritedConcreteSetter( |
| 304 String setterName, LibraryElement library); |
| 305 |
| 306 /** |
| 307 * Return the element representing the method that results from looking up the |
| 308 * given [methodName] in the superclass of this class with respect to the |
| 309 * given [library], or `null` if the look up fails. The behavior of this |
| 310 * method is defined by the Dart Language Specification in section 16.15.1: |
| 311 * <blockquote> |
| 312 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 313 * library <i>L</i> is: If <i>C</i> declares an instance method named |
| 314 * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
| 315 * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
| 316 * result of the lookup is the result of looking up method <i>m</i> in |
| 317 * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
| 318 * failed. |
| 319 * </blockquote> |
| 320 */ |
| 321 MethodElement lookUpInheritedMethod( |
| 322 String methodName, LibraryElement library); |
| 323 |
| 324 /** |
| 325 * Return the element representing the method that results from looking up the |
| 326 * given [methodName] in this class with respect to the given [library], or |
| 327 * `null` if the look up fails. The behavior of this method is defined by the |
| 328 * Dart Language Specification in section 16.15.1: |
| 329 * <blockquote> |
| 330 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 331 * library <i>L</i> is: If <i>C</i> declares an instance method named |
| 332 * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
| 333 * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
| 334 * result of the lookup is the result of looking up method <i>m</i> in |
| 335 * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
| 336 * failed. |
| 337 * </blockquote> |
| 338 */ |
| 339 MethodElement lookUpMethod(String methodName, LibraryElement library); |
| 340 |
| 341 /** |
| 342 * Return the element representing the setter that results from looking up the |
| 343 * given [setterName] in this class with respect to the given [library], or |
| 344 * `null` if the look up fails. The behavior of this method is defined by the |
| 345 * Dart Language Specification in section 16.15.2: |
| 346 * <blockquote> |
| 347 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 348 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 349 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 350 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 351 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 352 * of the lookup is the result of looking up getter (respectively setter) |
| 353 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 354 * lookup has failed. |
| 355 * </blockquote> |
| 356 */ |
| 357 PropertyAccessorElement lookUpSetter( |
| 358 String setterName, LibraryElement library); |
| 359 } |
| 360 |
| 361 /** |
| 362 * An element that is contained within a [ClassElement]. |
| 363 * |
| 364 * Clients may not extend, implement or mix-in this class. |
| 365 */ |
| 366 abstract class ClassMemberElement implements Element { |
| 367 @override |
| 368 ClassElement get enclosingElement; |
| 369 |
| 370 /** |
| 371 * Return `true` if this element is a static element. A static element is an |
| 372 * element that is not associated with a particular instance, but rather with |
| 373 * an entire library or class. |
| 374 */ |
| 375 bool get isStatic; |
| 376 } |
| 377 |
| 378 /** |
| 379 * An element representing a compilation unit. |
| 380 * |
| 381 * Clients may not extend, implement or mix-in this class. |
| 382 */ |
| 383 abstract class CompilationUnitElement implements Element, UriReferencedElement { |
| 384 /** |
| 385 * An empty list of compilation unit elements. |
| 386 */ |
| 387 static const List<CompilationUnitElement> EMPTY_LIST = |
| 388 const <CompilationUnitElement>[]; |
| 389 |
| 390 /** |
| 391 * Return a list containing all of the top-level accessors (getters and |
| 392 * setters) contained in this compilation unit. |
| 393 */ |
| 394 List<PropertyAccessorElement> get accessors; |
| 395 |
| 396 @override |
| 397 LibraryElement get enclosingElement; |
| 398 |
| 399 /** |
| 400 * Return a list containing all of the enums contained in this compilation |
| 401 * unit. |
| 402 */ |
| 403 List<ClassElement> get enums; |
| 404 |
| 405 /** |
| 406 * Return a list containing all of the top-level functions contained in this |
| 407 * compilation unit. |
| 408 */ |
| 409 List<FunctionElement> get functions; |
| 410 |
| 411 /** |
| 412 * Return a list containing all of the function type aliases contained in this |
| 413 * compilation unit. |
| 414 */ |
| 415 List<FunctionTypeAliasElement> get functionTypeAliases; |
| 416 |
| 417 /** |
| 418 * Return `true` if this compilation unit defines a top-level function named |
| 419 * `loadLibrary`. |
| 420 */ |
| 421 bool get hasLoadLibraryFunction; |
| 422 |
| 423 /** |
| 424 * Return a list containing all of the top-level variables contained in this |
| 425 * compilation unit. |
| 426 */ |
| 427 List<TopLevelVariableElement> get topLevelVariables; |
| 428 |
| 429 /** |
| 430 * Return a list containing all of the classes contained in this compilation |
| 431 * unit. |
| 432 */ |
| 433 List<ClassElement> get types; |
| 434 |
| 435 @override |
| 436 CompilationUnit computeNode(); |
| 437 |
| 438 /** |
| 439 * Return the element at the given [offset], maybe `null` if no such element. |
| 440 */ |
| 441 Element getElementAt(int offset); |
| 442 |
| 443 /** |
| 444 * Return the enum defined in this compilation unit that has the given [name], |
| 445 * or `null` if this compilation unit does not define an enum with the given |
| 446 * name. |
| 447 */ |
| 448 ClassElement getEnum(String name); |
| 449 |
| 450 /** |
| 451 * Return the class defined in this compilation unit that has the given |
| 452 * [name], or `null` if this compilation unit does not define a class with the |
| 453 * given name. |
| 454 */ |
| 455 ClassElement getType(String name); |
| 456 } |
| 457 |
| 458 /** |
| 459 * An element representing a constructor or a factory method defined within a |
| 460 * class. |
| 461 * |
| 462 * Clients may not extend, implement or mix-in this class. |
| 463 */ |
| 464 abstract class ConstructorElement |
| 465 implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget { |
| 466 /** |
| 467 * An empty list of constructor elements. |
| 468 */ |
| 469 static const List<ConstructorElement> EMPTY_LIST = |
| 470 const <ConstructorElement>[]; |
| 471 |
| 472 /** |
| 473 * Return `true` if this constructor is a const constructor. |
| 474 */ |
| 475 bool get isConst; |
| 476 |
| 477 /** |
| 478 * Return `true` if this constructor can be used as a default constructor - |
| 479 * unnamed and has no required parameters. |
| 480 */ |
| 481 bool get isDefaultConstructor; |
| 482 |
| 483 /** |
| 484 * Return `true` if this constructor represents a factory constructor. |
| 485 */ |
| 486 bool get isFactory; |
| 487 |
| 488 /** |
| 489 * Return the offset of the character immediately following the last character |
| 490 * of this constructor's name, or `null` if not named. |
| 491 */ |
| 492 int get nameEnd; |
| 493 |
| 494 /** |
| 495 * Return the offset of the `.` before this constructor name, or `null` if |
| 496 * not named. |
| 497 */ |
| 498 int get periodOffset; |
| 499 |
| 500 /** |
| 501 * Return the constructor to which this constructor is redirecting, or `null` |
| 502 * if this constructor does not redirect to another constructor or if the |
| 503 * library containing this constructor has not yet been resolved. |
| 504 */ |
| 505 ConstructorElement get redirectedConstructor; |
| 506 |
| 507 @override |
| 508 ConstructorDeclaration computeNode(); |
| 509 } |
| 510 |
| 511 /** |
| 512 * The base class for all of the elements in the element model. Generally |
| 513 * speaking, the element model is a semantic model of the program that |
| 514 * represents things that are declared with a name and hence can be referenced |
| 515 * elsewhere in the code. |
| 516 * |
| 517 * There are two exceptions to the general case. First, there are elements in |
| 518 * the element model that are created for the convenience of various kinds of |
| 519 * analysis but that do not have any corresponding declaration within the source |
| 520 * code. Such elements are marked as being <i>synthetic</i>. Examples of |
| 521 * synthetic elements include |
| 522 * * default constructors in classes that do not define any explicit |
| 523 * constructors, |
| 524 * * getters and setters that are induced by explicit field declarations, |
| 525 * * fields that are induced by explicit declarations of getters and setters, |
| 526 * and |
| 527 * * functions representing the initialization expression for a variable. |
| 528 * |
| 529 * Second, there are elements in the element model that do not have a name. |
| 530 * These correspond to unnamed functions and exist in order to more accurately |
| 531 * represent the semantic structure of the program. |
| 532 * |
| 533 * Clients may not extend, implement or mix-in this class. |
| 534 */ |
| 535 abstract class Element implements AnalysisTarget { |
| 536 /** |
| 537 * A comparator that can be used to sort elements by their name offset. |
| 538 * Elements with a smaller offset will be sorted to be before elements with a |
| 539 * larger name offset. |
| 540 */ |
| 541 static final Comparator<Element> SORT_BY_OFFSET = |
| 542 (Element firstElement, Element secondElement) => |
| 543 firstElement.nameOffset - secondElement.nameOffset; |
| 544 |
| 545 /** |
| 546 * Return the analysis context in which this element is defined. |
| 547 */ |
| 548 AnalysisContext get context; |
| 549 |
| 550 /** |
| 551 * Return the display name of this element, or `null` if this element does not |
| 552 * have a name. |
| 553 * |
| 554 * In most cases the name and the display name are the same. Differences |
| 555 * though are cases such as setters where the name of some setter `set f(x)` |
| 556 * is `f=`, instead of `f`. |
| 557 */ |
| 558 String get displayName; |
| 559 |
| 560 /** |
| 561 * Return the source range of the documentation comment for this element, |
| 562 * or `null` if this element does not or cannot have a documentation. |
| 563 */ |
| 564 SourceRange get docRange; |
| 565 |
| 566 /** |
| 567 * Return the element that either physically or logically encloses this |
| 568 * element. This will be `null` if this element is a library because libraries |
| 569 * are the top-level elements in the model. |
| 570 */ |
| 571 Element get enclosingElement; |
| 572 |
| 573 /** |
| 574 * The unique integer identifier of this element. |
| 575 */ |
| 576 int get id; |
| 577 |
| 578 /** |
| 579 * Return `true` if this element has an annotation of the form '@deprecated' |
| 580 * or '@Deprecated('..')'. |
| 581 */ |
| 582 bool get isDeprecated; |
| 583 |
| 584 /** |
| 585 * Return `true` if this element has an annotation of the form '@override'. |
| 586 */ |
| 587 bool get isOverride; |
| 588 |
| 589 /** |
| 590 * Return `true` if this element is private. Private elements are visible only |
| 591 * within the library in which they are declared. |
| 592 */ |
| 593 bool get isPrivate; |
| 594 |
| 595 /** |
| 596 * Return `true` if this element is public. Public elements are visible within |
| 597 * any library that imports the library in which they are declared. |
| 598 */ |
| 599 bool get isPublic; |
| 600 |
| 601 /** |
| 602 * Return `true` if this element is synthetic. A synthetic element is an |
| 603 * element that is not represented in the source code explicitly, but is |
| 604 * implied by the source code, such as the default constructor for a class |
| 605 * that does not explicitly define any constructors. |
| 606 */ |
| 607 bool get isSynthetic; |
| 608 |
| 609 /** |
| 610 * Return the kind of element that this is. |
| 611 */ |
| 612 ElementKind get kind; |
| 613 |
| 614 /** |
| 615 * Return the library that contains this element. This will be the element |
| 616 * itself if it is a library element. This will be `null` if this element is |
| 617 * an HTML file because HTML files are not contained in libraries. |
| 618 */ |
| 619 LibraryElement get library; |
| 620 |
| 621 /** |
| 622 * Return an object representing the location of this element in the element |
| 623 * model. The object can be used to locate this element at a later time. |
| 624 */ |
| 625 ElementLocation get location; |
| 626 |
| 627 /** |
| 628 * Return a list containing all of the metadata associated with this element. |
| 629 * The array will be empty if the element does not have any metadata or if the |
| 630 * library containing this element has not yet been resolved. |
| 631 */ |
| 632 List<ElementAnnotation> get metadata; |
| 633 |
| 634 /** |
| 635 * Return the name of this element, or `null` if this element does not have a |
| 636 * name. |
| 637 */ |
| 638 String get name; |
| 639 |
| 640 /** |
| 641 * Return the length of the name of this element in the file that contains the |
| 642 * declaration of this element, or `0` if this element does not have a name. |
| 643 */ |
| 644 int get nameLength; |
| 645 |
| 646 /** |
| 647 * Return the offset of the name of this element in the file that contains the |
| 648 * declaration of this element, or `-1` if this element is synthetic, does not |
| 649 * have a name, or otherwise does not have an offset. |
| 650 */ |
| 651 int get nameOffset; |
| 652 |
| 653 @override |
| 654 Source get source; |
| 655 |
| 656 /** |
| 657 * Return the resolved [CompilationUnit] that declares this element, or `null` |
| 658 * if this element is synthetic. |
| 659 * |
| 660 * This method is expensive, because resolved AST might have been already |
| 661 * evicted from cache, so parsing and resolving will be performed. |
| 662 */ |
| 663 CompilationUnit get unit; |
| 664 |
| 665 /** |
| 666 * Use the given [visitor] to visit this element. Return the value returned by |
| 667 * the visitor as a result of visiting this element. |
| 668 */ |
| 669 accept(ElementVisitor visitor); |
| 670 |
| 671 /** |
| 672 * Return the documentation comment for this element as it appears in the |
| 673 * original source (complete with the beginning and ending delimiters), or |
| 674 * `null` if this element does not have a documentation comment associated |
| 675 * with it. This can be a long-running operation if the information needed to |
| 676 * access the comment is not cached. |
| 677 * |
| 678 * Throws [AnalysisException] if the documentation comment could not be |
| 679 * determined because the analysis could not be performed |
| 680 */ |
| 681 String computeDocumentationComment(); |
| 682 |
| 683 /** |
| 684 * Return the resolved [AstNode] node that declares this element, or `null` if |
| 685 * this element is synthetic or isn't contained in a compilation unit, such as |
| 686 * a [LibraryElement]. |
| 687 * |
| 688 * This method is expensive, because resolved AST might be evicted from cache, |
| 689 * so parsing and resolving will be performed. |
| 690 * |
| 691 * <b>Note:</b> This method cannot be used in an async environment. |
| 692 */ |
| 693 AstNode computeNode(); |
| 694 |
| 695 /** |
| 696 * Return the most immediate ancestor of this element for which the |
| 697 * [predicate] returns `true`, or `null` if there is no such ancestor. Note |
| 698 * that this element will never be returned. |
| 699 */ |
| 700 Element getAncestor(Predicate<Element> predicate); |
| 701 |
| 702 /** |
| 703 * Return a display name for the given element that includes the path to the |
| 704 * compilation unit in which the type is defined. If [shortName] is `null` |
| 705 * then [getDisplayName] will be used as the name of this element. Otherwise |
| 706 * the provided name will be used. |
| 707 */ |
| 708 // TODO(brianwilkerson) Make the parameter optional. |
| 709 String getExtendedDisplayName(String shortName); |
| 710 |
| 711 /** |
| 712 * Return `true` if this element, assuming that it is within scope, is |
| 713 * accessible to code in the given [library]. This is defined by the Dart |
| 714 * Language Specification in section 3.2: |
| 715 * <blockquote> |
| 716 * A declaration <i>m</i> is accessible to library <i>L</i> if <i>m</i> is |
| 717 * declared in <i>L</i> or if <i>m</i> is public. |
| 718 * </blockquote> |
| 719 */ |
| 720 bool isAccessibleIn(LibraryElement library); |
| 721 |
| 722 /** |
| 723 * Use the given [visitor] to visit all of the children of this element. There |
| 724 * is no guarantee of the order in which the children will be visited. |
| 725 */ |
| 726 void visitChildren(ElementVisitor visitor); |
| 727 } |
| 728 |
| 729 /** |
| 730 * A single annotation associated with an element. |
| 731 * |
| 732 * Clients may not extend, implement or mix-in this class. |
| 733 */ |
| 734 abstract class ElementAnnotation { |
| 735 /** |
| 736 * An empty list of annotations. |
| 737 */ |
| 738 static const List<ElementAnnotation> EMPTY_LIST = const <ElementAnnotation>[]; |
| 739 |
| 740 /** |
| 741 * Return a representation of the value of this annotation. |
| 742 * |
| 743 * Return `null` if the value of this annotation could not be computed because |
| 744 * of errors. |
| 745 */ |
| 746 DartObject get constantValue; |
| 747 |
| 748 /** |
| 749 * Return the element representing the field, variable, or const constructor |
| 750 * being used as an annotation. |
| 751 */ |
| 752 Element get element; |
| 753 |
| 754 /** |
| 755 * Return `true` if this annotation marks the associated element as being |
| 756 * deprecated. |
| 757 */ |
| 758 bool get isDeprecated; |
| 759 |
| 760 /** |
| 761 * Return `true` if this annotation marks the associated method as being |
| 762 * expected to override an inherited method. |
| 763 */ |
| 764 bool get isOverride; |
| 765 |
| 766 /** |
| 767 * Return `true` if this annotation marks the associated class as implementing |
| 768 * a proxy object. |
| 769 */ |
| 770 bool get isProxy; |
| 771 } |
| 772 |
| 773 /** |
| 774 * The enumeration `ElementKind` defines the various kinds of elements in the |
| 775 * element model. |
| 776 * |
| 777 * Clients may not extend, implement or mix-in this class. |
| 778 */ |
| 779 class ElementKind extends Enum<ElementKind> { |
| 780 static const ElementKind CLASS = const ElementKind('CLASS', 0, "class"); |
| 781 |
| 782 static const ElementKind COMPILATION_UNIT = |
| 783 const ElementKind('COMPILATION_UNIT', 1, "compilation unit"); |
| 784 |
| 785 static const ElementKind CONSTRUCTOR = |
| 786 const ElementKind('CONSTRUCTOR', 2, "constructor"); |
| 787 |
| 788 static const ElementKind DYNAMIC = |
| 789 const ElementKind('DYNAMIC', 3, "<dynamic>"); |
| 790 |
| 791 static const ElementKind ERROR = const ElementKind('ERROR', 4, "<error>"); |
| 792 |
| 793 static const ElementKind EXPORT = |
| 794 const ElementKind('EXPORT', 5, "export directive"); |
| 795 |
| 796 static const ElementKind FIELD = const ElementKind('FIELD', 6, "field"); |
| 797 |
| 798 static const ElementKind FUNCTION = |
| 799 const ElementKind('FUNCTION', 7, "function"); |
| 800 |
| 801 static const ElementKind GETTER = const ElementKind('GETTER', 8, "getter"); |
| 802 |
| 803 static const ElementKind IMPORT = |
| 804 const ElementKind('IMPORT', 9, "import directive"); |
| 805 |
| 806 static const ElementKind LABEL = const ElementKind('LABEL', 10, "label"); |
| 807 |
| 808 static const ElementKind LIBRARY = |
| 809 const ElementKind('LIBRARY', 11, "library"); |
| 810 |
| 811 static const ElementKind LOCAL_VARIABLE = |
| 812 const ElementKind('LOCAL_VARIABLE', 12, "local variable"); |
| 813 |
| 814 static const ElementKind METHOD = const ElementKind('METHOD', 13, "method"); |
| 815 |
| 816 static const ElementKind NAME = const ElementKind('NAME', 14, "<name>"); |
| 817 |
| 818 static const ElementKind PARAMETER = |
| 819 const ElementKind('PARAMETER', 15, "parameter"); |
| 820 |
| 821 static const ElementKind PREFIX = |
| 822 const ElementKind('PREFIX', 16, "import prefix"); |
| 823 |
| 824 static const ElementKind SETTER = const ElementKind('SETTER', 17, "setter"); |
| 825 |
| 826 static const ElementKind TOP_LEVEL_VARIABLE = |
| 827 const ElementKind('TOP_LEVEL_VARIABLE', 18, "top level variable"); |
| 828 |
| 829 static const ElementKind FUNCTION_TYPE_ALIAS = |
| 830 const ElementKind('FUNCTION_TYPE_ALIAS', 19, "function type alias"); |
| 831 |
| 832 static const ElementKind TYPE_PARAMETER = |
| 833 const ElementKind('TYPE_PARAMETER', 20, "type parameter"); |
| 834 |
| 835 static const ElementKind UNIVERSE = |
| 836 const ElementKind('UNIVERSE', 21, "<universe>"); |
| 837 |
| 838 static const List<ElementKind> values = const [ |
| 839 CLASS, |
| 840 COMPILATION_UNIT, |
| 841 CONSTRUCTOR, |
| 842 DYNAMIC, |
| 843 ERROR, |
| 844 EXPORT, |
| 845 FIELD, |
| 846 FUNCTION, |
| 847 GETTER, |
| 848 IMPORT, |
| 849 LABEL, |
| 850 LIBRARY, |
| 851 LOCAL_VARIABLE, |
| 852 METHOD, |
| 853 NAME, |
| 854 PARAMETER, |
| 855 PREFIX, |
| 856 SETTER, |
| 857 TOP_LEVEL_VARIABLE, |
| 858 FUNCTION_TYPE_ALIAS, |
| 859 TYPE_PARAMETER, |
| 860 UNIVERSE |
| 861 ]; |
| 862 |
| 863 /** |
| 864 * The name displayed in the UI for this kind of element. |
| 865 */ |
| 866 final String displayName; |
| 867 |
| 868 /** |
| 869 * Initialize a newly created element kind to have the given [displayName]. |
| 870 */ |
| 871 const ElementKind(String name, int ordinal, this.displayName) |
| 872 : super(name, ordinal); |
| 873 |
| 874 /** |
| 875 * Return the kind of the given [element], or [ERROR] if the element is |
| 876 * `null`. This is a utility method that can reduce the need for null checks |
| 877 * in other places. |
| 878 */ |
| 879 static ElementKind of(Element element) { |
| 880 if (element == null) { |
| 881 return ERROR; |
| 882 } |
| 883 return element.kind; |
| 884 } |
| 885 } |
| 886 |
| 887 /** |
| 888 * The location of an element within the element model. |
| 889 * |
| 890 * Clients may not extend, implement or mix-in this class. |
| 891 */ |
| 892 abstract class ElementLocation { |
| 893 /** |
| 894 * Return the path to the element whose location is represented by this |
| 895 * object. Clients must not modify the returned array. |
| 896 */ |
| 897 List<String> get components; |
| 898 |
| 899 /** |
| 900 * Return an encoded representation of this location that can be used to |
| 901 * create a location that is equal to this location. |
| 902 */ |
| 903 String get encoding; |
| 904 } |
| 905 |
| 906 /** |
| 907 * An object that can be used to visit an element structure. |
| 908 * |
| 909 * Clients may implement this class. |
| 910 */ |
| 911 abstract class ElementVisitor<R> { |
| 912 R visitClassElement(ClassElement element); |
| 913 |
| 914 R visitCompilationUnitElement(CompilationUnitElement element); |
| 915 |
| 916 R visitConstructorElement(ConstructorElement element); |
| 917 |
| 918 R visitExportElement(ExportElement element); |
| 919 |
| 920 R visitFieldElement(FieldElement element); |
| 921 |
| 922 R visitFieldFormalParameterElement(FieldFormalParameterElement element); |
| 923 |
| 924 R visitFunctionElement(FunctionElement element); |
| 925 |
| 926 R visitFunctionTypeAliasElement(FunctionTypeAliasElement element); |
| 927 |
| 928 R visitImportElement(ImportElement element); |
| 929 |
| 930 R visitLabelElement(LabelElement element); |
| 931 |
| 932 R visitLibraryElement(LibraryElement element); |
| 933 |
| 934 R visitLocalVariableElement(LocalVariableElement element); |
| 935 |
| 936 R visitMethodElement(MethodElement element); |
| 937 |
| 938 R visitMultiplyDefinedElement(MultiplyDefinedElement element); |
| 939 |
| 940 R visitParameterElement(ParameterElement element); |
| 941 |
| 942 R visitPrefixElement(PrefixElement element); |
| 943 |
| 944 R visitPropertyAccessorElement(PropertyAccessorElement element); |
| 945 |
| 946 R visitTopLevelVariableElement(TopLevelVariableElement element); |
| 947 |
| 948 R visitTypeParameterElement(TypeParameterElement element); |
| 949 } |
| 950 |
| 951 /** |
| 952 * An element representing an executable object, including functions, methods, |
| 953 * constructors, getters, and setters. |
| 954 * |
| 955 * Clients may not extend, implement or mix-in this class. |
| 956 */ |
| 957 abstract class ExecutableElement implements FunctionTypedElement { |
| 958 /** |
| 959 * An empty list of executable elements. |
| 960 */ |
| 961 static const List<ExecutableElement> EMPTY_LIST = const <ExecutableElement>[]; |
| 962 |
| 963 /** |
| 964 * Return a list containing all of the functions defined within this |
| 965 * executable element. |
| 966 */ |
| 967 List<FunctionElement> get functions; |
| 968 |
| 969 /** |
| 970 * Return `true` if this executable element did not have an explicit return |
| 971 * type specified for it in the original source. Note that if there was no |
| 972 * explicit return type, and if the element model is fully populated, then |
| 973 * the [returnType] will not be `null`. |
| 974 */ |
| 975 bool get hasImplicitReturnType; |
| 976 |
| 977 /** |
| 978 * Return `true` if this executable element is abstract. Executable elements |
| 979 * are abstract if they are not external and have no body. |
| 980 */ |
| 981 bool get isAbstract; |
| 982 |
| 983 /** |
| 984 * Return `true` if this executable element has body marked as being |
| 985 * asynchronous. |
| 986 */ |
| 987 bool get isAsynchronous; |
| 988 |
| 989 /** |
| 990 * Return `true` if this executable element is external. Executable elements |
| 991 * are external if they are explicitly marked as such using the 'external' |
| 992 * keyword. |
| 993 */ |
| 994 bool get isExternal; |
| 995 |
| 996 /** |
| 997 * Return `true` if this executable element has a body marked as being a |
| 998 * generator. |
| 999 */ |
| 1000 bool get isGenerator; |
| 1001 |
| 1002 /** |
| 1003 * Return `true` if this executable element is an operator. The test may be |
| 1004 * based on the name of the executable element, in which case the result will |
| 1005 * be correct when the name is legal. |
| 1006 */ |
| 1007 bool get isOperator; |
| 1008 |
| 1009 /** |
| 1010 * Return `true` if this element is a static element. A static element is an |
| 1011 * element that is not associated with a particular instance, but rather with |
| 1012 * an entire library or class. |
| 1013 */ |
| 1014 bool get isStatic; |
| 1015 |
| 1016 /** |
| 1017 * Return `true` if this executable element has a body marked as being |
| 1018 * synchronous. |
| 1019 */ |
| 1020 bool get isSynchronous; |
| 1021 |
| 1022 /** |
| 1023 * Return a list containing all of the labels defined within this executable |
| 1024 * element. |
| 1025 */ |
| 1026 List<LabelElement> get labels; |
| 1027 |
| 1028 /** |
| 1029 * Return a list containing all of the local variables defined within this |
| 1030 * executable element. |
| 1031 */ |
| 1032 List<LocalVariableElement> get localVariables; |
| 1033 } |
| 1034 |
| 1035 /** |
| 1036 * An export directive within a library. |
| 1037 * |
| 1038 * Clients may not extend, implement or mix-in this class. |
| 1039 */ |
| 1040 abstract class ExportElement implements Element, UriReferencedElement { |
| 1041 /** |
| 1042 * An empty list of export elements. |
| 1043 */ |
| 1044 static const List<ExportElement> EMPTY_LIST = const <ExportElement>[]; |
| 1045 |
| 1046 /** |
| 1047 * Return a list containing the combinators that were specified as part of the |
| 1048 * export directive in the order in which they were specified. |
| 1049 */ |
| 1050 List<NamespaceCombinator> get combinators; |
| 1051 |
| 1052 /** |
| 1053 * Return the library that is exported from this library by this export |
| 1054 * directive. |
| 1055 */ |
| 1056 LibraryElement get exportedLibrary; |
| 1057 } |
| 1058 |
| 1059 /** |
| 1060 * A field defined within a type. |
| 1061 * |
| 1062 * Clients may not extend, implement or mix-in this class. |
| 1063 */ |
| 1064 abstract class FieldElement |
| 1065 implements ClassMemberElement, PropertyInducingElement { |
| 1066 /** |
| 1067 * An empty list of field elements. |
| 1068 */ |
| 1069 static const List<FieldElement> EMPTY_LIST = const <FieldElement>[]; |
| 1070 |
| 1071 /** |
| 1072 * Return {@code true} if this element is an enum constant. |
| 1073 */ |
| 1074 bool get isEnumConstant; |
| 1075 |
| 1076 @override |
| 1077 AstNode computeNode(); |
| 1078 } |
| 1079 |
| 1080 /** |
| 1081 * A field formal parameter defined within a constructor element. |
| 1082 * |
| 1083 * Clients may not extend, implement or mix-in this class. |
| 1084 */ |
| 1085 abstract class FieldFormalParameterElement implements ParameterElement { |
| 1086 /** |
| 1087 * Return the field element associated with this field formal parameter, or |
| 1088 * `null` if the parameter references a field that doesn't exist. |
| 1089 */ |
| 1090 FieldElement get field; |
| 1091 } |
| 1092 |
| 1093 /** |
| 1094 * A (non-method) function. This can be either a top-level function, a local |
| 1095 * function, a closure, or the initialization expression for a field or |
| 1096 * variable. |
| 1097 * |
| 1098 * Clients may not extend, implement or mix-in this class. |
| 1099 */ |
| 1100 abstract class FunctionElement implements ExecutableElement, LocalElement { |
| 1101 /** |
| 1102 * An empty list of function elements. |
| 1103 */ |
| 1104 static const List<FunctionElement> EMPTY_LIST = const <FunctionElement>[]; |
| 1105 |
| 1106 /** |
| 1107 * The name of the method that can be implemented by a class to allow its |
| 1108 * instances to be invoked as if they were a function. |
| 1109 */ |
| 1110 static final String CALL_METHOD_NAME = "call"; |
| 1111 |
| 1112 /** |
| 1113 * The name of the synthetic function defined for libraries that are deferred. |
| 1114 */ |
| 1115 static final String LOAD_LIBRARY_NAME = "loadLibrary"; |
| 1116 |
| 1117 /** |
| 1118 * The name of the function used as an entry point. |
| 1119 */ |
| 1120 static const String MAIN_FUNCTION_NAME = "main"; |
| 1121 |
| 1122 /** |
| 1123 * The name of the method that will be invoked if an attempt is made to invoke |
| 1124 * an undefined method on an object. |
| 1125 */ |
| 1126 static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod"; |
| 1127 |
| 1128 /** |
| 1129 * Return `true` if the function is an entry point, i.e. a top-level function |
| 1130 * and has the name `main`. |
| 1131 */ |
| 1132 bool get isEntryPoint; |
| 1133 |
| 1134 @override |
| 1135 FunctionDeclaration computeNode(); |
| 1136 } |
| 1137 |
| 1138 /** |
| 1139 * A function type alias (`typedef`). |
| 1140 * |
| 1141 * Clients may not extend, implement or mix-in this class. |
| 1142 */ |
| 1143 abstract class FunctionTypeAliasElement implements FunctionTypedElement { |
| 1144 /** |
| 1145 * An empty array of type alias elements. |
| 1146 */ |
| 1147 static List<FunctionTypeAliasElement> EMPTY_LIST = |
| 1148 new List<FunctionTypeAliasElement>(0); |
| 1149 |
| 1150 /** |
| 1151 * Return the compilation unit in which this type alias is defined. |
| 1152 */ |
| 1153 @override |
| 1154 CompilationUnitElement get enclosingElement; |
| 1155 |
| 1156 @override |
| 1157 FunctionTypeAlias computeNode(); |
| 1158 } |
| 1159 |
| 1160 /** |
| 1161 * An element that has a [FunctionType] as its [type]. |
| 1162 * |
| 1163 * This also provides convenient access to the parameters and return type. |
| 1164 * |
| 1165 * Clients may not extend, implement or mix-in this class. |
| 1166 */ |
| 1167 abstract class FunctionTypedElement |
| 1168 implements TypeDefiningElement, TypeParameterizedElement { |
| 1169 /** |
| 1170 * Return a list containing all of the parameters defined by this executable |
| 1171 * element. |
| 1172 */ |
| 1173 List<ParameterElement> get parameters; |
| 1174 |
| 1175 /** |
| 1176 * Return the return type defined by this element. If the element model is |
| 1177 * fully populated, then the [returnType] will not be `null`, even if no |
| 1178 * return type was explicitly specified. |
| 1179 */ |
| 1180 DartType get returnType; |
| 1181 |
| 1182 @override |
| 1183 FunctionType get type; |
| 1184 } |
| 1185 |
| 1186 /** |
| 1187 * A combinator that causes some of the names in a namespace to be hidden when |
| 1188 * being imported. |
| 1189 * |
| 1190 * Clients may not extend, implement or mix-in this class. |
| 1191 */ |
| 1192 abstract class HideElementCombinator implements NamespaceCombinator { |
| 1193 /** |
| 1194 * Return a list containing the names that are not to be made visible in the |
| 1195 * importing library even if they are defined in the imported library. |
| 1196 */ |
| 1197 List<String> get hiddenNames; |
| 1198 } |
| 1199 |
| 1200 /** |
| 1201 * A single import directive within a library. |
| 1202 * |
| 1203 * Clients may not extend, implement or mix-in this class. |
| 1204 */ |
| 1205 abstract class ImportElement implements Element, UriReferencedElement { |
| 1206 /** |
| 1207 * An empty list of import elements. |
| 1208 */ |
| 1209 static const List<ImportElement> EMPTY_LIST = const <ImportElement>[]; |
| 1210 |
| 1211 /** |
| 1212 * Return a list containing the combinators that were specified as part of the |
| 1213 * import directive in the order in which they were specified. |
| 1214 */ |
| 1215 List<NamespaceCombinator> get combinators; |
| 1216 |
| 1217 /** |
| 1218 * Return the library that is imported into this library by this import |
| 1219 * directive. |
| 1220 */ |
| 1221 LibraryElement get importedLibrary; |
| 1222 |
| 1223 /** |
| 1224 * Return `true` if this import is for a deferred library. |
| 1225 */ |
| 1226 bool get isDeferred; |
| 1227 |
| 1228 /** |
| 1229 * Return the prefix that was specified as part of the import directive, or |
| 1230 * `null` if there was no prefix specified. |
| 1231 */ |
| 1232 PrefixElement get prefix; |
| 1233 |
| 1234 /** |
| 1235 * Return the offset of the prefix of this import in the file that contains |
| 1236 * this import directive, or `-1` if this import is synthetic, does not have a |
| 1237 * prefix, or otherwise does not have an offset. |
| 1238 */ |
| 1239 int get prefixOffset; |
| 1240 } |
| 1241 |
| 1242 /** |
| 1243 * A label associated with a statement. |
| 1244 * |
| 1245 * Clients may not extend, implement or mix-in this class. |
| 1246 */ |
| 1247 abstract class LabelElement implements Element { |
| 1248 /** |
| 1249 * An empty list of label elements. |
| 1250 */ |
| 1251 static const List<LabelElement> EMPTY_LIST = const <LabelElement>[]; |
| 1252 |
| 1253 @override |
| 1254 ExecutableElement get enclosingElement; |
| 1255 } |
| 1256 |
| 1257 /** |
| 1258 * A library. |
| 1259 * |
| 1260 * Clients may not extend, implement or mix-in this class. |
| 1261 */ |
| 1262 abstract class LibraryElement implements Element { |
| 1263 /** |
| 1264 * An empty list of library elements. |
| 1265 */ |
| 1266 static const List<LibraryElement> EMPTY_LIST = const <LibraryElement>[]; |
| 1267 |
| 1268 /** |
| 1269 * Return the compilation unit that defines this library. |
| 1270 */ |
| 1271 CompilationUnitElement get definingCompilationUnit; |
| 1272 |
| 1273 /** |
| 1274 * Return the entry point for this library, or `null` if this library does not |
| 1275 * have an entry point. The entry point is defined to be a zero argument |
| 1276 * top-level function whose name is `main`. |
| 1277 */ |
| 1278 FunctionElement get entryPoint; |
| 1279 |
| 1280 /** |
| 1281 * Return a list containing all of the libraries that are exported from this |
| 1282 * library. |
| 1283 */ |
| 1284 List<LibraryElement> get exportedLibraries; |
| 1285 |
| 1286 /** |
| 1287 * The export [Namespace] of this library, `null` if it has not been |
| 1288 * computed yet. |
| 1289 */ |
| 1290 Namespace get exportNamespace; |
| 1291 |
| 1292 /** |
| 1293 * Return a list containing all of the exports defined in this library. |
| 1294 */ |
| 1295 List<ExportElement> get exports; |
| 1296 |
| 1297 /** |
| 1298 * Return `true` if the defining compilation unit of this library contains at |
| 1299 * least one import directive whose URI uses the "dart-ext" scheme. |
| 1300 */ |
| 1301 bool get hasExtUri; |
| 1302 |
| 1303 /** |
| 1304 * Return `true` if this library defines a top-level function named |
| 1305 * `loadLibrary`. |
| 1306 */ |
| 1307 bool get hasLoadLibraryFunction; |
| 1308 |
| 1309 /** |
| 1310 * Return a list containing all of the libraries that are imported into this |
| 1311 * library. This includes all of the libraries that are imported using a |
| 1312 * prefix (also available through the prefixes returned by [getPrefixes]) and |
| 1313 * those that are imported without a prefix. |
| 1314 */ |
| 1315 List<LibraryElement> get importedLibraries; |
| 1316 |
| 1317 /** |
| 1318 * Return a list containing all of the imports defined in this library. |
| 1319 */ |
| 1320 List<ImportElement> get imports; |
| 1321 |
| 1322 /** |
| 1323 * Return `true` if this library is an application that can be run in the |
| 1324 * browser. |
| 1325 */ |
| 1326 bool get isBrowserApplication; |
| 1327 |
| 1328 /** |
| 1329 * Return `true` if this library is the dart:core library. |
| 1330 */ |
| 1331 bool get isDartCore; |
| 1332 |
| 1333 /** |
| 1334 * Return `true` if this library is part of the SDK. |
| 1335 */ |
| 1336 bool get isInSdk; |
| 1337 |
| 1338 /** |
| 1339 * Return the element representing the synthetic function `loadLibrary` that |
| 1340 * is implicitly defined for this library if the library is imported using a |
| 1341 * deferred import. |
| 1342 */ |
| 1343 FunctionElement get loadLibraryFunction; |
| 1344 |
| 1345 /** |
| 1346 * Return a list containing all of the compilation units that are included in |
| 1347 * this library using a `part` directive. This does not include the defining |
| 1348 * compilation unit that contains the `part` directives. |
| 1349 */ |
| 1350 List<CompilationUnitElement> get parts; |
| 1351 |
| 1352 /** |
| 1353 * Return a list containing elements for each of the prefixes used to `import` |
| 1354 * libraries into this library. Each prefix can be used in more than one |
| 1355 * `import` directive. |
| 1356 */ |
| 1357 List<PrefixElement> get prefixes; |
| 1358 |
| 1359 /** |
| 1360 * The public [Namespace] of this library, `null` if it has not been |
| 1361 * computed yet. |
| 1362 */ |
| 1363 Namespace get publicNamespace; |
| 1364 |
| 1365 /** |
| 1366 * Return a list containing all of the compilation units this library consists |
| 1367 * of. This includes the defining compilation unit and units included using |
| 1368 * the `part` directive. |
| 1369 */ |
| 1370 List<CompilationUnitElement> get units; |
| 1371 |
| 1372 /** |
| 1373 * Return a list containing all directly and indirectly imported libraries. |
| 1374 */ |
| 1375 List<LibraryElement> get visibleLibraries; |
| 1376 |
| 1377 /** |
| 1378 * Return a list containing all of the imports that share the given [prefix], |
| 1379 * or an empty array if there are no such imports. |
| 1380 */ |
| 1381 List<ImportElement> getImportsWithPrefix(PrefixElement prefix); |
| 1382 |
| 1383 /** |
| 1384 * Return the class defined in this library that has the given [name], or |
| 1385 * `null` if this library does not define a class with the given name. |
| 1386 */ |
| 1387 ClassElement getType(String className); |
| 1388 |
| 1389 /** |
| 1390 * Return `true` if this library is up to date with respect to the given |
| 1391 * [timeStamp]. If any transitively referenced Source is newer than the time |
| 1392 * stamp, this method returns false. |
| 1393 */ |
| 1394 bool isUpToDate(int timeStamp); |
| 1395 } |
| 1396 |
| 1397 /** |
| 1398 * An element that can be (but is not required to be) defined within a method |
| 1399 * or function (an [ExecutableElement]). |
| 1400 * |
| 1401 * Clients may not extend, implement or mix-in this class. |
| 1402 */ |
| 1403 abstract class LocalElement implements Element { |
| 1404 /** |
| 1405 * Return a source range that covers the approximate portion of the source in |
| 1406 * which the name of this element is visible, or `null` if there is no single |
| 1407 * range of characters within which the element name is visible. |
| 1408 * |
| 1409 * * For a local variable, this includes everything from the end of the |
| 1410 * variable's initializer to the end of the block that encloses the variable |
| 1411 * declaration. |
| 1412 * * For a parameter, this includes the body of the method or function that |
| 1413 * declares the parameter. |
| 1414 * * For a local function, this includes everything from the beginning of the |
| 1415 * function's body to the end of the block that encloses the function |
| 1416 * declaration. |
| 1417 * * For top-level functions, `null` will be returned because they are |
| 1418 * potentially visible in multiple sources. |
| 1419 */ |
| 1420 SourceRange get visibleRange; |
| 1421 } |
| 1422 |
| 1423 /** |
| 1424 * A local variable. |
| 1425 * |
| 1426 * Clients may not extend, implement or mix-in this class. |
| 1427 */ |
| 1428 abstract class LocalVariableElement implements LocalElement, VariableElement { |
| 1429 /** |
| 1430 * An empty list of field elements. |
| 1431 */ |
| 1432 static const List<LocalVariableElement> EMPTY_LIST = |
| 1433 const <LocalVariableElement>[]; |
| 1434 } |
| 1435 |
| 1436 /** |
| 1437 * An element that represents a method defined within a type. |
| 1438 * |
| 1439 * Clients may not extend, implement or mix-in this class. |
| 1440 */ |
| 1441 abstract class MethodElement implements ClassMemberElement, ExecutableElement { |
| 1442 /** |
| 1443 * An empty list of method elements. |
| 1444 */ |
| 1445 static const List<MethodElement> EMPTY_LIST = const <MethodElement>[]; |
| 1446 |
| 1447 @override |
| 1448 MethodDeclaration computeNode(); |
| 1449 } |
| 1450 |
| 1451 /** |
| 1452 * The enumeration `Modifier` defines constants for all of the modifiers defined |
| 1453 * by the Dart language and for a few additional flags that are useful. |
| 1454 * |
| 1455 * Clients may not extend, implement or mix-in this class. |
| 1456 */ |
| 1457 class Modifier extends Enum<Modifier> { |
| 1458 /** |
| 1459 * Indicates that the modifier 'abstract' was applied to the element. |
| 1460 */ |
| 1461 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0); |
| 1462 |
| 1463 /** |
| 1464 * Indicates that an executable element has a body marked as being |
| 1465 * asynchronous. |
| 1466 */ |
| 1467 static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1); |
| 1468 |
| 1469 /** |
| 1470 * Indicates that the modifier 'const' was applied to the element. |
| 1471 */ |
| 1472 static const Modifier CONST = const Modifier('CONST', 2); |
| 1473 |
| 1474 /** |
| 1475 * Indicates that the import element represents a deferred library. |
| 1476 */ |
| 1477 static const Modifier DEFERRED = const Modifier('DEFERRED', 3); |
| 1478 |
| 1479 /** |
| 1480 * Indicates that a class element was defined by an enum declaration. |
| 1481 */ |
| 1482 static const Modifier ENUM = const Modifier('ENUM', 4); |
| 1483 |
| 1484 /** |
| 1485 * Indicates that a class element was defined by an enum declaration. |
| 1486 */ |
| 1487 static const Modifier EXTERNAL = const Modifier('EXTERNAL', 5); |
| 1488 |
| 1489 /** |
| 1490 * Indicates that the modifier 'factory' was applied to the element. |
| 1491 */ |
| 1492 static const Modifier FACTORY = const Modifier('FACTORY', 6); |
| 1493 |
| 1494 /** |
| 1495 * Indicates that the modifier 'final' was applied to the element. |
| 1496 */ |
| 1497 static const Modifier FINAL = const Modifier('FINAL', 7); |
| 1498 |
| 1499 /** |
| 1500 * Indicates that an executable element has a body marked as being a |
| 1501 * generator. |
| 1502 */ |
| 1503 static const Modifier GENERATOR = const Modifier('GENERATOR', 8); |
| 1504 |
| 1505 /** |
| 1506 * Indicates that the pseudo-modifier 'get' was applied to the element. |
| 1507 */ |
| 1508 static const Modifier GETTER = const Modifier('GETTER', 9); |
| 1509 |
| 1510 /** |
| 1511 * A flag used for libraries indicating that the defining compilation unit |
| 1512 * contains at least one import directive whose URI uses the "dart-ext" |
| 1513 * scheme. |
| 1514 */ |
| 1515 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); |
| 1516 |
| 1517 /** |
| 1518 * Indicates that the associated element did not have an explicit type |
| 1519 * associated with it. If the element is an [ExecutableElement], then the |
| 1520 * type being referred to is the return type. |
| 1521 */ |
| 1522 static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11); |
| 1523 |
| 1524 /** |
| 1525 * Indicates that a class can validly be used as a mixin. |
| 1526 */ |
| 1527 static const Modifier MIXIN = const Modifier('MIXIN', 12); |
| 1528 |
| 1529 /** |
| 1530 * Indicates that a class is a mixin application. |
| 1531 */ |
| 1532 static const Modifier MIXIN_APPLICATION = |
| 1533 const Modifier('MIXIN_APPLICATION', 13); |
| 1534 |
| 1535 /** |
| 1536 * Indicates that the value of a parameter or local variable might be mutated |
| 1537 * within the context. |
| 1538 */ |
| 1539 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = |
| 1540 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 14); |
| 1541 |
| 1542 /** |
| 1543 * Indicates that the value of a parameter or local variable might be mutated |
| 1544 * within the scope. |
| 1545 */ |
| 1546 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = |
| 1547 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 15); |
| 1548 |
| 1549 /** |
| 1550 * Indicates that a class contains an explicit reference to 'super'. |
| 1551 */ |
| 1552 static const Modifier REFERENCES_SUPER = |
| 1553 const Modifier('REFERENCES_SUPER', 16); |
| 1554 |
| 1555 /** |
| 1556 * Indicates that the pseudo-modifier 'set' was applied to the element. |
| 1557 */ |
| 1558 static const Modifier SETTER = const Modifier('SETTER', 17); |
| 1559 |
| 1560 /** |
| 1561 * Indicates that the modifier 'static' was applied to the element. |
| 1562 */ |
| 1563 static const Modifier STATIC = const Modifier('STATIC', 18); |
| 1564 |
| 1565 /** |
| 1566 * Indicates that the element does not appear in the source code but was |
| 1567 * implicitly created. For example, if a class does not define any |
| 1568 * constructors, an implicit zero-argument constructor will be created and it |
| 1569 * will be marked as being synthetic. |
| 1570 */ |
| 1571 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 19); |
| 1572 |
| 1573 static const List<Modifier> values = const [ |
| 1574 ABSTRACT, |
| 1575 ASYNCHRONOUS, |
| 1576 CONST, |
| 1577 DEFERRED, |
| 1578 ENUM, |
| 1579 EXTERNAL, |
| 1580 FACTORY, |
| 1581 FINAL, |
| 1582 GENERATOR, |
| 1583 GETTER, |
| 1584 HAS_EXT_URI, |
| 1585 IMPLICIT_TYPE, |
| 1586 MIXIN, |
| 1587 MIXIN_APPLICATION, |
| 1588 POTENTIALLY_MUTATED_IN_CONTEXT, |
| 1589 POTENTIALLY_MUTATED_IN_SCOPE, |
| 1590 REFERENCES_SUPER, |
| 1591 SETTER, |
| 1592 STATIC, |
| 1593 SYNTHETIC |
| 1594 ]; |
| 1595 |
| 1596 const Modifier(String name, int ordinal) : super(name, ordinal); |
| 1597 } |
| 1598 |
| 1599 /** |
| 1600 * A pseudo-element that represents multiple elements defined within a single |
| 1601 * scope that have the same name. This situation is not allowed by the language, |
| 1602 * so objects implementing this interface always represent an error. As a |
| 1603 * result, most of the normal operations on elements do not make sense and will |
| 1604 * return useless results. |
| 1605 * |
| 1606 * Clients may not extend, implement or mix-in this class. |
| 1607 */ |
| 1608 abstract class MultiplyDefinedElement implements Element { |
| 1609 /** |
| 1610 * Return a list containing all of the elements that were defined within the |
| 1611 * scope to have the same name. |
| 1612 */ |
| 1613 List<Element> get conflictingElements; |
| 1614 |
| 1615 /** |
| 1616 * Return the type of this element as the dynamic type. |
| 1617 */ |
| 1618 DartType get type; |
| 1619 } |
| 1620 |
| 1621 /** |
| 1622 * An [ExecutableElement], with the additional information of a list of |
| 1623 * [ExecutableElement]s from which this element was composed. |
| 1624 * |
| 1625 * Clients may not extend, implement or mix-in this class. |
| 1626 */ |
| 1627 abstract class MultiplyInheritedExecutableElement implements ExecutableElement { |
| 1628 /** |
| 1629 * Return a list containing all of the executable elements defined within this |
| 1630 * executable element. |
| 1631 */ |
| 1632 List<ExecutableElement> get inheritedElements; |
| 1633 } |
| 1634 |
| 1635 /** |
| 1636 * An object that controls how namespaces are combined. |
| 1637 * |
| 1638 * Clients may not extend, implement or mix-in this class. |
| 1639 */ |
| 1640 abstract class NamespaceCombinator { |
| 1641 /** |
| 1642 * An empty list of namespace combinators. |
| 1643 */ |
| 1644 static const List<NamespaceCombinator> EMPTY_LIST = |
| 1645 const <NamespaceCombinator>[]; |
| 1646 } |
| 1647 |
| 1648 /** |
| 1649 * A parameter defined within an executable element. |
| 1650 * |
| 1651 * Clients may not extend, implement or mix-in this class. |
| 1652 */ |
| 1653 abstract class ParameterElement |
| 1654 implements LocalElement, VariableElement, ConstantEvaluationTarget { |
| 1655 /** |
| 1656 * An empty list of parameter elements. |
| 1657 */ |
| 1658 static const List<ParameterElement> EMPTY_LIST = const <ParameterElement>[]; |
| 1659 |
| 1660 /** |
| 1661 * Return the Dart code of the default value, or `null` if no default value. |
| 1662 */ |
| 1663 String get defaultValueCode; |
| 1664 |
| 1665 /** |
| 1666 * Return `true` if this parameter is an initializing formal parameter. |
| 1667 */ |
| 1668 bool get isInitializingFormal; |
| 1669 |
| 1670 /** |
| 1671 * Return the kind of this parameter. |
| 1672 */ |
| 1673 ParameterKind get parameterKind; |
| 1674 |
| 1675 /** |
| 1676 * Return a list containing all of the parameters defined by this parameter. |
| 1677 * A parameter will only define other parameters if it is a function typed |
| 1678 * parameter. |
| 1679 */ |
| 1680 List<ParameterElement> get parameters; |
| 1681 |
| 1682 /** |
| 1683 * Return a list containing all of the type parameters defined by this |
| 1684 * parameter. A parameter will only define other parameters if it is a |
| 1685 * function typed parameter. |
| 1686 */ |
| 1687 List<TypeParameterElement> get typeParameters; |
| 1688 |
| 1689 /** |
| 1690 * Append the type, name and possibly the default value of this parameter to |
| 1691 * the given [buffer]. |
| 1692 */ |
| 1693 void appendToWithoutDelimiters(StringBuffer buffer); |
| 1694 |
| 1695 @override |
| 1696 FormalParameter computeNode(); |
| 1697 } |
| 1698 |
| 1699 /** |
| 1700 * A prefix used to import one or more libraries into another library. |
| 1701 * |
| 1702 * Clients may not extend, implement or mix-in this class. |
| 1703 */ |
| 1704 abstract class PrefixElement implements Element { |
| 1705 /** |
| 1706 * An empty list of prefix elements. |
| 1707 */ |
| 1708 static const List<PrefixElement> EMPTY_LIST = const <PrefixElement>[]; |
| 1709 |
| 1710 @override |
| 1711 LibraryElement get enclosingElement; |
| 1712 |
| 1713 /** |
| 1714 * Return a list containing all of the libraries that are imported using this |
| 1715 * prefix. |
| 1716 */ |
| 1717 List<LibraryElement> get importedLibraries; |
| 1718 } |
| 1719 |
| 1720 /** |
| 1721 * A getter or a setter. Note that explicitly defined property accessors |
| 1722 * implicitly define a synthetic field. Symmetrically, synthetic accessors are |
| 1723 * implicitly created for explicitly defined fields. The following rules apply: |
| 1724 * |
| 1725 * * Every explicit field is represented by a non-synthetic [FieldElement]. |
| 1726 * * Every explicit field induces a getter and possibly a setter, both of which |
| 1727 * are represented by synthetic [PropertyAccessorElement]s. |
| 1728 * * Every explicit getter or setter is represented by a non-synthetic |
| 1729 * [PropertyAccessorElement]. |
| 1730 * * Every explicit getter or setter (or pair thereof if they have the same |
| 1731 * name) induces a field that is represented by a synthetic [FieldElement]. |
| 1732 * |
| 1733 * Clients may not extend, implement or mix-in this class. |
| 1734 */ |
| 1735 abstract class PropertyAccessorElement implements ExecutableElement { |
| 1736 /** |
| 1737 * An empty list of property accessor elements. |
| 1738 */ |
| 1739 static const List<PropertyAccessorElement> EMPTY_LIST = |
| 1740 const <PropertyAccessorElement>[]; |
| 1741 |
| 1742 /** |
| 1743 * Return the accessor representing the getter that corresponds to (has the |
| 1744 * same name as) this setter, or `null` if this accessor is not a setter or if |
| 1745 * there is no corresponding getter. |
| 1746 */ |
| 1747 PropertyAccessorElement get correspondingGetter; |
| 1748 |
| 1749 /** |
| 1750 * Return the accessor representing the setter that corresponds to (has the |
| 1751 * same name as) this getter, or `null` if this accessor is not a getter or if |
| 1752 * there is no corresponding setter. |
| 1753 */ |
| 1754 PropertyAccessorElement get correspondingSetter; |
| 1755 |
| 1756 /** |
| 1757 * Return `true` if this accessor represents a getter. |
| 1758 */ |
| 1759 bool get isGetter; |
| 1760 |
| 1761 /** |
| 1762 * Return `true` if this accessor represents a setter. |
| 1763 */ |
| 1764 bool get isSetter; |
| 1765 |
| 1766 /** |
| 1767 * Return the field or top-level variable associated with this accessor. If |
| 1768 * this accessor was explicitly defined (is not synthetic) then the variable |
| 1769 * associated with it will be synthetic. |
| 1770 */ |
| 1771 PropertyInducingElement get variable; |
| 1772 } |
| 1773 |
| 1774 /** |
| 1775 * A variable that has an associated getter and possibly a setter. Note that |
| 1776 * explicitly defined variables implicitly define a synthetic getter and that |
| 1777 * non-`final` explicitly defined variables implicitly define a synthetic |
| 1778 * setter. Symmetrically, synthetic fields are implicitly created for explicitly |
| 1779 * defined getters and setters. The following rules apply: |
| 1780 * |
| 1781 * * Every explicit variable is represented by a non-synthetic |
| 1782 * [PropertyInducingElement]. |
| 1783 * * Every explicit variable induces a getter and possibly a setter, both of |
| 1784 * which are represented by synthetic [PropertyAccessorElement]s. |
| 1785 * * Every explicit getter or setter is represented by a non-synthetic |
| 1786 * [PropertyAccessorElement]. |
| 1787 * * Every explicit getter or setter (or pair thereof if they have the same |
| 1788 * name) induces a variable that is represented by a synthetic |
| 1789 * [PropertyInducingElement]. |
| 1790 * |
| 1791 * Clients may not extend, implement or mix-in this class. |
| 1792 */ |
| 1793 abstract class PropertyInducingElement implements VariableElement { |
| 1794 /** |
| 1795 * An empty list of elements. |
| 1796 */ |
| 1797 static const List<PropertyInducingElement> EMPTY_LIST = |
| 1798 const <PropertyInducingElement>[]; |
| 1799 |
| 1800 /** |
| 1801 * Return the getter associated with this variable. If this variable was |
| 1802 * explicitly defined (is not synthetic) then the getter associated with it |
| 1803 * will be synthetic. |
| 1804 */ |
| 1805 PropertyAccessorElement get getter; |
| 1806 |
| 1807 /** |
| 1808 * Return the propagated type of this variable, or `null` if type propagation |
| 1809 * has not been performed, for example because the variable is not final. |
| 1810 */ |
| 1811 DartType get propagatedType; |
| 1812 |
| 1813 /** |
| 1814 * Return the setter associated with this variable, or `null` if the variable |
| 1815 * is effectively `final` and therefore does not have a setter associated with |
| 1816 * it. (This can happen either because the variable is explicitly defined as |
| 1817 * being `final` or because the variable is induced by an explicit getter that |
| 1818 * does not have a corresponding setter.) If this variable was explicitly |
| 1819 * defined (is not synthetic) then the setter associated with it will be |
| 1820 * synthetic. |
| 1821 */ |
| 1822 PropertyAccessorElement get setter; |
| 1823 } |
| 1824 |
| 1825 /** |
| 1826 * A combinator that cause some of the names in a namespace to be visible (and |
| 1827 * the rest hidden) when being imported. |
| 1828 * |
| 1829 * Clients may not extend, implement or mix-in this class. |
| 1830 */ |
| 1831 abstract class ShowElementCombinator implements NamespaceCombinator { |
| 1832 /** |
| 1833 * Return the offset of the character immediately following the last character |
| 1834 * of this node. |
| 1835 */ |
| 1836 int get end; |
| 1837 |
| 1838 /** |
| 1839 * Return the offset of the 'show' keyword of this element. |
| 1840 */ |
| 1841 int get offset; |
| 1842 |
| 1843 /** |
| 1844 * Return a list containing the names that are to be made visible in the |
| 1845 * importing library if they are defined in the imported library. |
| 1846 */ |
| 1847 List<String> get shownNames; |
| 1848 } |
| 1849 |
| 1850 /** |
| 1851 * A top-level variable. |
| 1852 * |
| 1853 * Clients may not extend, implement or mix-in this class. |
| 1854 */ |
| 1855 abstract class TopLevelVariableElement implements PropertyInducingElement { |
| 1856 /** |
| 1857 * An empty list of top-level variable elements. |
| 1858 */ |
| 1859 static const List<TopLevelVariableElement> EMPTY_LIST = |
| 1860 const <TopLevelVariableElement>[]; |
| 1861 |
| 1862 @override |
| 1863 VariableDeclaration computeNode(); |
| 1864 } |
| 1865 |
| 1866 /** |
| 1867 * An element that defines a type. |
| 1868 * |
| 1869 * Clients may not extend, implement or mix-in this class. |
| 1870 */ |
| 1871 abstract class TypeDefiningElement implements Element { |
| 1872 /** |
| 1873 * Return the type defined by this element. |
| 1874 */ |
| 1875 DartType get type; |
| 1876 } |
| 1877 |
| 1878 /** |
| 1879 * A type parameter. |
| 1880 * |
| 1881 * Clients may not extend, implement or mix-in this class. |
| 1882 */ |
| 1883 abstract class TypeParameterElement implements TypeDefiningElement { |
| 1884 /** |
| 1885 * An empty list of type parameter elements. |
| 1886 */ |
| 1887 static const List<TypeParameterElement> EMPTY_LIST = |
| 1888 const <TypeParameterElement>[]; |
| 1889 |
| 1890 /** |
| 1891 * Return the type representing the bound associated with this parameter, or |
| 1892 * `null` if this parameter does not have an explicit bound. |
| 1893 */ |
| 1894 DartType get bound; |
| 1895 |
| 1896 @override |
| 1897 TypeParameterType get type; |
| 1898 } |
| 1899 |
| 1900 /** |
| 1901 * An element that has type parameters, such as a class or a typedef. This also |
| 1902 * includes functions and methods if support for generic methods is enabled. |
| 1903 * |
| 1904 * Clients may not extend, implement or mix-in this class. |
| 1905 */ |
| 1906 abstract class TypeParameterizedElement implements Element { |
| 1907 /** |
| 1908 * Return a list containing all of the type parameters declared by this |
| 1909 * element directly. This does not include type parameters that are declared |
| 1910 * by any enclosing elements. |
| 1911 */ |
| 1912 List<TypeParameterElement> get typeParameters; |
| 1913 } |
| 1914 |
| 1915 /** |
| 1916 * A pseudo-elements that represents names that are undefined. This situation is |
| 1917 * not allowed by the language, so objects implementing this interface always |
| 1918 * represent an error. As a result, most of the normal operations on elements do |
| 1919 * not make sense and will return useless results. |
| 1920 * |
| 1921 * Clients may not extend, implement or mix-in this class. |
| 1922 */ |
| 1923 abstract class UndefinedElement implements Element {} |
| 1924 |
| 1925 /** |
| 1926 * An element included into a library using some URI. |
| 1927 * |
| 1928 * Clients may not extend, implement or mix-in this class. |
| 1929 */ |
| 1930 abstract class UriReferencedElement implements Element { |
| 1931 /** |
| 1932 * Return the URI that is used to include this element into the enclosing |
| 1933 * library, or `null` if this is the defining compilation unit of a library. |
| 1934 */ |
| 1935 String get uri; |
| 1936 |
| 1937 /** |
| 1938 * Return the offset of the character immediately following the last character |
| 1939 * of this node's URI, or `-1` for synthetic import. |
| 1940 */ |
| 1941 int get uriEnd; |
| 1942 |
| 1943 /** |
| 1944 * Return the offset of the URI in the file, or `-1` if this element is |
| 1945 * synthetic. |
| 1946 */ |
| 1947 int get uriOffset; |
| 1948 } |
| 1949 |
| 1950 /** |
| 1951 * A variable. There are more specific subclasses for more specific kinds of |
| 1952 * variables. |
| 1953 * |
| 1954 * Clients may not extend, implement or mix-in this class. |
| 1955 */ |
| 1956 abstract class VariableElement implements Element, ConstantEvaluationTarget { |
| 1957 /** |
| 1958 * An empty list of variable elements. |
| 1959 */ |
| 1960 static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; |
| 1961 |
| 1962 /** |
| 1963 * Return a representation of the value of this variable. |
| 1964 * |
| 1965 * Return `null` if either this variable was not declared with the 'const' |
| 1966 * modifier or if the value of this variable could not be computed because of |
| 1967 * errors. |
| 1968 */ |
| 1969 DartObject get constantValue; |
| 1970 |
| 1971 /** |
| 1972 * Return `true` if this variable element did not have an explicit type |
| 1973 * specified for it. |
| 1974 */ |
| 1975 bool get hasImplicitType; |
| 1976 |
| 1977 /** |
| 1978 * Return a synthetic function representing this variable's initializer, or |
| 1979 * `null` if this variable does not have an initializer. The function will |
| 1980 * have no parameters. The return type of the function will be the |
| 1981 * compile-time type of the initialization expression. |
| 1982 */ |
| 1983 FunctionElement get initializer; |
| 1984 |
| 1985 /** |
| 1986 * Return `true` if this variable was declared with the 'const' modifier. |
| 1987 */ |
| 1988 bool get isConst; |
| 1989 |
| 1990 /** |
| 1991 * Return `true` if this variable was declared with the 'final' modifier. |
| 1992 * Variables that are declared with the 'const' modifier will return `false` |
| 1993 * even though they are implicitly final. |
| 1994 */ |
| 1995 bool get isFinal; |
| 1996 |
| 1997 /** |
| 1998 * Return `true` if this variable is potentially mutated somewhere in a |
| 1999 * closure. This information is only available for local variables (including |
| 2000 * parameters) and only after the compilation unit containing the variable has |
| 2001 * been resolved. |
| 2002 */ |
| 2003 bool get isPotentiallyMutatedInClosure; |
| 2004 |
| 2005 /** |
| 2006 * Return `true` if this variable is potentially mutated somewhere in its |
| 2007 * scope. This information is only available for local variables (including |
| 2008 * parameters) and only after the compilation unit containing the variable has |
| 2009 * been resolved. |
| 2010 */ |
| 2011 bool get isPotentiallyMutatedInScope; |
| 2012 |
| 2013 /** |
| 2014 * Return `true` if this element is a static variable, as per section 8 of the |
| 2015 * Dart Language Specification: |
| 2016 * |
| 2017 * > A static variable is a variable that is not associated with a particular |
| 2018 * > instance, but rather with an entire library or class. Static variables |
| 2019 * > include library variables and class variables. Class variables are |
| 2020 * > variables whose declaration is immediately nested inside a class |
| 2021 * > declaration and includes the modifier static. A library variable is |
| 2022 * > implicitly static. |
| 2023 */ |
| 2024 bool get isStatic; |
| 2025 |
| 2026 /** |
| 2027 * Return the declared type of this variable, or `null` if the variable did |
| 2028 * not have a declared type (such as if it was declared using the keyword |
| 2029 * 'var'). |
| 2030 */ |
| 2031 DartType get type; |
| 2032 } |
OLD | NEW |