Index: pkg/analyzer/lib/src/generated/element.dart |
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart |
index 360ca234bb5de67140148d7f4b7691b77f6c51da..52696341c49a199abe31da980e2abaffad07ac28 100644 |
--- a/pkg/analyzer/lib/src/generated/element.dart |
+++ b/pkg/analyzer/lib/src/generated/element.dart |
@@ -7,6 +7,9 @@ library analyzer.src.generated.element; |
import 'dart:collection'; |
import 'dart:math' show min; |
+import 'package:analyzer/dart/element/element.dart'; |
+import 'package:analyzer/dart/element/type.dart'; |
+import 'package:analyzer/dart/element/visitor.dart'; |
import 'package:analyzer/src/generated/ast.dart'; |
import 'package:analyzer/src/generated/constant.dart' |
show DartObject, EvaluationResultImpl; |
@@ -21,8 +24,10 @@ import 'package:analyzer/src/generated/source.dart'; |
import 'package:analyzer/src/generated/utilities_collection.dart'; |
import 'package:analyzer/src/generated/utilities_dart.dart'; |
import 'package:analyzer/src/generated/utilities_general.dart'; |
-import 'package:analyzer/src/task/dart.dart'; |
-import 'package:analyzer/task/model.dart' show AnalysisTarget; |
+ |
+export 'package:analyzer/dart/element/element.dart'; |
+export 'package:analyzer/dart/element/type.dart'; |
+export 'package:analyzer/dart/element/visitor.dart'; |
/** |
* For AST nodes that could be in both the getter and setter contexts |
@@ -125,353 +130,6 @@ class CircularTypeImpl extends DynamicTypeImpl { |
} |
/** |
- * An element that represents a class. |
- */ |
-abstract class ClassElement |
- implements TypeDefiningElement, TypeParameterizedElement { |
- /** |
- * An empty list of class elements. |
- */ |
- static const List<ClassElement> EMPTY_LIST = const <ClassElement>[]; |
- |
- /** |
- * Return a list containing all of the accessors (getters and setters) |
- * declared in this class. |
- */ |
- List<PropertyAccessorElement> get accessors; |
- |
- /** |
- * Return a list containing all the supertypes defined for this class and its |
- * supertypes. This includes superclasses, mixins and interfaces. |
- */ |
- List<InterfaceType> get allSupertypes; |
- |
- /** |
- * Return a list containing all of the constructors declared in this class. |
- */ |
- List<ConstructorElement> get constructors; |
- |
- /** |
- * Return a list containing all of the fields declared in this class. |
- */ |
- List<FieldElement> get fields; |
- |
- /** |
- * Return `true` if this class or its superclass declares a non-final instance |
- * field. |
- */ |
- bool get hasNonFinalField; |
- |
- /** |
- * Return `true` if this class has reference to super (so, for example, cannot |
- * be used as a mixin). |
- */ |
- bool get hasReferenceToSuper; |
- |
- /** |
- * Return `true` if this class declares a static member. |
- */ |
- bool get hasStaticMember; |
- |
- /** |
- * Return a list containing all of the interfaces that are implemented by this |
- * class. |
- * |
- * <b>Note:</b> Because the element model represents the state of the code, it |
- * is possible for it to be semantically invalid. In particular, it is not |
- * safe to assume that the inheritance structure of a class does not contain a |
- * cycle. Clients that traverse the inheritance structure must explicitly |
- * guard against infinite loops. |
- */ |
- List<InterfaceType> get interfaces; |
- |
- /** |
- * Return `true` if this class is abstract. A class is abstract if it has an |
- * explicit `abstract` modifier. Note, that this definition of <i>abstract</i> |
- * is different from <i>has unimplemented members</i>. |
- */ |
- bool get isAbstract; |
- |
- /** |
- * Return `true` if this class is defined by an enum declaration. |
- */ |
- bool get isEnum; |
- |
- /** |
- * Return `true` if this class is a mixin application. A class is a mixin |
- * application if it was declared using the syntax "class A = B with C;". |
- */ |
- bool get isMixinApplication; |
- |
- /** |
- * Return `true` if this class [isProxy], or if it inherits the proxy |
- * annotation from a supertype. |
- */ |
- bool get isOrInheritsProxy; |
- |
- /** |
- * Return `true` if this element has an annotation of the form '@proxy'. |
- */ |
- bool get isProxy; |
- |
- /** |
- * Return `true` if this class can validly be used as a mixin when defining |
- * another class. The behavior of this method is defined by the Dart Language |
- * Specification in section 9: |
- * <blockquote> |
- * It is a compile-time error if a declared or derived mixin refers to super. |
- * It is a compile-time error if a declared or derived mixin explicitly |
- * declares a constructor. It is a compile-time error if a mixin is derived |
- * from a class whose superclass is not Object. |
- * </blockquote> |
- */ |
- bool get isValidMixin; |
- |
- /** |
- * Return a list containing all of the methods declared in this class. |
- */ |
- List<MethodElement> get methods; |
- |
- /** |
- * Return a list containing all of the mixins that are applied to the class |
- * being extended in order to derive the superclass of this class. |
- * |
- * <b>Note:</b> Because the element model represents the state of the code, it |
- * is possible for it to be semantically invalid. In particular, it is not |
- * safe to assume that the inheritance structure of a class does not contain a |
- * cycle. Clients that traverse the inheritance structure must explicitly |
- * guard against infinite loops. |
- */ |
- List<InterfaceType> get mixins; |
- |
- /** |
- * Return the superclass of this class, or `null` if the class represents the |
- * class 'Object'. All other classes will have a non-`null` superclass. If the |
- * superclass was not explicitly declared then the implicit superclass |
- * 'Object' will be returned. |
- * |
- * <b>Note:</b> Because the element model represents the state of the code, it |
- * is possible for it to be semantically invalid. In particular, it is not |
- * safe to assume that the inheritance structure of a class does not contain a |
- * cycle. Clients that traverse the inheritance structure must explicitly |
- * guard against infinite loops. |
- */ |
- InterfaceType get supertype; |
- |
- @override |
- InterfaceType get type; |
- |
- /** |
- * Return the unnamed constructor declared in this class, or `null` if this |
- * class does not declare an unnamed constructor but does declare named |
- * constructors. The returned constructor will be synthetic if this class does |
- * not declare any constructors, in which case it will represent the default |
- * constructor for the class. |
- */ |
- ConstructorElement get unnamedConstructor; |
- |
- /** |
- * Return the resolved [ClassDeclaration] or [EnumDeclaration] node that |
- * declares this [ClassElement]. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- NamedCompilationUnitMember computeNode(); |
- |
- /** |
- * Return the field (synthetic or explicit) defined in this class that has the |
- * given [name], or `null` if this class does not define a field with the |
- * given name. |
- */ |
- FieldElement getField(String name); |
- |
- /** |
- * Return the element representing the getter with the given [name] that is |
- * declared in this class, or `null` if this class does not declare a getter |
- * with the given name. |
- */ |
- PropertyAccessorElement getGetter(String name); |
- |
- /** |
- * Return the element representing the method with the given [name] that is |
- * declared in this class, or `null` if this class does not declare a method |
- * with the given name. |
- */ |
- MethodElement getMethod(String name); |
- |
- /** |
- * Return the named constructor declared in this class with the given [name], |
- * or `null` if this class does not declare a named constructor with the given |
- * name. |
- */ |
- ConstructorElement getNamedConstructor(String name); |
- |
- /** |
- * Return the element representing the setter with the given [name] that is |
- * declared in this class, or `null` if this class does not declare a setter |
- * with the given name. |
- */ |
- PropertyAccessorElement getSetter(String name); |
- |
- /** |
- * Determine whether the given [constructor], which exists in the superclass |
- * of this class, is accessible to constructors in this class. |
- */ |
- bool isSuperConstructorAccessible(ConstructorElement constructor); |
- |
- /** |
- * Return the element representing the method that results from looking up the |
- * given [methodName] in this class with respect to the given [library], |
- * ignoring abstract methods, or `null` if the look up fails. The behavior of |
- * this method is defined by the Dart Language Specification in section |
- * 16.15.1: |
- * <blockquote> |
- * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
- * library <i>L</i> is: If <i>C</i> declares an instance method named <i>m</i> |
- * that is accessible to <i>L</i>, then that method is the result of the |
- * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
- * of the lookup is the result of looking up method <i>m</i> in <i>S</i> with |
- * respect to <i>L</i>. Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- MethodElement lookUpConcreteMethod(String methodName, LibraryElement library); |
- |
- /** |
- * Return the element representing the getter that results from looking up the |
- * given [getterName] in this class with respect to the given [library], or |
- * `null` if the look up fails. The behavior of this method is defined by the |
- * Dart Language Specification in section 16.15.2: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
- * instance getter (respectively setter) named <i>m</i> that is accessible to |
- * <i>L</i>, then that getter (respectively setter) is the result of the |
- * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
- * of the lookup is the result of looking up getter (respectively setter) |
- * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
- * lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpGetter( |
- String getterName, LibraryElement library); |
- |
- /** |
- * Return the element representing the getter that results from looking up the |
- * given [getterName] in the superclass of this class with respect to the |
- * given [library], ignoring abstract getters, or `null` if the look up fails. |
- * The behavior of this method is defined by the Dart Language Specification |
- * in section 16.15.2: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
- * instance getter (respectively setter) named <i>m</i> that is accessible to |
- * <i>L</i>, then that getter (respectively setter) is the result of the |
- * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
- * of the lookup is the result of looking up getter (respectively setter) |
- * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
- * lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpInheritedConcreteGetter( |
- String getterName, LibraryElement library); |
- |
- /** |
- * Return the element representing the method that results from looking up the |
- * given [methodName] in the superclass of this class with respect to the |
- * given [library], ignoring abstract methods, or `null` if the look up fails. |
- * The behavior of this method is defined by the Dart Language Specification |
- * in section 16.15.1: |
- * <blockquote> |
- * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
- * library <i>L</i> is: If <i>C</i> declares an instance method named |
- * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
- * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
- * result of the lookup is the result of looking up method <i>m</i> in |
- * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
- * failed. |
- * </blockquote> |
- */ |
- MethodElement lookUpInheritedConcreteMethod( |
- String methodName, LibraryElement library); |
- |
- /** |
- * Return the element representing the setter that results from looking up the |
- * given [setterName] in the superclass of this class with respect to the |
- * given [library], ignoring abstract setters, or `null` if the look up fails. |
- * The behavior of this method is defined by the Dart Language Specification |
- * in section 16.15.2: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
- * instance getter (respectively setter) named <i>m</i> that is accessible to |
- * <i>L</i>, then that getter (respectively setter) is the result of the |
- * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
- * of the lookup is the result of looking up getter (respectively setter) |
- * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
- * lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpInheritedConcreteSetter( |
- String setterName, LibraryElement library); |
- |
- /** |
- * Return the element representing the method that results from looking up the |
- * given [methodName] in the superclass of this class with respect to the |
- * given [library], or `null` if the look up fails. The behavior of this |
- * method is defined by the Dart Language Specification in section 16.15.1: |
- * <blockquote> |
- * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
- * library <i>L</i> is: If <i>C</i> declares an instance method named |
- * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
- * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
- * result of the lookup is the result of looking up method <i>m</i> in |
- * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
- * failed. |
- * </blockquote> |
- */ |
- MethodElement lookUpInheritedMethod( |
- String methodName, LibraryElement library); |
- |
- /** |
- * Return the element representing the method that results from looking up the |
- * given [methodName] in this class with respect to the given [library], or |
- * `null` if the look up fails. The behavior of this method is defined by the |
- * Dart Language Specification in section 16.15.1: |
- * <blockquote> |
- * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
- * library <i>L</i> is: If <i>C</i> declares an instance method named |
- * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
- * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
- * result of the lookup is the result of looking up method <i>m</i> in |
- * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
- * failed. |
- * </blockquote> |
- */ |
- MethodElement lookUpMethod(String methodName, LibraryElement library); |
- |
- /** |
- * Return the element representing the setter that results from looking up the |
- * given [setterName] in this class with respect to the given [library], or |
- * `null` if the look up fails. The behavior of this method is defined by the |
- * Dart Language Specification in section 16.15.2: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
- * instance getter (respectively setter) named <i>m</i> that is accessible to |
- * <i>L</i>, then that getter (respectively setter) is the result of the |
- * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
- * of the lookup is the result of looking up getter (respectively setter) |
- * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
- * lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpSetter( |
- String setterName, LibraryElement library); |
-} |
- |
-/** |
* A concrete implementation of a [ClassElement]. |
*/ |
class ClassElementImpl extends ElementImpl implements ClassElement { |
@@ -1313,111 +971,6 @@ class ClassElementImpl extends ElementImpl implements ClassElement { |
} |
/** |
- * An element that is contained within a [ClassElement]. |
- */ |
-abstract class ClassMemberElement implements Element { |
- /** |
- * Return the type in which this member is defined. |
- */ |
- @override |
- ClassElement get enclosingElement; |
- |
- /** |
- * Return `true` if this element is a static element. A static element is an |
- * element that is not associated with a particular instance, but rather with |
- * an entire library or class. |
- */ |
- bool get isStatic; |
-} |
- |
-/** |
- * An element representing a compilation unit. |
- */ |
-abstract class CompilationUnitElement implements Element, UriReferencedElement { |
- /** |
- * An empty list of compilation unit elements. |
- */ |
- static const List<CompilationUnitElement> EMPTY_LIST = |
- const <CompilationUnitElement>[]; |
- |
- /** |
- * Return a list containing all of the top-level accessors (getters and |
- * setters) contained in this compilation unit. |
- */ |
- List<PropertyAccessorElement> get accessors; |
- |
- /** |
- * Return the library in which this compilation unit is defined. |
- */ |
- @override |
- LibraryElement get enclosingElement; |
- |
- /** |
- * Return a list containing all of the enums contained in this compilation |
- * unit. |
- */ |
- List<ClassElement> get enums; |
- |
- /** |
- * Return a list containing all of the top-level functions contained in this |
- * compilation unit. |
- */ |
- List<FunctionElement> get functions; |
- |
- /** |
- * Return a list containing all of the function type aliases contained in this |
- * compilation unit. |
- */ |
- List<FunctionTypeAliasElement> get functionTypeAliases; |
- |
- /** |
- * Return `true` if this compilation unit defines a top-level function named |
- * `loadLibrary`. |
- */ |
- bool get hasLoadLibraryFunction; |
- |
- /** |
- * Return a list containing all of the top-level variables contained in this |
- * compilation unit. |
- */ |
- List<TopLevelVariableElement> get topLevelVariables; |
- |
- /** |
- * Return a list containing all of the classes contained in this compilation |
- * unit. |
- */ |
- List<ClassElement> get types; |
- |
- /** |
- * Return the resolved [CompilationUnit] node that declares this element. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- CompilationUnit computeNode(); |
- |
- /** |
- * Return the element at the given [offset], maybe `null` if no such element. |
- */ |
- Element getElementAt(int offset); |
- |
- /** |
- * Return the enum defined in this compilation unit that has the given [name], |
- * or `null` if this compilation unit does not define an enum with the given |
- * name. |
- */ |
- ClassElement getEnum(String name); |
- |
- /** |
- * Return the class defined in this compilation unit that has the given |
- * [name], or `null` if this compilation unit does not define a class with the |
- * given name. |
- */ |
- ClassElement getType(String name); |
-} |
- |
-/** |
* A concrete implementation of a [CompilationUnitElement]. |
*/ |
class CompilationUnitElementImpl extends UriReferencedElementImpl |
@@ -1776,64 +1329,6 @@ class ConstLocalVariableElementImpl extends LocalVariableElementImpl |
} |
/** |
- * An element representing a constructor or a factory method defined within a |
- * class. |
- */ |
-abstract class ConstructorElement |
- implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget { |
- /** |
- * An empty list of constructor elements. |
- */ |
- static const List<ConstructorElement> EMPTY_LIST = |
- const <ConstructorElement>[]; |
- |
- /** |
- * Return `true` if this constructor is a const constructor. |
- */ |
- bool get isConst; |
- |
- /** |
- * Return `true` if this constructor can be used as a default constructor - |
- * unnamed and has no required parameters. |
- */ |
- bool get isDefaultConstructor; |
- |
- /** |
- * Return `true` if this constructor represents a factory constructor. |
- */ |
- bool get isFactory; |
- |
- /** |
- * Return the offset of the character immediately following the last character |
- * of this constructor's name, or `null` if not named. |
- */ |
- int get nameEnd; |
- |
- /** |
- * Return the offset of the `.` before this constructor name, or `null` if |
- * not named. |
- */ |
- int get periodOffset; |
- |
- /** |
- * Return the constructor to which this constructor is redirecting, or `null` |
- * if this constructor does not redirect to another constructor or if the |
- * library containing this constructor has not yet been resolved. |
- */ |
- ConstructorElement get redirectedConstructor; |
- |
- /** |
- * Return the resolved [ConstructorDeclaration] node that declares this |
- * [ConstructorElement] . |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- ConstructorDeclaration computeNode(); |
-} |
- |
-/** |
* A concrete implementation of a [ConstructorElement]. |
*/ |
class ConstructorElementImpl extends ExecutableElementImpl |
@@ -2026,7 +1521,7 @@ class ConstructorMember extends ExecutableMember implements ConstructorElement { |
} |
buffer.write(")"); |
if (type != null) { |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
buffer.write(type.returnType); |
} |
return buffer.toString(); |
@@ -2114,111 +1609,6 @@ abstract class ConstVariableElement { |
} |
/** |
- * The type associated with elements in the element model. |
- */ |
-abstract class DartType { |
- /** |
- * An empty list of types. |
- */ |
- static const List<DartType> EMPTY_LIST = const <DartType>[]; |
- |
- /** |
- * Return the name of this type as it should appear when presented to users in |
- * contexts such as error messages. |
- */ |
- String get displayName; |
- |
- /** |
- * Return the element representing the declaration of this type, or `null` if |
- * the type has not, or cannot, be associated with an element. The former case |
- * will occur if the element model is not yet complete; the latter case will |
- * occur if this object represents an undefined type. |
- */ |
- Element get element; |
- |
- /** |
- * Return `true` if this type represents the bottom type. |
- */ |
- bool get isBottom; |
- |
- /** |
- * Return `true` if this type represents the type 'Function' defined in the |
- * dart:core library. |
- */ |
- bool get isDartCoreFunction; |
- |
- /** |
- * Return `true` if this type represents the type 'dynamic'. |
- */ |
- bool get isDynamic; |
- |
- /** |
- * Return `true` if this type represents the type 'Object'. |
- */ |
- bool get isObject; |
- |
- /** |
- * Return `true` if this type represents a typename that couldn't be resolved. |
- */ |
- bool get isUndefined; |
- |
- /** |
- * Return `true` if this type represents the type 'void'. |
- */ |
- bool get isVoid; |
- |
- /** |
- * Return the name of this type, or `null` if the type does not have a name, |
- * such as when the type represents the type of an unnamed function. |
- */ |
- String get name; |
- |
- /** |
- * Return `true` if this type is assignable to the given [type]. A type |
- * <i>T</i> may be assigned to a type <i>S</i>, written <i>T</i> ⇔ |
- * <i>S</i>, iff either <i>T</i> <: <i>S</i> or <i>S</i> <: <i>T</i>. |
- */ |
- bool isAssignableTo(DartType type); |
- |
- /** |
- * Return `true` if this type is more specific than the given [type]. |
- */ |
- bool isMoreSpecificThan(DartType type); |
- |
- /** |
- * Return `true` if this type is a subtype of the given [type]. |
- */ |
- bool isSubtypeOf(DartType type); |
- |
- /** |
- * Return `true` if this type is a supertype of the given [type]. A type |
- * <i>S</i> is a supertype of <i>T</i>, written <i>S</i> :> <i>T</i>, iff |
- * <i>T</i> is a subtype of <i>S</i>. |
- */ |
- bool isSupertypeOf(DartType type); |
- |
- /** |
- * Return the type resulting from substituting the given [argumentTypes] for |
- * the given [parameterTypes] in this type. The specification defines this |
- * operation in section 2: |
- * <blockquote> |
- * The notation <i>[x<sub>1</sub>, ..., x<sub>n</sub>/y<sub>1</sub>, ..., |
- * y<sub>n</sub>]E</i> denotes a copy of <i>E</i> in which all occurrences of |
- * <i>y<sub>i</sub>, 1 <= i <= n</i> have been replaced with |
- * <i>x<sub>i</sub></i>. |
- * </blockquote> |
- * Note that, contrary to the specification, this method will not create a |
- * copy of this type if no substitutions were required, but will return this |
- * type directly. |
- * |
- * Note too that the current implementation of this method is only guaranteed |
- * to work when the parameter types are type variables. |
- */ |
- DartType substitute2( |
- List<DartType> argumentTypes, List<DartType> parameterTypes); |
-} |
- |
-/** |
* A [FieldFormalParameterElementImpl] for parameters that have an initializer. |
*/ |
class DefaultFieldFormalParameterElementImpl |
@@ -2378,279 +1768,13 @@ class DynamicTypeImpl extends TypeImpl { |
} |
/** |
- * The base class for all of the elements in the element model. Generally |
- * speaking, the element model is a semantic model of the program that |
- * represents things that are declared with a name and hence can be referenced |
- * elsewhere in the code. |
- * |
- * There are two exceptions to the general case. First, there are elements in |
- * the element model that are created for the convenience of various kinds of |
- * analysis but that do not have any corresponding declaration within the source |
- * code. Such elements are marked as being <i>synthetic</i>. Examples of |
- * synthetic elements include |
- * * default constructors in classes that do not define any explicit |
- * constructors, |
- * * getters and setters that are induced by explicit field declarations, |
- * * fields that are induced by explicit declarations of getters and setters, |
- * and |
- * * functions representing the initialization expression for a variable. |
- * |
- * Second, there are elements in the element model that do not have a name. |
- * These correspond to unnamed functions and exist in order to more accurately |
- * represent the semantic structure of the program. |
+ * A concrete implementation of an [ElementAnnotation]. |
*/ |
-abstract class Element implements AnalysisTarget { |
+class ElementAnnotationImpl implements ElementAnnotation { |
/** |
- * An Unicode right arrow. |
+ * The name of the class used to mark an element as being deprecated. |
*/ |
- static final String RIGHT_ARROW = " \u2192 "; |
- |
- /** |
- * A comparator that can be used to sort elements by their name offset. |
- * Elements with a smaller offset will be sorted to be before elements with a |
- * larger name offset. |
- */ |
- static final Comparator<Element> SORT_BY_OFFSET = |
- (Element firstElement, Element secondElement) => |
- firstElement.nameOffset - secondElement.nameOffset; |
- |
- /** |
- * Return the analysis context in which this element is defined. |
- */ |
- AnalysisContext get context; |
- |
- /** |
- * Return the display name of this element, or `null` if this element does not |
- * have a name. |
- * |
- * In most cases the name and the display name are the same. Differences |
- * though are cases such as setters where the name of some setter `set f(x)` |
- * is `f=`, instead of `f`. |
- */ |
- String get displayName; |
- |
- /** |
- * Return the source range of the documentation comment for this element, |
- * or `null` if this element does not or cannot have a documentation. |
- */ |
- SourceRange get docRange; |
- |
- /** |
- * Return the element that either physically or logically encloses this |
- * element. This will be `null` if this element is a library because libraries |
- * are the top-level elements in the model. |
- */ |
- Element get enclosingElement; |
- |
- /** |
- * The unique integer identifier of this element. |
- */ |
- int get id; |
- |
- /** |
- * Return `true` if this element has an annotation of the form '@deprecated' |
- * or '@Deprecated('..')'. |
- */ |
- bool get isDeprecated; |
- |
- /** |
- * Return `true` if this element has an annotation of the form '@override'. |
- */ |
- bool get isOverride; |
- |
- /** |
- * Return `true` if this element is private. Private elements are visible only |
- * within the library in which they are declared. |
- */ |
- bool get isPrivate; |
- |
- /** |
- * Return `true` if this element is public. Public elements are visible within |
- * any library that imports the library in which they are declared. |
- */ |
- bool get isPublic; |
- |
- /** |
- * Return `true` if this element is synthetic. A synthetic element is an |
- * element that is not represented in the source code explicitly, but is |
- * implied by the source code, such as the default constructor for a class |
- * that does not explicitly define any constructors. |
- */ |
- bool get isSynthetic; |
- |
- /** |
- * Return the kind of element that this is. |
- */ |
- ElementKind get kind; |
- |
- /** |
- * Return the library that contains this element. This will be the element |
- * itself if it is a library element. This will be `null` if this element is |
- * an HTML file because HTML files are not contained in libraries. |
- */ |
- LibraryElement get library; |
- |
- /** |
- * Return an object representing the location of this element in the element |
- * model. The object can be used to locate this element at a later time. |
- */ |
- ElementLocation get location; |
- |
- /** |
- * Return a list containing all of the metadata associated with this element. |
- * The array will be empty if the element does not have any metadata or if the |
- * library containing this element has not yet been resolved. |
- */ |
- List<ElementAnnotation> get metadata; |
- |
- /** |
- * Return the name of this element, or `null` if this element does not have a |
- * name. |
- */ |
- String get name; |
- |
- /** |
- * Return the length of the name of this element in the file that contains the |
- * declaration of this element, or `0` if this element does not have a name. |
- */ |
- int get nameLength; |
- |
- /** |
- * Return the offset of the name of this element in the file that contains the |
- * declaration of this element, or `-1` if this element is synthetic, does not |
- * have a name, or otherwise does not have an offset. |
- */ |
- int get nameOffset; |
- |
- /** |
- * Return the source that contains this element, or `null` if this element is |
- * not contained in a source. |
- */ |
- Source get source; |
- |
- /** |
- * Return the resolved [CompilationUnit] that declares this element, or `null` |
- * if this element is synthetic. |
- * |
- * This method is expensive, because resolved AST might have been already |
- * evicted from cache, so parsing and resolving will be performed. |
- */ |
- CompilationUnit get unit; |
- |
- /** |
- * Use the given [visitor] to visit this element. Return the value returned by |
- * the visitor as a result of visiting this element. |
- */ |
- accept(ElementVisitor visitor); |
- |
- /** |
- * Return the documentation comment for this element as it appears in the |
- * original source (complete with the beginning and ending delimiters), or |
- * `null` if this element does not have a documentation comment associated |
- * with it. This can be a long-running operation if the information needed to |
- * access the comment is not cached. |
- * |
- * Throws [AnalysisException] if the documentation comment could not be |
- * determined because the analysis could not be performed |
- */ |
- String computeDocumentationComment(); |
- |
- /** |
- * Return the resolved [AstNode] node that declares this element, or `null` if |
- * this element is synthetic or isn't contained in a compilation unit, such as |
- * a [LibraryElement]. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- * |
- * <b>Note:</b> This method cannot be used in an async environment. |
- */ |
- AstNode computeNode(); |
- |
- /** |
- * Return the most immediate ancestor of this element for which the |
- * [predicate] returns `true`, or `null` if there is no such ancestor. Note |
- * that this element will never be returned. |
- */ |
- Element getAncestor(Predicate<Element> predicate); |
- |
- /** |
- * Return a display name for the given element that includes the path to the |
- * compilation unit in which the type is defined. If [shortName] is `null` |
- * then [getDisplayName] will be used as the name of this element. Otherwise |
- * the provided name will be used. |
- */ |
- // TODO(brianwilkerson) Make the parameter optional. |
- String getExtendedDisplayName(String shortName); |
- |
- /** |
- * Return `true` if this element, assuming that it is within scope, is |
- * accessible to code in the given [library]. This is defined by the Dart |
- * Language Specification in section 3.2: |
- * <blockquote> |
- * A declaration <i>m</i> is accessible to library <i>L</i> if <i>m</i> is |
- * declared in <i>L</i> or if <i>m</i> is public. |
- * </blockquote> |
- */ |
- bool isAccessibleIn(LibraryElement library); |
- |
- /** |
- * Use the given [visitor] to visit all of the children of this element. There |
- * is no guarantee of the order in which the children will be visited. |
- */ |
- void visitChildren(ElementVisitor visitor); |
-} |
- |
-/** |
- * A single annotation associated with an element. |
- */ |
-abstract class ElementAnnotation { |
- /** |
- * An empty list of annotations. |
- */ |
- static const List<ElementAnnotation> EMPTY_LIST = const <ElementAnnotation>[]; |
- |
- /** |
- * Return a representation of the value of this annotation. |
- * |
- * Return `null` if the value of this annotation could not be computed because |
- * of errors. |
- */ |
- DartObject get constantValue; |
- |
- /** |
- * Return the element representing the field, variable, or const constructor |
- * being used as an annotation. |
- */ |
- Element get element; |
- |
- /** |
- * Return `true` if this annotation marks the associated element as being |
- * deprecated. |
- */ |
- bool get isDeprecated; |
- |
- /** |
- * Return `true` if this annotation marks the associated method as being |
- * expected to override an inherited method. |
- */ |
- bool get isOverride; |
- |
- /** |
- * Return `true` if this annotation marks the associated class as implementing |
- * a proxy object. |
- */ |
- bool get isProxy; |
-} |
- |
-/** |
- * A concrete implementation of an [ElementAnnotation]. |
- */ |
-class ElementAnnotationImpl implements ElementAnnotation { |
- /** |
- * The name of the class used to mark an element as being deprecated. |
- */ |
- static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
+ static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
/** |
* The name of the top-level variable used to mark an element as being |
@@ -2749,6 +1873,11 @@ class ElementAnnotationImpl implements ElementAnnotation { |
* A base class for concrete implementations of an [Element]. |
*/ |
abstract class ElementImpl implements Element { |
+ /** |
+ * An Unicode right arrow. |
+ */ |
+ static final String RIGHT_ARROW = " \u2192 "; |
+ |
static int _NEXT_ID = 0; |
final int id = _NEXT_ID++; |
@@ -3109,146 +2238,6 @@ abstract class ElementImpl implements Element { |
} |
/** |
- * The enumeration `ElementKind` defines the various kinds of elements in the |
- * element model. |
- */ |
-class ElementKind extends Enum<ElementKind> { |
- static const ElementKind CLASS = const ElementKind('CLASS', 0, "class"); |
- |
- static const ElementKind COMPILATION_UNIT = |
- const ElementKind('COMPILATION_UNIT', 1, "compilation unit"); |
- |
- static const ElementKind CONSTRUCTOR = |
- const ElementKind('CONSTRUCTOR', 2, "constructor"); |
- |
- static const ElementKind DYNAMIC = |
- const ElementKind('DYNAMIC', 3, "<dynamic>"); |
- |
- static const ElementKind EMBEDDED_HTML_SCRIPT = |
- const ElementKind('EMBEDDED_HTML_SCRIPT', 4, "embedded html script"); |
- |
- static const ElementKind ERROR = const ElementKind('ERROR', 5, "<error>"); |
- |
- static const ElementKind EXPORT = |
- const ElementKind('EXPORT', 6, "export directive"); |
- |
- static const ElementKind EXTERNAL_HTML_SCRIPT = |
- const ElementKind('EXTERNAL_HTML_SCRIPT', 7, "external html script"); |
- |
- static const ElementKind FIELD = const ElementKind('FIELD', 8, "field"); |
- |
- static const ElementKind FUNCTION = |
- const ElementKind('FUNCTION', 9, "function"); |
- |
- static const ElementKind GETTER = const ElementKind('GETTER', 10, "getter"); |
- |
- static const ElementKind HTML = const ElementKind('HTML', 11, "html"); |
- |
- static const ElementKind IMPORT = |
- const ElementKind('IMPORT', 12, "import directive"); |
- |
- static const ElementKind LABEL = const ElementKind('LABEL', 13, "label"); |
- |
- static const ElementKind LIBRARY = |
- const ElementKind('LIBRARY', 14, "library"); |
- |
- static const ElementKind LOCAL_VARIABLE = |
- const ElementKind('LOCAL_VARIABLE', 15, "local variable"); |
- |
- static const ElementKind METHOD = const ElementKind('METHOD', 16, "method"); |
- |
- static const ElementKind NAME = const ElementKind('NAME', 17, "<name>"); |
- |
- static const ElementKind PARAMETER = |
- const ElementKind('PARAMETER', 18, "parameter"); |
- |
- static const ElementKind PREFIX = |
- const ElementKind('PREFIX', 19, "import prefix"); |
- |
- static const ElementKind SETTER = const ElementKind('SETTER', 20, "setter"); |
- |
- static const ElementKind TOP_LEVEL_VARIABLE = |
- const ElementKind('TOP_LEVEL_VARIABLE', 21, "top level variable"); |
- |
- static const ElementKind FUNCTION_TYPE_ALIAS = |
- const ElementKind('FUNCTION_TYPE_ALIAS', 22, "function type alias"); |
- |
- static const ElementKind TYPE_PARAMETER = |
- const ElementKind('TYPE_PARAMETER', 23, "type parameter"); |
- |
- static const ElementKind UNIVERSE = |
- const ElementKind('UNIVERSE', 24, "<universe>"); |
- |
- static const List<ElementKind> values = const [ |
- CLASS, |
- COMPILATION_UNIT, |
- CONSTRUCTOR, |
- DYNAMIC, |
- EMBEDDED_HTML_SCRIPT, |
- ERROR, |
- EXPORT, |
- EXTERNAL_HTML_SCRIPT, |
- FIELD, |
- FUNCTION, |
- GETTER, |
- HTML, |
- IMPORT, |
- LABEL, |
- LIBRARY, |
- LOCAL_VARIABLE, |
- METHOD, |
- NAME, |
- PARAMETER, |
- PREFIX, |
- SETTER, |
- TOP_LEVEL_VARIABLE, |
- FUNCTION_TYPE_ALIAS, |
- TYPE_PARAMETER, |
- UNIVERSE |
- ]; |
- |
- /** |
- * The name displayed in the UI for this kind of element. |
- */ |
- final String displayName; |
- |
- /** |
- * Initialize a newly created element kind to have the given [displayName]. |
- */ |
- const ElementKind(String name, int ordinal, this.displayName) |
- : super(name, ordinal); |
- |
- /** |
- * Return the kind of the given [element], or [ERROR] if the element is |
- * `null`. This is a utility method that can reduce the need for null checks |
- * in other places. |
- */ |
- static ElementKind of(Element element) { |
- if (element == null) { |
- return ERROR; |
- } |
- return element.kind; |
- } |
-} |
- |
-/** |
- * The location of an element within the element model. |
- */ |
-abstract class ElementLocation { |
- /** |
- * Return the path to the element whose location is represented by this |
- * object. Clients must not modify the returned array. |
- */ |
- List<String> get components; |
- |
- /** |
- * Return an encoded representation of this location that can be used to |
- * create a location that is equal to this location. |
- */ |
- String get encoding; |
-} |
- |
-/** |
* A concrete implementation of an [ElementLocation]. |
*/ |
class ElementLocationImpl implements ElementLocation { |
@@ -3401,131 +2390,6 @@ class ElementLocationImpl implements ElementLocation { |
} |
/** |
- * An object that can be used to visit an element structure. |
- */ |
-abstract class ElementVisitor<R> { |
- R visitClassElement(ClassElement element); |
- |
- R visitCompilationUnitElement(CompilationUnitElement element); |
- |
- R visitConstructorElement(ConstructorElement element); |
- |
- R visitExportElement(ExportElement element); |
- |
- R visitFieldElement(FieldElement element); |
- |
- R visitFieldFormalParameterElement(FieldFormalParameterElement element); |
- |
- R visitFunctionElement(FunctionElement element); |
- |
- R visitFunctionTypeAliasElement(FunctionTypeAliasElement element); |
- |
- R visitImportElement(ImportElement element); |
- |
- R visitLabelElement(LabelElement element); |
- |
- R visitLibraryElement(LibraryElement element); |
- |
- R visitLocalVariableElement(LocalVariableElement element); |
- |
- R visitMethodElement(MethodElement element); |
- |
- R visitMultiplyDefinedElement(MultiplyDefinedElement element); |
- |
- R visitParameterElement(ParameterElement element); |
- |
- R visitPrefixElement(PrefixElement element); |
- |
- R visitPropertyAccessorElement(PropertyAccessorElement element); |
- |
- R visitTopLevelVariableElement(TopLevelVariableElement element); |
- |
- R visitTypeParameterElement(TypeParameterElement element); |
-} |
- |
-/** |
- * An element representing an executable object, including functions, methods, |
- * constructors, getters, and setters. |
- */ |
-abstract class ExecutableElement implements FunctionTypedElement { |
- /** |
- * An empty list of executable elements. |
- */ |
- static const List<ExecutableElement> EMPTY_LIST = const <ExecutableElement>[]; |
- |
- /** |
- * Return a list containing all of the functions defined within this |
- * executable element. |
- */ |
- List<FunctionElement> get functions; |
- |
- /** |
- * Return `true` if this executable element did not have an explicit return |
- * type specified for it in the original source. Note that if there was no |
- * explicit return type, and if the element model is fully populated, then |
- * the [returnType] will not be `null`. |
- */ |
- bool get hasImplicitReturnType; |
- |
- /** |
- * Return `true` if this executable element is abstract. Executable elements |
- * are abstract if they are not external and have no body. |
- */ |
- bool get isAbstract; |
- |
- /** |
- * Return `true` if this executable element has body marked as being |
- * asynchronous. |
- */ |
- bool get isAsynchronous; |
- |
- /** |
- * Return `true` if this executable element is external. Executable elements |
- * are external if they are explicitly marked as such using the 'external' |
- * keyword. |
- */ |
- bool get isExternal; |
- |
- /** |
- * Return `true` if this executable element has a body marked as being a |
- * generator. |
- */ |
- bool get isGenerator; |
- |
- /** |
- * Return `true` if this executable element is an operator. The test may be |
- * based on the name of the executable element, in which case the result will |
- * be correct when the name is legal. |
- */ |
- bool get isOperator; |
- |
- /** |
- * Return `true` if this element is a static element. A static element is an |
- * element that is not associated with a particular instance, but rather with |
- * an entire library or class. |
- */ |
- bool get isStatic; |
- |
- /** |
- * Return `true` if this executable element has a body marked as being |
- * synchronous. |
- */ |
- bool get isSynchronous; |
- |
- /** |
- * Return a list containing all of the labels defined within this executable |
- * element. |
- */ |
- List<LabelElement> get labels; |
- |
- /** |
- * Return a list containing all of the local variables defined within this |
- * executable element. |
- */ |
- List<LocalVariableElement> get localVariables; |
-} |
- |
-/** |
* A base class for concrete implementations of an [ExecutableElement]. |
*/ |
abstract class ExecutableElementImpl extends ElementImpl |
@@ -3745,7 +2609,7 @@ abstract class ExecutableElementImpl extends ElementImpl |
buffer.write(")"); |
} |
if (type != null) { |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
buffer.write(type.returnType); |
} |
} |
@@ -3878,28 +2742,6 @@ abstract class ExecutableMember extends Member implements ExecutableElement { |
} |
/** |
- * An export directive within a library. |
- */ |
-abstract class ExportElement implements Element, UriReferencedElement { |
- /** |
- * An empty list of export elements. |
- */ |
- static const List<ExportElement> EMPTY_LIST = const <ExportElement>[]; |
- |
- /** |
- * Return a list containing the combinators that were specified as part of the |
- * export directive in the order in which they were specified. |
- */ |
- List<NamespaceCombinator> get combinators; |
- |
- /** |
- * Return the library that is exported from this library by this export |
- * directive. |
- */ |
- LibraryElement get exportedLibrary; |
-} |
- |
-/** |
* A concrete implementation of an [ExportElement]. |
*/ |
class ExportElementImpl extends UriReferencedElementImpl |
@@ -3937,44 +2779,18 @@ class ExportElementImpl extends UriReferencedElementImpl |
} |
/** |
- * A field defined within a type. |
+ * A concrete implementation of a [FieldElement]. |
*/ |
-abstract class FieldElement |
- implements ClassMemberElement, PropertyInducingElement { |
+class FieldElementImpl extends PropertyInducingElementImpl |
+ implements FieldElement { |
/** |
- * An empty list of field elements. |
+ * Initialize a newly created synthetic field element to have the given [name] |
+ * at the given [offset]. |
*/ |
- static const List<FieldElement> EMPTY_LIST = const <FieldElement>[]; |
+ FieldElementImpl(String name, int offset) : super(name, offset); |
/** |
- * Return {@code true} if this element is an enum constant. |
- */ |
- bool get isEnumConstant; |
- |
- /** |
- * Return the resolved [VariableDeclaration] or [EnumConstantDeclaration] |
- * node that declares this [FieldElement]. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- AstNode computeNode(); |
-} |
- |
-/** |
- * A concrete implementation of a [FieldElement]. |
- */ |
-class FieldElementImpl extends PropertyInducingElementImpl |
- implements FieldElement { |
- /** |
- * Initialize a newly created synthetic field element to have the given [name] |
- * at the given [offset]. |
- */ |
- FieldElementImpl(String name, int offset) : super(name, offset); |
- |
- /** |
- * Initialize a newly created field element to have the given [name]. |
+ * Initialize a newly created field element to have the given [name]. |
*/ |
FieldElementImpl.forNode(Identifier name) : super.forNode(name); |
@@ -4009,17 +2825,6 @@ class FieldElementImpl extends PropertyInducingElementImpl |
} |
/** |
- * A field formal parameter defined within a constructor element. |
- */ |
-abstract class FieldFormalParameterElement implements ParameterElement { |
- /** |
- * Return the field element associated with this field formal parameter, or |
- * `null` if the parameter references a field that doesn't exist. |
- */ |
- FieldElement get field; |
-} |
- |
-/** |
* A [ParameterElementImpl] that has the additional information of the |
* [FieldElement] associated with the parameter. |
*/ |
@@ -4167,55 +2972,6 @@ class FieldMember extends VariableMember implements FieldElement { |
} |
/** |
- * A (non-method) function. This can be either a top-level function, a local |
- * function, a closure, or the initialization expression for a field or |
- * variable. |
- */ |
-abstract class FunctionElement implements ExecutableElement, LocalElement { |
- /** |
- * An empty list of function elements. |
- */ |
- static const List<FunctionElement> EMPTY_LIST = const <FunctionElement>[]; |
- |
- /** |
- * The name of the method that can be implemented by a class to allow its |
- * instances to be invoked as if they were a function. |
- */ |
- static final String CALL_METHOD_NAME = "call"; |
- |
- /** |
- * The name of the synthetic function defined for libraries that are deferred. |
- */ |
- static final String LOAD_LIBRARY_NAME = "loadLibrary"; |
- |
- /** |
- * The name of the function used as an entry point. |
- */ |
- static const String MAIN_FUNCTION_NAME = "main"; |
- |
- /** |
- * The name of the method that will be invoked if an attempt is made to invoke |
- * an undefined method on an object. |
- */ |
- static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod"; |
- |
- /** |
- * Return `true` if the function is an entry point, i.e. a top-level function |
- * and has the name `main`. |
- */ |
- bool get isEntryPoint; |
- |
- /** |
- * Return the resolved function declaration node that declares this element. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- FunctionDeclaration computeNode(); |
-} |
- |
-/** |
* A concrete implementation of a [FunctionElement]. |
*/ |
class FunctionElementImpl extends ExecutableElementImpl |
@@ -4376,174 +3132,6 @@ class FunctionMember extends ExecutableMember implements FunctionElement { |
} |
/** |
- * The type of a function, method, constructor, getter, or setter. Function |
- * types come in three variations: |
- * |
- * * The types of functions that only have required parameters. These have the |
- * general form <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>. |
- * * The types of functions with optional positional parameters. These have the |
- * general form <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub> |
- * …, T<sub>n+k</sub>]) → T</i>. |
- * * The types of functions with named parameters. These have the general form |
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub> x1, …, |
- * T<sub>xk</sub> xk}) → T</i>. |
- */ |
-abstract class FunctionType implements ParameterizedType { |
- /** |
- * The type parameters of this generic function. For example `<T> T -> T`. |
- * |
- * These are distinct from the [typeParameters] list, which contains type |
- * parameters from surrounding contexts, and thus are free type variables from |
- * the perspective of this function type. |
- */ |
- List<TypeParameterElement> get boundTypeParameters; |
- |
- /** |
- * Return a map from the names of named parameters to the types of the named |
- * parameters of this type of function. The entries in the map will be |
- * iterated in the same order as the order in which the named parameters were |
- * defined. If there were no named parameters declared then the map will be |
- * empty. |
- */ |
- Map<String, DartType> get namedParameterTypes; |
- |
- /** |
- * Return a list containing the types of the normal parameters of this type of |
- * function. The parameter types are in the same order as they appear in the |
- * declaration of the function. |
- */ |
- List<DartType> get normalParameterTypes; |
- |
- /** |
- * Return a map from the names of optional (positional) parameters to the |
- * types of the optional parameters of this type of function. The entries in |
- * the map will be iterated in the same order as the order in which the |
- * optional parameters were defined. If there were no optional parameters |
- * declared then the map will be empty. |
- */ |
- List<DartType> get optionalParameterTypes; |
- |
- /** |
- * Return a list containing the parameters elements of this type of function. |
- * The parameter types are in the same order as they appear in the declaration |
- * of the function. |
- */ |
- List<ParameterElement> get parameters; |
- |
- /** |
- * Return the type of object returned by this type of function. |
- */ |
- DartType get returnType; |
- |
- /** |
- * Return the type resulting from instantiating (replacing) the given |
- * [argumentTypes] for this function's bound type parameters. |
- */ |
- FunctionType instantiate(List<DartType> argumentTypes); |
- |
- /** |
- * Return `true` if this type is a subtype of the given [type]. |
- * |
- * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i> is |
- * a subtype of the function type <i>(S<sub>1</sub>, …, S<sub>n</sub>) |
- * → S</i>, if all of the following conditions are met: |
- * |
- * * Either |
- * * <i>S</i> is void, or |
- * * <i>T ⇔ S</i>. |
- * |
- * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ |
- * S<sub>i</sub></i>. |
- * |
- * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, |
- * [T<sub>n+1</sub>, …, T<sub>n+k</sub>]) → T</i> is a subtype of |
- * the function type <i>(S<sub>1</sub>, …, S<sub>n</sub>, |
- * [S<sub>n+1</sub>, …, S<sub>n+m</sub>]) → S</i>, if all of the |
- * following conditions are met: |
- * |
- * * Either |
- * * <i>S</i> is void, or |
- * * <i>T ⇔ S</i>. |
- * |
- * * <i>k</i> >= <i>m</i> and for all <i>i</i>, 1 <= <i>i</i> <= <i>n+m</i>, |
- * <i>T<sub>i</sub> ⇔ S<sub>i</sub></i>. |
- * |
- * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, |
- * {T<sub>x1</sub> x1, …, T<sub>xk</sub> xk}) → T</i> is a subtype |
- * of the function type <i>(S<sub>1</sub>, …, S<sub>n</sub>, |
- * {S<sub>y1</sub> y1, …, S<sub>ym</sub> ym}) → S</i>, if all of |
- * the following conditions are met: |
- * * Either |
- * * <i>S</i> is void, |
- * * or <i>T ⇔ S</i>. |
- * |
- * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ |
- * S<sub>i</sub></i>. |
- * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, |
- * …, x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>. |
- * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, …, |
- * y<sub>m</sub>}</i>, <i>y<sub>i</sub> = x<sub>j</sub> => Tj ⇔ Si</i>. |
- * |
- * In addition, the following subtype rules apply: |
- * |
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>, []) → T <: (T<sub>1</sub>, |
- * …, T<sub>n</sub>) → T.</i><br> |
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, |
- * …, T<sub>n</sub>, {}) → T.</i><br> |
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {}) → T <: (T<sub>1</sub>, |
- * …, T<sub>n</sub>) → T.</i><br> |
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, |
- * …, T<sub>n</sub>, []) → T.</i> |
- * |
- * All functions implement the class `Function`. However not all function |
- * types are a subtype of `Function`. If an interface type <i>I</i> includes a |
- * method named `call()`, and the type of `call()` is the function type |
- * <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>. |
- */ |
- @override |
- bool isSubtypeOf(DartType type); |
- |
- @override |
- FunctionType substitute2( |
- List<DartType> argumentTypes, List<DartType> parameterTypes); |
- |
- /** |
- * Return the type resulting from substituting the given [argumentTypes] for |
- * this type's parameters. This is fully equivalent to |
- * `substitute(argumentTypes, getTypeArguments())`. |
- */ |
- @deprecated // use instantiate |
- FunctionType substitute3(List<DartType> argumentTypes); |
-} |
- |
-/** |
- * A function type alias (`typedef`). |
- */ |
-abstract class FunctionTypeAliasElement |
- implements TypeDefiningElement, FunctionTypedElement { |
- /** |
- * An empty array of type alias elements. |
- */ |
- static List<FunctionTypeAliasElement> EMPTY_LIST = |
- new List<FunctionTypeAliasElement>(0); |
- |
- /** |
- * Return the compilation unit in which this type alias is defined. |
- */ |
- @override |
- CompilationUnitElement get enclosingElement; |
- |
- /** |
- * Return the resolved function type alias node that declares this element. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- FunctionTypeAlias computeNode(); |
-} |
- |
-/** |
* A concrete implementation of a [FunctionTypeAliasElement]. |
*/ |
class FunctionTypeAliasElementImpl extends ElementImpl |
@@ -4647,10 +3235,10 @@ class FunctionTypeAliasElementImpl extends ElementImpl |
} |
buffer.write(")"); |
if (type != null) { |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
buffer.write(type.returnType); |
} else if (returnType != null) { |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
buffer.write(returnType); |
} |
} |
@@ -4684,31 +3272,6 @@ class FunctionTypeAliasElementImpl extends ElementImpl |
} |
/** |
- * An element that has a [FunctionType] as its [type]. |
- * |
- * This also provides convenient access to the parameters and return type. |
- */ |
-abstract class FunctionTypedElement implements TypeParameterizedElement { |
- /** |
- * Return a list containing all of the parameters defined by this executable |
- * element. |
- */ |
- List<ParameterElement> get parameters; |
- |
- /** |
- * Return the return type defined by this element. If the element model is |
- * fully populated, then the [returnType] will not be `null`, even |
- * if no return type was explicitly specified. |
- */ |
- DartType get returnType; |
- |
- /** |
- * Return the type of function defined by this element. |
- */ |
- FunctionType get type; |
-} |
- |
-/** |
* The type of a function, method, constructor, getter, or setter. |
*/ |
class FunctionTypeImpl extends TypeImpl implements FunctionType { |
@@ -4868,7 +3431,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
needsComma = true; |
} |
buffer.write(")"); |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
if (returnType == null) { |
buffer.write("null"); |
} else { |
@@ -5230,7 +3793,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
needsComma = true; |
} |
buffer.write(")"); |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
if (returnType == null) { |
buffer.write("null"); |
} else { |
@@ -5626,168 +4189,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
} |
/** |
- * An element visitor that will recursively visit all of the elements in an |
- * element model (like instances of the class [RecursiveElementVisitor]). In |
- * addition, when an element of a specific type is visited not only will the |
- * visit method for that specific type of element be invoked, but additional |
- * methods for the supertypes of that element will also be invoked. For example, |
- * using an instance of this class to visit a [MethodElement] will cause the |
- * method [visitMethodElement] to be invoked but will also cause the methods |
- * [visitExecutableElement] and [visitElement] to be subsequently invoked. This |
- * allows visitors to be written that visit all executable elements without |
- * needing to override the visit method for each of the specific subclasses of |
- * [ExecutableElement]. |
- * |
- * Note, however, that unlike many visitors, element visitors visit objects |
- * based on the interfaces implemented by those elements. Because interfaces |
- * form a graph structure rather than a tree structure the way classes do, and |
- * because it is generally undesirable for an object to be visited more than |
- * once, this class flattens the interface graph into a pseudo-tree. In |
- * particular, this class treats elements as if the element types were |
- * structured in the following way: |
- * |
- * <pre> |
- * Element |
- * ClassElement |
- * CompilationUnitElement |
- * ExecutableElement |
- * ConstructorElement |
- * LocalElement |
- * FunctionElement |
- * MethodElement |
- * PropertyAccessorElement |
- * ExportElement |
- * HtmlElement |
- * ImportElement |
- * LabelElement |
- * LibraryElement |
- * MultiplyDefinedElement |
- * PrefixElement |
- * TypeAliasElement |
- * TypeParameterElement |
- * UndefinedElement |
- * VariableElement |
- * PropertyInducingElement |
- * FieldElement |
- * TopLevelVariableElement |
- * LocalElement |
- * LocalVariableElement |
- * ParameterElement |
- * FieldFormalParameterElement |
- * </pre> |
- * |
- * Subclasses that override a visit method must either invoke the overridden |
- * visit method or explicitly invoke the more general visit method. Failure to |
- * do so will cause the visit methods for superclasses of the element to not be |
- * invoked and will cause the children of the visited node to not be visited. |
- */ |
-class GeneralizingElementVisitor<R> implements ElementVisitor<R> { |
- @override |
- R visitClassElement(ClassElement element) => visitElement(element); |
- |
- @override |
- R visitCompilationUnitElement(CompilationUnitElement element) => |
- visitElement(element); |
- |
- @override |
- R visitConstructorElement(ConstructorElement element) => |
- visitExecutableElement(element); |
- |
- R visitElement(Element element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- R visitExecutableElement(ExecutableElement element) => visitElement(element); |
- |
- @override |
- R visitExportElement(ExportElement element) => visitElement(element); |
- |
- @override |
- R visitFieldElement(FieldElement element) => |
- visitPropertyInducingElement(element); |
- |
- @override |
- R visitFieldFormalParameterElement(FieldFormalParameterElement element) => |
- visitParameterElement(element); |
- |
- @override |
- R visitFunctionElement(FunctionElement element) => visitLocalElement(element); |
- |
- @override |
- R visitFunctionTypeAliasElement(FunctionTypeAliasElement element) => |
- visitElement(element); |
- |
- @override |
- R visitImportElement(ImportElement element) => visitElement(element); |
- |
- @override |
- R visitLabelElement(LabelElement element) => visitElement(element); |
- |
- @override |
- R visitLibraryElement(LibraryElement element) => visitElement(element); |
- |
- R visitLocalElement(LocalElement element) { |
- if (element is LocalVariableElement) { |
- return visitVariableElement(element); |
- } else if (element is ParameterElement) { |
- return visitVariableElement(element); |
- } else if (element is FunctionElement) { |
- return visitExecutableElement(element); |
- } |
- return null; |
- } |
- |
- @override |
- R visitLocalVariableElement(LocalVariableElement element) => |
- visitLocalElement(element); |
- |
- @override |
- R visitMethodElement(MethodElement element) => |
- visitExecutableElement(element); |
- |
- @override |
- R visitMultiplyDefinedElement(MultiplyDefinedElement element) => |
- visitElement(element); |
- |
- @override |
- R visitParameterElement(ParameterElement element) => |
- visitLocalElement(element); |
- |
- @override |
- R visitPrefixElement(PrefixElement element) => visitElement(element); |
- |
- @override |
- R visitPropertyAccessorElement(PropertyAccessorElement element) => |
- visitExecutableElement(element); |
- |
- R visitPropertyInducingElement(PropertyInducingElement element) => |
- visitVariableElement(element); |
- |
- @override |
- R visitTopLevelVariableElement(TopLevelVariableElement element) => |
- visitPropertyInducingElement(element); |
- |
- @override |
- R visitTypeParameterElement(TypeParameterElement element) => |
- visitElement(element); |
- |
- R visitVariableElement(VariableElement element) => visitElement(element); |
-} |
- |
-/** |
- * A combinator that causes some of the names in a namespace to be hidden when |
- * being imported. |
- */ |
-abstract class HideElementCombinator implements NamespaceCombinator { |
- /** |
- * Return a list containing the names that are not to be made visible in the |
- * importing library even if they are defined in the imported library. |
- */ |
- List<String> get hiddenNames; |
-} |
- |
-/** |
* A concrete implementation of a [HideElementCombinator]. |
*/ |
class HideElementCombinatorImpl implements HideElementCombinator { |
@@ -5813,46 +4214,6 @@ class HideElementCombinatorImpl implements HideElementCombinator { |
} |
/** |
- * A single import directive within a library. |
- */ |
-abstract class ImportElement implements Element, UriReferencedElement { |
- /** |
- * An empty list of import elements. |
- */ |
- static const List<ImportElement> EMPTY_LIST = const <ImportElement>[]; |
- |
- /** |
- * Return a list containing the combinators that were specified as part of the |
- * import directive in the order in which they were specified. |
- */ |
- List<NamespaceCombinator> get combinators; |
- |
- /** |
- * Return the library that is imported into this library by this import |
- * directive. |
- */ |
- LibraryElement get importedLibrary; |
- |
- /** |
- * Return `true` if this import is for a deferred library. |
- */ |
- bool get isDeferred; |
- |
- /** |
- * Return the prefix that was specified as part of the import directive, or |
- * `null` if there was no prefix specified. |
- */ |
- PrefixElement get prefix; |
- |
- /** |
- * Return the offset of the prefix of this import in the file that contains |
- * this import directive, or `-1` if this import is synthetic, does not have a |
- * prefix, or otherwise does not have an offset. |
- */ |
- int get prefixOffset; |
-} |
- |
-/** |
* A concrete implementation of an [ImportElement]. |
*/ |
class ImportElementImpl extends UriReferencedElementImpl |
@@ -5920,444 +4281,61 @@ class ImportElementImpl extends UriReferencedElementImpl |
} |
/** |
- * The type introduced by either a class or an interface, or a reference to such |
- * a type. |
+ * A concrete implementation of an [InterfaceType]. |
*/ |
-abstract class InterfaceType implements ParameterizedType { |
+class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
/** |
- * An empty list of types. |
+ * A list containing the actual types of the type arguments. |
*/ |
- static const List<InterfaceType> EMPTY_LIST = const <InterfaceType>[]; |
+ List<DartType> typeArguments = DartType.EMPTY_LIST; |
/** |
- * Return a list containing all of the accessors (getters and setters) |
- * declared in this type. |
+ * The set of typedefs which should not be expanded when exploring this type, |
+ * to avoid creating infinite types in response to self-referential typedefs. |
*/ |
- List<PropertyAccessorElement> get accessors; |
+ final List<FunctionTypeAliasElement> prunedTypedefs; |
/** |
- * Return a list containing all of the constructors declared in this type. |
+ * Initialize a newly created type to be declared by the given [element]. |
*/ |
- List<ConstructorElement> get constructors; |
- |
- @override |
- ClassElement get element; |
+ InterfaceTypeImpl(ClassElement element, [this.prunedTypedefs]) |
+ : super(element, element.displayName); |
/** |
- * Return a list containing all of the interfaces that are implemented by this |
- * interface. Note that this is <b>not</b>, in general, equivalent to getting |
- * the interfaces from this type's element because the types returned by this |
- * method will have had their type parameters replaced. |
+ * Initialize a newly created type to have the given [name]. This constructor |
+ * should only be used in cases where there is no declaration of the type. |
*/ |
- List<InterfaceType> get interfaces; |
+ InterfaceTypeImpl.named(String name) |
+ : prunedTypedefs = null, |
+ super(null, name); |
/** |
- * Return a list containing all of the methods declared in this type. |
+ * Private constructor. |
*/ |
- List<MethodElement> get methods; |
+ InterfaceTypeImpl._(Element element, String name, this.prunedTypedefs) |
+ : super(element, name); |
- /** |
- * Return a list containing all of the mixins that are applied to the class |
- * being extended in order to derive the superclass of this class. Note that |
- * this is <b>not</b>, in general, equivalent to getting the mixins from this |
- * type's element because the types returned by this method will have had |
- * their type parameters replaced. |
- */ |
- List<InterfaceType> get mixins; |
+ @override |
+ List<PropertyAccessorElement> get accessors { |
+ List<PropertyAccessorElement> accessors = element.accessors; |
+ List<PropertyAccessorElement> members = |
+ new List<PropertyAccessorElement>(accessors.length); |
+ for (int i = 0; i < accessors.length; i++) { |
+ members[i] = PropertyAccessorMember.from(accessors[i], this); |
+ } |
+ return members; |
+ } |
- /** |
- * Return the type representing the superclass of this type, or null if this |
- * type represents the class 'Object'. Note that this is <b>not</b>, in |
- * general, equivalent to getting the superclass from this type's element |
- * because the type returned by this method will have had it's type parameters |
- * replaced. |
- */ |
- InterfaceType get superclass; |
- |
- /** |
- * Return the element representing the getter with the given [name] that is |
- * declared in this class, or `null` if this class does not declare a getter |
- * with the given name. |
- */ |
- PropertyAccessorElement getGetter(String name); |
- |
- /** |
- * Return the element representing the method with the given [name] that is |
- * declared in this class, or `null` if this class does not declare a method |
- * with the given name. |
- */ |
- MethodElement getMethod(String name); |
- |
- /** |
- * Return the element representing the setter with the given [name] that is |
- * declared in this class, or `null` if this class does not declare a setter |
- * with the given name. |
- */ |
- PropertyAccessorElement getSetter(String name); |
- |
- /** |
- * Return `true` if this type is a direct supertype of the given [type]. The |
- * implicit interface of class <i>I</i> is a direct supertype of the implicit |
- * interface of class <i>J</i> iff: |
- * |
- * * <i>I</i> is Object, and <i>J</i> has no extends clause. |
- * * <i>I</i> is listed in the extends clause of <i>J</i>. |
- * * <i>I</i> is listed in the implements clause of <i>J</i>. |
- * * <i>I</i> is listed in the with clause of <i>J</i>. |
- * * <i>J</i> is a mixin application of the mixin of <i>I</i>. |
- */ |
- bool isDirectSupertypeOf(InterfaceType type); |
- |
- /** |
- * Return `true` if this type is more specific than the given [type]. An |
- * interface type <i>T</i> is more specific than an interface type <i>S</i>, |
- * written <i>T « S</i>, if one of the following conditions is met: |
- * |
- * * Reflexivity: <i>T</i> is <i>S</i>. |
- * * <i>T</i> is bottom. |
- * * <i>S</i> is dynamic. |
- * * Direct supertype: <i>S</i> is a direct supertype of <i>T</i>. |
- * * <i>T</i> is a type parameter and <i>S</i> is the upper bound of <i>T</i>. |
- * * Covariance: <i>T</i> is of the form <i>I<T<sub>1</sub>, …, |
- * T<sub>n</sub>></i> and S</i> is of the form <i>I<S<sub>1</sub>, |
- * …, S<sub>n</sub>></i> and <i>T<sub>i</sub> « |
- * S<sub>i</sub></i>, <i>1 <= i <= n</i>. |
- * * Transitivity: <i>T « U</i> and <i>U « S</i>. |
- */ |
- @override |
- bool isMoreSpecificThan(DartType type); |
- |
- /** |
- * Return `true` if this type is a subtype of the given [type]. An interface |
- * type <i>T</i> is a subtype of an interface type <i>S</i>, written <i>T</i> |
- * <: <i>S</i>, iff <i>[bottom/dynamic]T</i> « <i>S</i> (<i>T</i> is |
- * more specific than <i>S</i>). If an interface type <i>I</i> includes a |
- * method named <i>call()</i>, and the type of <i>call()</i> is the function |
- * type <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>. |
- */ |
- @override |
- bool isSubtypeOf(DartType type); |
- |
- /** |
- * Return the element representing the constructor that results from looking |
- * up the constructor with the given [name] in this class with respect to the |
- * given [library], or `null` if the look up fails. The behavior of this |
- * method is defined by the Dart Language Specification in section 12.11.1: |
- * <blockquote> |
- * If <i>e</i> is of the form <b>new</b> <i>T.id()</i> then let <i>q<i> be the |
- * constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<i>. |
- * Otherwise, if <i>q</i> is not defined or not accessible, a |
- * NoSuchMethodException is thrown. |
- * </blockquote> |
- */ |
- ConstructorElement lookUpConstructor(String name, LibraryElement library); |
- |
- /** |
- * Return the element representing the getter that results from looking up the |
- * getter with the given [name] in this class with respect to the given |
- * [library], or `null` if the look up fails. The behavior of this method is |
- * defined by the Dart Language Specification in section 12.15.1: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: |
- * * If <i>C</i> declares an instance getter (respectively setter) named |
- * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
- * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
- * superclass <i>S</i>, then the result of the lookup is the result of |
- * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
- * to <i>L</i>. Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpGetter(String name, LibraryElement library); |
- |
- /** |
- * Return the element representing the getter that results from looking up the |
- * getter with the given [name] in the superclass of this class with respect |
- * to the given [library], or `null` if the look up fails. The behavior of |
- * this method is defined by the Dart Language Specification in section |
- * 12.15.1: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: |
- * * If <i>C</i> declares an instance getter (respectively setter) named |
- * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
- * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
- * superclass <i>S</i>, then the result of the lookup is the result of |
- * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
- * to <i>L</i>. Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpGetterInSuperclass( |
- String name, LibraryElement library); |
- |
- /** |
- * Look up the member with the given [name] in this type and all extended |
- * and mixed in classes, and by default including [thisType]. If the search |
- * fails, this will then search interfaces. |
- * |
- * Return the element representing the member that was found, or `null` if |
- * there is no getter with the given name. |
- * |
- * The [library] determines if a private member name is visible, and does not |
- * need to be supplied for public names. |
- */ |
- PropertyAccessorElement lookUpInheritedGetter(String name, |
- {LibraryElement library, bool thisType: true}); |
- |
- /** |
- * Look up the member with the given [name] in this type and all extended |
- * and mixed in classes, starting from this type. If the search fails, |
- * search interfaces. |
- * |
- * Return the element representing the member that was found, or `null` if |
- * there is no getter with the given name. |
- * |
- * The [library] determines if a private member name is visible, and does not |
- * need to be supplied for public names. |
- */ |
- ExecutableElement lookUpInheritedGetterOrMethod(String name, |
- {LibraryElement library}); |
- |
- /** |
- * Look up the member with the given [name] in this type and all extended |
- * and mixed in classes, and by default including [thisType]. If the search |
- * fails, this will then search interfaces. |
- * |
- * Return the element representing the member that was found, or `null` if |
- * there is no getter with the given name. |
- * |
- * The [library] determines if a private member name is visible, and does not |
- * need to be supplied for public names. |
- */ |
- MethodElement lookUpInheritedMethod(String name, |
- {LibraryElement library, bool thisType: true}); |
- |
- /** |
- * Look up the member with the given [name] in this type and all extended |
- * and mixed in classes, and by default including [thisType]. If the search |
- * fails, this will then search interfaces. |
- * |
- * Return the element representing the member that was found, or `null` if |
- * there is no getter with the given name. |
- * |
- * The [library] determines if a private member name is visible, and does not |
- * need to be supplied for public names. |
- */ |
- PropertyAccessorElement lookUpInheritedSetter(String name, |
- {LibraryElement library, bool thisType: true}); |
- |
- /** |
- * Return the element representing the method that results from looking up the |
- * method with the given [name] in this class with respect to the given |
- * [library], or `null` if the look up fails. The behavior of this method is |
- * defined by the Dart Language Specification in section 12.15.1: |
- * <blockquote> |
- * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
- * library <i>L</i> is: |
- * * If <i>C</i> declares an instance method named <i>m</i> that is accessible |
- * to <i>L</i>, then that method is the result of the lookup. Otherwise, if |
- * <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the |
- * result of looking up method <i>m</i> in <i>S</i> with respect to <i>L</i> |
- * Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- MethodElement lookUpMethod(String name, LibraryElement library); |
- |
- /** |
- * Return the element representing the method that results from looking up the |
- * method with the given [name] in the superclass of this class with respect |
- * to the given [library], or `null` if the look up fails. The behavior of |
- * this method is defined by the Dart Language Specification in section |
- * 12.15.1: |
- * <blockquote> |
- * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
- * library <i>L</i> is: |
- * * If <i>C</i> declares an instance method named <i>m</i> that is accessible |
- * to <i>L</i>, then that method is the result of the lookup. Otherwise, if |
- * <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the |
- * result of looking up method <i>m</i> in <i>S</i> with respect to <i>L</i>. |
- * Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- MethodElement lookUpMethodInSuperclass(String name, LibraryElement library); |
- |
- /** |
- * Return the element representing the setter that results from looking up the |
- * setter with the given [name] in this class with respect to the given |
- * [library], or `null` if the look up fails. The behavior of this method is |
- * defined by the Dart Language Specification in section 12.16: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: |
- * * If <i>C</i> declares an instance getter (respectively setter) named |
- * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
- * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
- * superclass <i>S</i>, then the result of the lookup is the result of |
- * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
- * to <i>L</i>. Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpSetter(String name, LibraryElement library); |
- |
- /** |
- * Return the element representing the setter that results from looking up the |
- * setter with the given [name] in the superclass of this class with respect |
- * to the given [library], or `null` if the look up fails. The behavior of |
- * this method is defined by the Dart Language Specification in section 12.16: |
- * <blockquote> |
- * The result of looking up getter (respectively setter) <i>m</i> in class |
- * <i>C</i> with respect to library <i>L</i> is: |
- * * If <i>C</i> declares an instance getter (respectively setter) named |
- * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
- * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
- * superclass <i>S</i>, then the result of the lookup is the result of |
- * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
- * to <i>L</i>. Otherwise, we say that the lookup has failed. |
- * </blockquote> |
- */ |
- PropertyAccessorElement lookUpSetterInSuperclass( |
- String name, LibraryElement library); |
- |
- @override |
- InterfaceType substitute2( |
- List<DartType> argumentTypes, List<DartType> parameterTypes); |
- |
- // TODO(jmesserly): introduce a new "instantiate" and deprecate this. |
- // The new "instantiate" should work similar to FunctionType.instantiate, |
- // which uses [boundTypeParameters] to model type parameters that haven't been |
- // filled in yet. Those are kept separate from already-substituted type |
- // parameters or free variables from the enclosing scopes, which allows nested |
- // generics to work, such as a generic method in a generic class. |
- /** |
- * Return the type resulting from substituting the given arguments for this |
- * type's parameters. This is fully equivalent to `substitute2(argumentTypes, |
- * getTypeArguments())`. |
- */ |
- InterfaceType substitute4(List<DartType> argumentTypes); |
- |
- /** |
- * Returns a "smart" version of the "least upper bound" of the given types. |
- * |
- * If these types have the same element and differ only in terms of the type |
- * arguments, attempts to find a compatible set of type arguments. |
- * |
- * Otherwise, calls [DartType.getLeastUpperBound]. |
- */ |
- static InterfaceType getSmartLeastUpperBound( |
- InterfaceType first, InterfaceType second) { |
- // TODO(paulberry): this needs to be deprecated and replaced with a method |
- // in [TypeSystem], since it relies on the deprecated functionality of |
- // [DartType.getLeastUpperBound]. |
- if (first.element == second.element) { |
- return _leastUpperBound(first, second); |
- } |
- AnalysisContext context = first.element.context; |
- return context.typeSystem |
- .getLeastUpperBound(context.typeProvider, first, second); |
- } |
- |
- /** |
- * Return the "least upper bound" of the given types under the assumption that |
- * the types have the same element and differ only in terms of the type |
- * arguments. |
- * |
- * The resulting type is composed by comparing the corresponding type |
- * arguments, keeping those that are the same, and using 'dynamic' for those |
- * that are different. |
- */ |
- static InterfaceType _leastUpperBound( |
- InterfaceType firstType, InterfaceType secondType) { |
- ClassElement firstElement = firstType.element; |
- ClassElement secondElement = secondType.element; |
- if (firstElement != secondElement) { |
- throw new IllegalArgumentException('The same elements expected, but ' |
- '$firstElement and $secondElement are given.'); |
- } |
- if (firstType == secondType) { |
- return firstType; |
- } |
- List<DartType> firstArguments = firstType.typeArguments; |
- List<DartType> secondArguments = secondType.typeArguments; |
- int argumentCount = firstArguments.length; |
- if (argumentCount == 0) { |
- return firstType; |
- } |
- List<DartType> lubArguments = new List<DartType>(argumentCount); |
- for (int i = 0; i < argumentCount; i++) { |
- // |
- // Ideally we would take the least upper bound of the two argument types, |
- // but this can cause an infinite recursion (such as when finding the |
- // least upper bound of String and num). |
- // |
- if (firstArguments[i] == secondArguments[i]) { |
- lubArguments[i] = firstArguments[i]; |
- } |
- if (lubArguments[i] == null) { |
- lubArguments[i] = DynamicTypeImpl.instance; |
- } |
- } |
- InterfaceTypeImpl lub = new InterfaceTypeImpl(firstElement); |
- lub.typeArguments = lubArguments; |
- return lub; |
- } |
-} |
- |
-/** |
- * A concrete implementation of an [InterfaceType]. |
- */ |
-class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
- /** |
- * A list containing the actual types of the type arguments. |
- */ |
- List<DartType> typeArguments = DartType.EMPTY_LIST; |
- |
- /** |
- * The set of typedefs which should not be expanded when exploring this type, |
- * to avoid creating infinite types in response to self-referential typedefs. |
- */ |
- final List<FunctionTypeAliasElement> prunedTypedefs; |
- |
- /** |
- * Initialize a newly created type to be declared by the given [element]. |
- */ |
- InterfaceTypeImpl(ClassElement element, [this.prunedTypedefs]) |
- : super(element, element.displayName); |
- |
- /** |
- * Initialize a newly created type to have the given [name]. This constructor |
- * should only be used in cases where there is no declaration of the type. |
- */ |
- InterfaceTypeImpl.named(String name) |
- : prunedTypedefs = null, |
- super(null, name); |
- |
- /** |
- * Private constructor. |
- */ |
- InterfaceTypeImpl._(Element element, String name, this.prunedTypedefs) |
- : super(element, name); |
- |
- @override |
- List<PropertyAccessorElement> get accessors { |
- List<PropertyAccessorElement> accessors = element.accessors; |
- List<PropertyAccessorElement> members = |
- new List<PropertyAccessorElement>(accessors.length); |
- for (int i = 0; i < accessors.length; i++) { |
- members[i] = PropertyAccessorMember.from(accessors[i], this); |
- } |
- return members; |
- } |
- |
- @override |
- List<ConstructorElement> get constructors { |
- List<ConstructorElement> constructors = element.constructors; |
- List<ConstructorElement> members = |
- new List<ConstructorElement>(constructors.length); |
- for (int i = 0; i < constructors.length; i++) { |
- members[i] = ConstructorMember.from(constructors[i], this); |
- } |
- return members; |
- } |
+ @override |
+ List<ConstructorElement> get constructors { |
+ List<ConstructorElement> constructors = element.constructors; |
+ List<ConstructorElement> members = |
+ new List<ConstructorElement>(constructors.length); |
+ for (int i = 0; i < constructors.length; i++) { |
+ members[i] = ConstructorMember.from(constructors[i], this); |
+ } |
+ return members; |
+ } |
@override |
String get displayName { |
@@ -6978,6 +4956,27 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
_computeSuperinterfaceSet(type, new HashSet<InterfaceType>()); |
/** |
+ * Returns a "smart" version of the "least upper bound" of the given types. |
+ * |
+ * If these types have the same element and differ only in terms of the type |
+ * arguments, attempts to find a compatible set of type arguments. |
+ * |
+ * Otherwise, calls [DartType.getLeastUpperBound]. |
+ */ |
+ static InterfaceType getSmartLeastUpperBound( |
+ InterfaceType first, InterfaceType second) { |
+ // TODO(paulberry): this needs to be deprecated and replaced with a method |
+ // in [TypeSystem], since it relies on the deprecated functionality of |
+ // [DartType.getLeastUpperBound]. |
+ if (first.element == second.element) { |
+ return _leastUpperBound(first, second); |
+ } |
+ AnalysisContext context = first.element.context; |
+ return context.typeSystem |
+ .getLeastUpperBound(context.typeProvider, first, second); |
+ } |
+ |
+ /** |
* Return the length of the longest inheritance path from a subtype of the |
* given [type] to Object, where the given [depth] is the length of the |
* longest path from the subtype to this type. The set of [visitedTypes] is |
@@ -7061,6 +5060,51 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
} |
/** |
+ * Return the "least upper bound" of the given types under the assumption that |
+ * the types have the same element and differ only in terms of the type |
+ * arguments. |
+ * |
+ * The resulting type is composed by comparing the corresponding type |
+ * arguments, keeping those that are the same, and using 'dynamic' for those |
+ * that are different. |
+ */ |
+ static InterfaceType _leastUpperBound( |
+ InterfaceType firstType, InterfaceType secondType) { |
+ ClassElement firstElement = firstType.element; |
+ ClassElement secondElement = secondType.element; |
+ if (firstElement != secondElement) { |
+ throw new IllegalArgumentException('The same elements expected, but ' |
+ '$firstElement and $secondElement are given.'); |
+ } |
+ if (firstType == secondType) { |
+ return firstType; |
+ } |
+ List<DartType> firstArguments = firstType.typeArguments; |
+ List<DartType> secondArguments = secondType.typeArguments; |
+ int argumentCount = firstArguments.length; |
+ if (argumentCount == 0) { |
+ return firstType; |
+ } |
+ List<DartType> lubArguments = new List<DartType>(argumentCount); |
+ for (int i = 0; i < argumentCount; i++) { |
+ // |
+ // Ideally we would take the least upper bound of the two argument types, |
+ // but this can cause an infinite recursion (such as when finding the |
+ // least upper bound of String and num). |
+ // |
+ if (firstArguments[i] == secondArguments[i]) { |
+ lubArguments[i] = firstArguments[i]; |
+ } |
+ if (lubArguments[i] == null) { |
+ lubArguments[i] = DynamicTypeImpl.instance; |
+ } |
+ } |
+ InterfaceTypeImpl lub = new InterfaceTypeImpl(firstElement); |
+ lub.typeArguments = lubArguments; |
+ return lub; |
+ } |
+ |
+ /** |
* Look up the getter with the given [name] in the interfaces |
* implemented by the given [targetType], either directly or indirectly. |
* Return the element representing the getter that was found, or `null` if |
@@ -7114,22 +5158,6 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
} |
/** |
- * A label associated with a statement. |
- */ |
-abstract class LabelElement implements Element { |
- /** |
- * An empty list of label elements. |
- */ |
- static const List<LabelElement> EMPTY_LIST = const <LabelElement>[]; |
- |
- /** |
- * Return the executable element in which this label is defined. |
- */ |
- @override |
- ExecutableElement get enclosingElement; |
-} |
- |
-/** |
* A concrete implementation of a [LabelElement]. |
*/ |
class LabelElementImpl extends ElementImpl implements LabelElement { |
@@ -7180,144 +5208,6 @@ class LabelElementImpl extends ElementImpl implements LabelElement { |
} |
/** |
- * A library. |
- */ |
-abstract class LibraryElement implements Element { |
- /** |
- * An empty list of library elements. |
- */ |
- static const List<LibraryElement> EMPTY_LIST = const <LibraryElement>[]; |
- |
- /** |
- * Return the compilation unit that defines this library. |
- */ |
- CompilationUnitElement get definingCompilationUnit; |
- |
- /** |
- * Return the entry point for this library, or `null` if this library does not |
- * have an entry point. The entry point is defined to be a zero argument |
- * top-level function whose name is `main`. |
- */ |
- FunctionElement get entryPoint; |
- |
- /** |
- * Return a list containing all of the libraries that are exported from this |
- * library. |
- */ |
- List<LibraryElement> get exportedLibraries; |
- |
- /** |
- * The export [Namespace] of this library, `null` if it has not been |
- * computed yet. |
- */ |
- Namespace get exportNamespace; |
- |
- /** |
- * Return a list containing all of the exports defined in this library. |
- */ |
- List<ExportElement> get exports; |
- |
- /** |
- * Return `true` if the defining compilation unit of this library contains at |
- * least one import directive whose URI uses the "dart-ext" scheme. |
- */ |
- bool get hasExtUri; |
- |
- /** |
- * Return `true` if this library defines a top-level function named |
- * `loadLibrary`. |
- */ |
- bool get hasLoadLibraryFunction; |
- |
- /** |
- * Return a list containing all of the libraries that are imported into this |
- * library. This includes all of the libraries that are imported using a |
- * prefix (also available through the prefixes returned by [getPrefixes]) and |
- * those that are imported without a prefix. |
- */ |
- List<LibraryElement> get importedLibraries; |
- |
- /** |
- * Return a list containing all of the imports defined in this library. |
- */ |
- List<ImportElement> get imports; |
- |
- /** |
- * Return `true` if this library is an application that can be run in the |
- * browser. |
- */ |
- bool get isBrowserApplication; |
- |
- /** |
- * Return `true` if this library is the dart:core library. |
- */ |
- bool get isDartCore; |
- |
- /** |
- * Return `true` if this library is part of the SDK. |
- */ |
- bool get isInSdk; |
- |
- /** |
- * Return the element representing the synthetic function `loadLibrary` that |
- * is implicitly defined for this library if the library is imported using a |
- * deferred import. |
- */ |
- FunctionElement get loadLibraryFunction; |
- |
- /** |
- * Return a list containing all of the compilation units that are included in |
- * this library using a `part` directive. This does not include the defining |
- * compilation unit that contains the `part` directives. |
- */ |
- List<CompilationUnitElement> get parts; |
- |
- /** |
- * Return a list containing elements for each of the prefixes used to `import` |
- * libraries into this library. Each prefix can be used in more than one |
- * `import` directive. |
- */ |
- List<PrefixElement> get prefixes; |
- |
- /** |
- * The public [Namespace] of this library, `null` if it has not been |
- * computed yet. |
- */ |
- Namespace get publicNamespace; |
- |
- /** |
- * Return a list containing all of the compilation units this library consists |
- * of. This includes the defining compilation unit and units included using |
- * the `part` directive. |
- */ |
- List<CompilationUnitElement> get units; |
- |
- /** |
- * Return a list containing all directly and indirectly imported libraries. |
- */ |
- List<LibraryElement> get visibleLibraries; |
- |
- /** |
- * Return a list containing all of the imports that share the given [prefix], |
- * or an empty array if there are no such imports. |
- */ |
- List<ImportElement> getImportsWithPrefix(PrefixElement prefix); |
- |
- /** |
- * Return the class defined in this library that has the given [name], or |
- * `null` if this library does not define a class with the given name. |
- */ |
- ClassElement getType(String className); |
- |
- /** |
- * Return `true` if this library is up to date with respect to the given |
- * [timeStamp]. If any transitively referenced Source is newer than the time |
- * stamp, this method returns false. |
- */ |
- bool isUpToDate(int timeStamp); |
-} |
- |
-/** |
* A concrete implementation of a [LibraryElement]. |
*/ |
class LibraryElementImpl extends ElementImpl implements LibraryElement { |
@@ -7838,7 +5728,7 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
/** |
* Return `true` if the given [library] is up to date with respect to the |
* given [timeStamp]. The set of [visitedLibraries] is used to prevent |
- * infinite recusion in the case of mutually dependent libraries. |
+ * infinite recursion in the case of mutually dependent libraries. |
*/ |
static bool _safeIsUpToDate(LibraryElement library, int timeStamp, |
Set<LibraryElement> visitedLibraries) { |
@@ -7875,41 +5765,6 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
} |
/** |
- * An element that can be (but are not required to be) defined within a method |
- * or function (an [ExecutableElement]). |
- */ |
-abstract class LocalElement implements Element { |
- /** |
- * Return a source range that covers the approximate portion of the source in |
- * which the name of this element is visible, or `null` if there is no single |
- * range of characters within which the element name is visible. |
- * |
- * * For a local variable, this includes everything from the end of the |
- * variable's initializer to the end of the block that encloses the variable |
- * declaration. |
- * * For a parameter, this includes the body of the method or function that |
- * declares the parameter. |
- * * For a local function, this includes everything from the beginning of the |
- * function's body to the end of the block that encloses the function |
- * declaration. |
- * * For top-level functions, `null` will be returned because they are |
- * potentially visible in multiple sources. |
- */ |
- SourceRange get visibleRange; |
-} |
- |
-/** |
- * A local variable. |
- */ |
-abstract class LocalVariableElement implements LocalElement, VariableElement { |
- /** |
- * An empty list of field elements. |
- */ |
- static const List<LocalVariableElement> EMPTY_LIST = |
- const <LocalVariableElement>[]; |
-} |
- |
-/** |
* A concrete implementation of a [LocalVariableElement]. |
*/ |
class LocalVariableElementImpl extends VariableElementImpl |
@@ -8147,26 +6002,6 @@ abstract class Member implements Element { |
} |
/** |
- * An element that represents a method defined within a type. |
- */ |
-abstract class MethodElement implements ClassMemberElement, ExecutableElement { |
- /** |
- * An empty list of method elements. |
- */ |
- static const List<MethodElement> EMPTY_LIST = const <MethodElement>[]; |
- |
- /** |
- * Return the resolved [MethodDeclaration] node that declares this |
- * [MethodElement]. |
- * |
- * This method is expensive, because resolved AST might be evicted from cache, |
- * so parsing and resolving will be performed. |
- */ |
- @override |
- MethodDeclaration computeNode(); |
-} |
- |
-/** |
* A concrete implementation of a [MethodElement]. |
*/ |
class MethodElementImpl extends ExecutableElementImpl implements MethodElement { |
@@ -8297,7 +6132,7 @@ class MethodMember extends ExecutableMember implements MethodElement { |
} |
buffer.write(")"); |
if (type != null) { |
- buffer.write(Element.RIGHT_ARROW); |
+ buffer.write(ElementImpl.RIGHT_ARROW); |
buffer.write(type.returnType); |
} |
return buffer.toString(); |
@@ -8327,172 +6162,6 @@ class MethodMember extends ExecutableMember implements MethodElement { |
} |
/** |
- * The enumeration `Modifier` defines constants for all of the modifiers defined |
- * by the Dart language and for a few additional flags that are useful. |
- */ |
-class Modifier extends Enum<Modifier> { |
- /** |
- * Indicates that the modifier 'abstract' was applied to the element. |
- */ |
- static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0); |
- |
- /** |
- * Indicates that an executable element has a body marked as being |
- * asynchronous. |
- */ |
- static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1); |
- |
- /** |
- * Indicates that the modifier 'const' was applied to the element. |
- */ |
- static const Modifier CONST = const Modifier('CONST', 2); |
- |
- /** |
- * Indicates that the import element represents a deferred library. |
- */ |
- static const Modifier DEFERRED = const Modifier('DEFERRED', 3); |
- |
- /** |
- * Indicates that a class element was defined by an enum declaration. |
- */ |
- static const Modifier ENUM = const Modifier('ENUM', 4); |
- |
- /** |
- * Indicates that a class element was defined by an enum declaration. |
- */ |
- static const Modifier EXTERNAL = const Modifier('EXTERNAL', 5); |
- |
- /** |
- * Indicates that the modifier 'factory' was applied to the element. |
- */ |
- static const Modifier FACTORY = const Modifier('FACTORY', 6); |
- |
- /** |
- * Indicates that the modifier 'final' was applied to the element. |
- */ |
- static const Modifier FINAL = const Modifier('FINAL', 7); |
- |
- /** |
- * Indicates that an executable element has a body marked as being a |
- * generator. |
- */ |
- static const Modifier GENERATOR = const Modifier('GENERATOR', 8); |
- |
- /** |
- * Indicates that the pseudo-modifier 'get' was applied to the element. |
- */ |
- static const Modifier GETTER = const Modifier('GETTER', 9); |
- |
- /** |
- * A flag used for libraries indicating that the defining compilation unit |
- * contains at least one import directive whose URI uses the "dart-ext" |
- * scheme. |
- */ |
- static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); |
- |
- /** |
- * Indicates that the associated element did not have an explicit type |
- * associated with it. If the element is an [ExecutableElement], then the |
- * type being referred to is the return type. |
- */ |
- static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11); |
- |
- /** |
- * Indicates that a class can validly be used as a mixin. |
- */ |
- static const Modifier MIXIN = const Modifier('MIXIN', 12); |
- |
- /** |
- * Indicates that a class is a mixin application. |
- */ |
- static const Modifier MIXIN_APPLICATION = |
- const Modifier('MIXIN_APPLICATION', 13); |
- |
- /** |
- * Indicates that the value of a parameter or local variable might be mutated |
- * within the context. |
- */ |
- static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = |
- const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 14); |
- |
- /** |
- * Indicates that the value of a parameter or local variable might be mutated |
- * within the scope. |
- */ |
- static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = |
- const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 15); |
- |
- /** |
- * Indicates that a class contains an explicit reference to 'super'. |
- */ |
- static const Modifier REFERENCES_SUPER = |
- const Modifier('REFERENCES_SUPER', 16); |
- |
- /** |
- * Indicates that the pseudo-modifier 'set' was applied to the element. |
- */ |
- static const Modifier SETTER = const Modifier('SETTER', 17); |
- |
- /** |
- * Indicates that the modifier 'static' was applied to the element. |
- */ |
- static const Modifier STATIC = const Modifier('STATIC', 18); |
- |
- /** |
- * Indicates that the element does not appear in the source code but was |
- * implicitly created. For example, if a class does not define any |
- * constructors, an implicit zero-argument constructor will be created and it |
- * will be marked as being synthetic. |
- */ |
- static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 19); |
- |
- static const List<Modifier> values = const [ |
- ABSTRACT, |
- ASYNCHRONOUS, |
- CONST, |
- DEFERRED, |
- ENUM, |
- EXTERNAL, |
- FACTORY, |
- FINAL, |
- GENERATOR, |
- GETTER, |
- HAS_EXT_URI, |
- IMPLICIT_TYPE, |
- MIXIN, |
- MIXIN_APPLICATION, |
- POTENTIALLY_MUTATED_IN_CONTEXT, |
- POTENTIALLY_MUTATED_IN_SCOPE, |
- REFERENCES_SUPER, |
- SETTER, |
- STATIC, |
- SYNTHETIC |
- ]; |
- |
- const Modifier(String name, int ordinal) : super(name, ordinal); |
-} |
- |
-/** |
- * A pseudo-element that represents multiple elements defined within a single |
- * scope that have the same name. This situation is not allowed by the language, |
- * so objects implementing this interface always represent an error. As a |
- * result, most of the normal operations on elements do not make sense and will |
- * return useless results. |
- */ |
-abstract class MultiplyDefinedElement implements Element { |
- /** |
- * Return a list containing all of the elements that were defined within the |
- * scope to have the same name. |
- */ |
- List<Element> get conflictingElements; |
- |
- /** |
- * Return the type of this element as the dynamic type. |
- */ |
- DartType get type; |
-} |
- |
-/** |
* A concrete implementation of a [MultiplyDefinedElement]. |
*/ |
class MultiplyDefinedElementImpl implements MultiplyDefinedElement { |
@@ -8683,18 +6352,6 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement { |
} |
/** |
- * An [ExecutableElement], with the additional information of a list of |
- * [ExecutableElement]s from which this element was composed. |
- */ |
-abstract class MultiplyInheritedExecutableElement implements ExecutableElement { |
- /** |
- * Return a list containing all of the executable elements defined within this |
- * executable element. |
- */ |
- List<ExecutableElement> get inheritedElements; |
-} |
- |
-/** |
* A [MethodElementImpl], with the additional information of a list of |
* [ExecutableElement]s from which this element was composed. |
*/ |
@@ -8745,66 +6402,6 @@ class MultiplyInheritedPropertyAccessorElementImpl |
} |
/** |
- * An object that controls how namespaces are combined. |
- */ |
-abstract class NamespaceCombinator { |
- /** |
- * An empty list of namespace combinators. |
- */ |
- static const List<NamespaceCombinator> EMPTY_LIST = |
- const <NamespaceCombinator>[]; |
-} |
- |
-/** |
- * A parameter defined within an executable element. |
- */ |
-abstract class ParameterElement |
- implements LocalElement, VariableElement, ConstantEvaluationTarget { |
- /** |
- * An empty list of parameter elements. |
- */ |
- static const List<ParameterElement> EMPTY_LIST = const <ParameterElement>[]; |
- |
- /** |
- * Return the Dart code of the default value, or `null` if no default value. |
- */ |
- String get defaultValueCode; |
- |
- /** |
- * Return `true` if this parameter is an initializing formal parameter. |
- */ |
- bool get isInitializingFormal; |
- |
- /** |
- * Return the kind of this parameter. |
- */ |
- ParameterKind get parameterKind; |
- |
- /** |
- * Return a list containing all of the parameters defined by this parameter. |
- * A parameter will only define other parameters if it is a function typed |
- * parameter. |
- */ |
- List<ParameterElement> get parameters; |
- |
- /** |
- * Return a list containing all of the type parameters defined by this |
- * parameter. A parameter will only define other parameters if it is a |
- * function typed parameter. |
- */ |
- List<TypeParameterElement> get typeParameters; |
- |
- /** |
- * Append the type, name and possibly the default value of this parameter to |
- * the given [buffer]. |
- */ |
- void appendToWithoutDelimiters(StringBuffer buffer); |
- |
- @override |
- FormalParameter computeNode(); |
-} |
- |
-/** |
* A concrete implementation of a [ParameterElement]. |
*/ |
class ParameterElementImpl extends VariableElementImpl |
@@ -9005,26 +6602,6 @@ abstract class ParameterElementMixin implements ParameterElement { |
} |
/** |
- * A type with type parameters, such as a class or function type alias. |
- */ |
-abstract class ParameterizedType implements DartType { |
- /** |
- * Return a list containing the actual types of the type arguments. If this |
- * type's element does not have type parameters, then the array should be |
- * empty (although it is possible for type arguments to be erroneously |
- * declared). If the element has type parameters and the actual type does not |
- * explicitly include argument values, then the type "dynamic" will be |
- * automatically provided. |
- */ |
- List<DartType> get typeArguments; |
- |
- /** |
- * Return a list containing all of the type parameters declared for this type. |
- */ |
- List<TypeParameterElement> get typeParameters; |
-} |
- |
-/** |
* A parameter element defined in a parameterized type where the values of the |
* type parameters are known. |
*/ |
@@ -9159,29 +6736,6 @@ class ParameterMember extends VariableMember |
} |
/** |
- * A prefix used to import one or more libraries into another library. |
- */ |
-abstract class PrefixElement implements Element { |
- /** |
- * An empty list of prefix elements. |
- */ |
- static const List<PrefixElement> EMPTY_LIST = const <PrefixElement>[]; |
- |
- /** |
- * Return the library into which other libraries are imported using this |
- * prefix. |
- */ |
- @override |
- LibraryElement get enclosingElement; |
- |
- /** |
- * Return a list containing all of the libraries that are imported using this |
- * prefix. |
- */ |
- List<LibraryElement> get importedLibraries; |
-} |
- |
-/** |
* A concrete implementation of a [PrefixElement]. |
*/ |
class PrefixElementImpl extends ElementImpl implements PrefixElement { |
@@ -9222,69 +6776,17 @@ class PrefixElementImpl extends ElementImpl implements PrefixElement { |
_importedLibraries = libraries; |
} |
- @override |
- ElementKind get kind => ElementKind.PREFIX; |
- |
- @override |
- accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); |
- |
- @override |
- void appendTo(StringBuffer buffer) { |
- buffer.write("as "); |
- super.appendTo(buffer); |
- } |
-} |
- |
-/** |
- * A getter or a setter. Note that explicitly defined property accessors |
- * implicitly define a synthetic field. Symmetrically, synthetic accessors are |
- * implicitly created for explicitly defined fields. The following rules apply: |
- * |
- * * Every explicit field is represented by a non-synthetic [FieldElement]. |
- * * Every explicit field induces a getter and possibly a setter, both of which |
- * are represented by synthetic [PropertyAccessorElement]s. |
- * * Every explicit getter or setter is represented by a non-synthetic |
- * [PropertyAccessorElement]. |
- * * Every explicit getter or setter (or pair thereof if they have the same |
- * name) induces a field that is represented by a synthetic [FieldElement]. |
- */ |
-abstract class PropertyAccessorElement implements ExecutableElement { |
- /** |
- * An empty list of property accessor elements. |
- */ |
- static const List<PropertyAccessorElement> EMPTY_LIST = |
- const <PropertyAccessorElement>[]; |
- |
- /** |
- * Return the accessor representing the getter that corresponds to (has the |
- * same name as) this setter, or `null` if this accessor is not a setter or if |
- * there is no corresponding getter. |
- */ |
- PropertyAccessorElement get correspondingGetter; |
- |
- /** |
- * Return the accessor representing the setter that corresponds to (has the |
- * same name as) this getter, or `null` if this accessor is not a getter or if |
- * there is no corresponding setter. |
- */ |
- PropertyAccessorElement get correspondingSetter; |
- |
- /** |
- * Return `true` if this accessor represents a getter. |
- */ |
- bool get isGetter; |
- |
- /** |
- * Return `true` if this accessor represents a setter. |
- */ |
- bool get isSetter; |
+ @override |
+ ElementKind get kind => ElementKind.PREFIX; |
- /** |
- * Return the field or top-level variable associated with this accessor. If |
- * this accessor was explicitly defined (is not synthetic) then the variable |
- * associated with it will be synthetic. |
- */ |
- PropertyInducingElement get variable; |
+ @override |
+ accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); |
+ |
+ @override |
+ void appendTo(StringBuffer buffer) { |
+ buffer.write("as "); |
+ super.appendTo(buffer); |
+ } |
} |
/** |
@@ -9497,7 +6999,7 @@ class PropertyAccessorMember extends ExecutableMember |
} |
builder.write(")"); |
if (type != null) { |
- builder.write(Element.RIGHT_ARROW); |
+ builder.write(ElementImpl.RIGHT_ARROW); |
builder.write(type.returnType); |
} |
return builder.toString(); |
@@ -9562,55 +7064,6 @@ class PropertyAccessorMember extends ExecutableMember |
} |
/** |
- * A variable that has an associated getter and possibly a setter. Note that |
- * explicitly defined variables implicitly define a synthetic getter and that |
- * non-`final` explicitly defined variables implicitly define a synthetic |
- * setter. Symmetrically, synthetic fields are implicitly created for explicitly |
- * defined getters and setters. The following rules apply: |
- * |
- * * Every explicit variable is represented by a non-synthetic |
- * [PropertyInducingElement]. |
- * * Every explicit variable induces a getter and possibly a setter, both of |
- * which are represented by synthetic [PropertyAccessorElement]s. |
- * * Every explicit getter or setter is represented by a non-synthetic |
- * [PropertyAccessorElement]. |
- * * Every explicit getter or setter (or pair thereof if they have the same |
- * name) induces a variable that is represented by a synthetic |
- * [PropertyInducingElement]. |
- */ |
-abstract class PropertyInducingElement implements VariableElement { |
- /** |
- * An empty list of elements. |
- */ |
- static const List<PropertyInducingElement> EMPTY_LIST = |
- const <PropertyInducingElement>[]; |
- |
- /** |
- * Return the getter associated with this variable. If this variable was |
- * explicitly defined (is not synthetic) then the getter associated with it |
- * will be synthetic. |
- */ |
- PropertyAccessorElement get getter; |
- |
- /** |
- * Return the propagated type of this variable, or `null` if type propagation |
- * has not been performed, for example because the variable is not final. |
- */ |
- DartType get propagatedType; |
- |
- /** |
- * Return the setter associated with this variable, or `null` if the variable |
- * is effectively `final` and therefore does not have a setter associated with |
- * it. (This can happen either because the variable is explicitly defined as |
- * being `final` or because the variable is induced by an explicit getter that |
- * does not have a corresponding setter.) If this variable was explicitly |
- * defined (is not synthetic) then the setter associated with it will be |
- * synthetic. |
- */ |
- PropertyAccessorElement get setter; |
-} |
- |
-/** |
* A concrete implementation of a [PropertyInducingElement]. |
*/ |
abstract class PropertyInducingElementImpl extends VariableElementImpl |
@@ -9646,156 +7099,6 @@ abstract class PropertyInducingElementImpl extends VariableElementImpl |
} |
/** |
- * A visitor that will recursively visit all of the element in an element model. |
- * For example, using an instance of this class to visit a |
- * [CompilationUnitElement] will also cause all of the types in the compilation |
- * unit to be visited. |
- * |
- * Subclasses that override a visit method must either invoke the overridden |
- * visit method or must explicitly ask the visited element to visit its |
- * children. Failure to do so will cause the children of the visited element to |
- * not be visited. |
- */ |
-class RecursiveElementVisitor<R> implements ElementVisitor<R> { |
- @override |
- R visitClassElement(ClassElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitCompilationUnitElement(CompilationUnitElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitConstructorElement(ConstructorElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitExportElement(ExportElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitFieldElement(FieldElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitFieldFormalParameterElement(FieldFormalParameterElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitFunctionElement(FunctionElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitImportElement(ImportElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitLabelElement(LabelElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitLibraryElement(LibraryElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitLocalVariableElement(LocalVariableElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitMethodElement(MethodElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitMultiplyDefinedElement(MultiplyDefinedElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitParameterElement(ParameterElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitPrefixElement(PrefixElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitPropertyAccessorElement(PropertyAccessorElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitTopLevelVariableElement(TopLevelVariableElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
- |
- @override |
- R visitTypeParameterElement(TypeParameterElement element) { |
- element.visitChildren(this); |
- return null; |
- } |
-} |
- |
-/** |
- * A combinator that cause some of the names in a namespace to be visible (and |
- * the rest hidden) when being imported. |
- */ |
-abstract class ShowElementCombinator implements NamespaceCombinator { |
- /** |
- * Return the offset of the character immediately following the last character |
- * of this node. |
- */ |
- int get end; |
- |
- /** |
- * Return the offset of the 'show' keyword of this element. |
- */ |
- int get offset; |
- |
- /** |
- * Return a list containing the names that are to be made visible in the |
- * importing library if they are defined in the imported library. |
- */ |
- List<String> get shownNames; |
-} |
- |
-/** |
* A concrete implementation of a [ShowElementCombinator]. |
*/ |
class ShowElementCombinatorImpl implements ShowElementCombinator { |
@@ -9832,86 +7135,6 @@ class ShowElementCombinatorImpl implements ShowElementCombinator { |
} |
/** |
- * A visitor that will do nothing when visiting an element. It is intended to be |
- * a superclass for classes that use the visitor pattern primarily as a dispatch |
- * mechanism (and hence don't need to recursively visit a whole structure) and |
- * that only need to visit a small number of element types. |
- */ |
-class SimpleElementVisitor<R> implements ElementVisitor<R> { |
- @override |
- R visitClassElement(ClassElement element) => null; |
- |
- @override |
- R visitCompilationUnitElement(CompilationUnitElement element) => null; |
- |
- @override |
- R visitConstructorElement(ConstructorElement element) => null; |
- |
- @override |
- R visitExportElement(ExportElement element) => null; |
- |
- @override |
- R visitFieldElement(FieldElement element) => null; |
- |
- @override |
- R visitFieldFormalParameterElement(FieldFormalParameterElement element) => |
- null; |
- |
- @override |
- R visitFunctionElement(FunctionElement element) => null; |
- |
- @override |
- R visitFunctionTypeAliasElement(FunctionTypeAliasElement element) => null; |
- |
- @override |
- R visitImportElement(ImportElement element) => null; |
- |
- @override |
- R visitLabelElement(LabelElement element) => null; |
- |
- @override |
- R visitLibraryElement(LibraryElement element) => null; |
- |
- @override |
- R visitLocalVariableElement(LocalVariableElement element) => null; |
- |
- @override |
- R visitMethodElement(MethodElement element) => null; |
- |
- @override |
- R visitMultiplyDefinedElement(MultiplyDefinedElement element) => null; |
- |
- @override |
- R visitParameterElement(ParameterElement element) => null; |
- |
- @override |
- R visitPrefixElement(PrefixElement element) => null; |
- |
- @override |
- R visitPropertyAccessorElement(PropertyAccessorElement element) => null; |
- |
- @override |
- R visitTopLevelVariableElement(TopLevelVariableElement element) => null; |
- |
- @override |
- R visitTypeParameterElement(TypeParameterElement element) => null; |
-} |
- |
-/** |
- * A top-level variable. |
- */ |
-abstract class TopLevelVariableElement implements PropertyInducingElement { |
- /** |
- * An empty list of top-level variable elements. |
- */ |
- static const List<TopLevelVariableElement> EMPTY_LIST = |
- const <TopLevelVariableElement>[]; |
- |
- @override |
- VariableDeclaration computeNode(); |
-} |
- |
-/** |
* A concrete implementation of a [TopLevelVariableElement]. |
*/ |
class TopLevelVariableElementImpl extends PropertyInducingElementImpl |
@@ -9943,16 +7166,6 @@ class TopLevelVariableElementImpl extends PropertyInducingElementImpl |
} |
/** |
- * An element that defines a type. |
- */ |
-abstract class TypeDefiningElement implements Element { |
- /** |
- * Return the type defined by this element. |
- */ |
- DartType get type; |
-} |
- |
-/** |
* The abstract class `TypeImpl` implements the behavior common to objects |
* representing the declared type of elements in the element model. |
*/ |
@@ -10000,7 +7213,7 @@ abstract class TypeImpl implements DartType { |
/** |
* Append a textual representation of this type to the given [buffer]. The set |
- * of [visitedTypes] is used to prevent infinite recusion. |
+ * of [visitedTypes] is used to prevent infinite recursion. |
*/ |
void appendTo(StringBuffer buffer) { |
if (name == null) { |
@@ -10150,28 +7363,6 @@ abstract class TypeImpl implements DartType { |
} |
/** |
- * A type parameter. |
- */ |
-abstract class TypeParameterElement implements TypeDefiningElement { |
- /** |
- * An empty list of type parameter elements. |
- */ |
- static const List<TypeParameterElement> EMPTY_LIST = |
- const <TypeParameterElement>[]; |
- |
- /** |
- * Return the type representing the bound associated with this parameter, or |
- * `null` if this parameter does not have an explicit bound. |
- */ |
- DartType get bound; |
- |
- /** |
- * Return the type defined by this type parameter. |
- */ |
- TypeParameterType get type; |
-} |
- |
-/** |
* A concrete implementation of a [TypeParameterElement]. |
*/ |
class TypeParameterElementImpl extends ElementImpl |
@@ -10215,33 +7406,6 @@ class TypeParameterElementImpl extends ElementImpl |
} |
/** |
- * An element that has type parameters. |
- * |
- * For example, a class or a typedef. This also includes functions and methods |
- * if support for generic methods is enabled. |
- */ |
-abstract class TypeParameterizedElement implements Element { |
- /** |
- * Return a list containing all of the type parameters declared for this |
- * class. |
- */ |
- List<TypeParameterElement> get typeParameters; |
-} |
- |
-/** |
- * The type introduced by a type parameter. |
- */ |
-abstract class TypeParameterType implements DartType { |
- /** |
- * An empty list of type parameter types. |
- */ |
- static const List<TypeParameterType> EMPTY_LIST = const <TypeParameterType>[]; |
- |
- @override |
- TypeParameterElement get element; |
-} |
- |
-/** |
* A concrete implementation of a [TypeParameterType]. |
*/ |
class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { |
@@ -10354,16 +7518,8 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { |
} |
/** |
- * A pseudo-elements that represents names that are undefined. This situation is |
- * not allowed by the language, so objects implementing this interface always |
- * represent an error. As a result, most of the normal operations on elements do |
- * not make sense and will return useless results. |
- */ |
-abstract class UndefinedElement implements Element {} |
- |
-/** |
* The unique instance of the class `UndefinedTypeImpl` implements the type of |
- * typenames that couldn't be resolved. |
+ * type names that couldn't be resolved. |
* |
* This class behaves like DynamicTypeImpl in almost every respect, to reduce |
* cascading errors. |
@@ -10432,29 +7588,6 @@ class UndefinedTypeImpl extends TypeImpl { |
} |
/** |
- * An element included into a library using some URI. |
- */ |
-abstract class UriReferencedElement implements Element { |
- /** |
- * Return the URI that is used to include this element into the enclosing |
- * library, or `null` if this is the defining compilation unit of a library. |
- */ |
- String get uri; |
- |
- /** |
- * Return the offset of the character immediately following the last character |
- * of this node's URI, or `-1` for synthetic import. |
- */ |
- int get uriEnd; |
- |
- /** |
- * Return the offset of the URI in the file, or `-1` if this element is |
- * synthetic. |
- */ |
- int get uriOffset; |
-} |
- |
-/** |
* A concrete implementation of a [UriReferencedElement]. |
*/ |
abstract class UriReferencedElementImpl extends ElementImpl |
@@ -10476,94 +7609,13 @@ abstract class UriReferencedElementImpl extends ElementImpl |
String uri; |
/** |
- * Initialize a newly created import element to heve the given [name] and |
+ * Initialize a newly created import element to have the given [name] and |
* [offset]. The offset may be `-1` if the element is synthetic. |
*/ |
UriReferencedElementImpl(String name, int offset) : super(name, offset); |
} |
/** |
- * A variable. There are concrete subclasses for different kinds of variables. |
- */ |
-abstract class VariableElement implements Element, ConstantEvaluationTarget { |
- /** |
- * An empty list of variable elements. |
- */ |
- static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; |
- |
- /** |
- * Return a representation of the value of this variable. |
- * |
- * Return `null` if either this variable was not declared with the 'const' |
- * modifier or if the value of this variable could not be computed because of |
- * errors. |
- */ |
- DartObject get constantValue; |
- |
- /** |
- * Return `true` if this variable element did not have an explicit type |
- * specified for it. |
- */ |
- bool get hasImplicitType; |
- |
- /** |
- * Return a synthetic function representing this variable's initializer, or |
- * `null` if this variable does not have an initializer. The function will |
- * have no parameters. The return type of the function will be the |
- * compile-time type of the initialization expression. |
- */ |
- FunctionElement get initializer; |
- |
- /** |
- * Return `true` if this variable was declared with the 'const' modifier. |
- */ |
- bool get isConst; |
- |
- /** |
- * Return `true` if this variable was declared with the 'final' modifier. |
- * Variables that are declared with the 'const' modifier will return `false` |
- * even though they are implicitly final. |
- */ |
- bool get isFinal; |
- |
- /** |
- * Return `true` if this variable is potentially mutated somewhere in a |
- * closure. This information is only available for local variables (including |
- * parameters) and only after the compilation unit containing the variable has |
- * been resolved. |
- */ |
- bool get isPotentiallyMutatedInClosure; |
- |
- /** |
- * Return `true` if this variable is potentially mutated somewhere in its |
- * scope. This information is only available for local variables (including |
- * parameters) and only after the compilation unit containing the variable has |
- * been resolved. |
- */ |
- bool get isPotentiallyMutatedInScope; |
- |
- /** |
- * Return `true` if this element is a static variable, as per section 8 of the |
- * Dart Language Specification: |
- * |
- * > A static variable is a variable that is not associated with a particular |
- * > instance, but rather with an entire library or class. Static variables |
- * > include library variables and class variables. Class variables are |
- * > variables whose declaration is immediately nested inside a class |
- * > declaration and includes the modifier static. A library variable is |
- * > implicitly static. |
- */ |
- bool get isStatic; |
- |
- /** |
- * Return the declared type of this variable, or `null` if the variable did |
- * not have a declared type (such as if it was declared using the keyword |
- * 'var'). |
- */ |
- DartType get type; |
-} |
- |
-/** |
* A concrete implementation of a [VariableElement]. |
*/ |
abstract class VariableElementImpl extends ElementImpl |