Move API declarations of elements into src/, re-export.
In following CLs I plan to add `final` and `sealed` modifiers.
Change-Id: Ia6b9091034ed9f8f6f8576dbe6029d7e72a9d6b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315249
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart b/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
index 87e141e..325fb9a 100644
--- a/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
+++ b/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
@@ -7,7 +7,6 @@
import 'package:analysis_server/src/utilities/extensions/ast.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
index cc69056..997b794 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
@@ -11,7 +11,6 @@
import 'package:analysis_server/src/protocol_server.dart' show NavigationTarget;
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart' as protocol;
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart
index 69a2ca1..0c95b2d 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart
@@ -8,7 +8,6 @@
import 'package:analysis_server/src/utilities/flutter.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/source/source_range.dart';
import 'package:analyzer/src/dart/analysis/session_helper.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart
index ca72f42..9238fce 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart
@@ -8,7 +8,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/element.dart' as analyzer;
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
diff --git a/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_local.dart b/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_local.dart
index 70ad3f7..2d66735 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_local.dart
@@ -14,7 +14,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/source.dart';
diff --git a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
index 3d96567..eafed50 100644
--- a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
+++ b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/search/search_engine.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/search.dart';
diff --git a/pkg/analysis_server/lib/src/status/element_writer.dart b/pkg/analysis_server/lib/src/status/element_writer.dart
index 0959bd1..1cd365f 100644
--- a/pkg/analysis_server/lib/src/status/element_writer.dart
+++ b/pkg/analysis_server/lib/src/status/element_writer.dart
@@ -5,7 +5,6 @@
import 'dart:convert';
import 'package:analysis_server/src/status/tree_writer.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analysis_server/lib/src/status/tree_writer.dart b/pkg/analysis_server/lib/src/status/tree_writer.dart
index a1fe248..7a09228 100644
--- a/pkg/analysis_server/lib/src/status/tree_writer.dart
+++ b/pkg/analysis_server/lib/src/status/tree_writer.dart
@@ -4,7 +4,6 @@
import 'dart:convert';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/source.dart';
diff --git a/pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart b/pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart
index 32e2ad3..737285c 100644
--- a/pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart
@@ -11,7 +11,6 @@
show ArgumentsTrailingComma;
import 'package:analysis_server/src/services/search/search_engine_internal.dart';
import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/source/source_range.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 7699ce3..57c40f4 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -36,898 +36,80 @@
/// represented by an element.
library;
-import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/analysis/session.dart';
-import 'package:analyzer/dart/constant/value.dart';
-import 'package:analyzer/dart/element/nullability_suffix.dart';
-import 'package:analyzer/dart/element/scope.dart';
-import 'package:analyzer/dart/element/type.dart';
-import 'package:analyzer/dart/element/type_provider.dart';
-import 'package:analyzer/dart/element/type_system.dart';
-import 'package:analyzer/error/error.dart';
-import 'package:analyzer/src/dart/constant/evaluation.dart';
-import 'package:analyzer/src/dart/resolver/scope.dart' show Namespace;
-import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/utilities_dart.dart';
-import 'package:analyzer/src/task/api/model.dart' show AnalysisTarget;
-import 'package:meta/meta.dart';
+import 'package:analyzer/src/dart/element/element.dart';
import 'package:pub_semver/pub_semver.dart';
-/// A library augmentation import directive within a library.
-///
-/// Clients may not extend, implement or mix-in this class.
-@experimental
-abstract class AugmentationImportElement implements _ExistingElement {
- @Deprecated('Use enclosingElement2 instead')
- @override
- LibraryOrAugmentationElement get enclosingElement;
-
- @override
- LibraryOrAugmentationElement get enclosingElement2;
-
- /// The [LibraryAugmentationElement], if [uri] is a
- /// [DirectiveUriWithAugmentation].
- LibraryAugmentationElement? get importedAugmentation;
-
- /// The offset of the `import` keyword.
- int get importKeywordOffset;
-
- /// The interpretation of the URI specified in the directive.
- DirectiveUri get uri;
-}
-
-/// The result of applying augmentations to a [ClassElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedClassElement implements AugmentedInterfaceElement {
- @override
- ClassElement get declaration;
-}
-
-/// The result of applying augmentations to an [EnumElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedEnumElement implements AugmentedInterfaceElement {}
-
-/// The result of applying augmentations to an [ExtensionElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedExtensionElement implements AugmentedInstanceElement {}
-
-/// The result of applying augmentations to an [InlineClassElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedInlineClassElement
- implements AugmentedNamedInstanceElement {}
-
-/// The result of applying augmentations to a [InstanceElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedInstanceElement {
- /// The accessors (getters and setters) declared in this element.
- ///
- /// [PropertyAccessorElement]s replace corresponding elements,
- /// other [PropertyAccessorElement]s are appended.
- List<PropertyAccessorElement> get accessors;
-
- /// The declaration (not augmentation) that owns this result.
- InstanceElement get declaration;
-
- /// The fields declared in this element.
- ///
- /// [FieldAugmentationElement]s replace corresponding elements, other
- /// [FieldElement]s are appended.
- List<FieldElement> get fields;
-
- /// The metadata associated with this element.
- ///
- /// This is a union of annotations associated with the class declaration and
- /// all its augmentations.
- List<ElementAnnotation> get metadata;
-
- /// The methods declared in this element.
- ///
- /// [MethodAugmentationElement]s replace corresponding elements, other
- /// [MethodElement]s are appended.
- List<MethodElement> get methods;
-
- /// Returns the field from [fields] that has the given [name].
- FieldElement? getField(String name);
-
- /// Returns the getter from [accessors] that has the given [name].
- PropertyAccessorElement? getGetter(String name);
-
- /// Returns the method from [methods] that has the given [name].
- MethodElement? getMethod(String name);
-
- /// Returns the setter from [accessors] that has the given [name].
- PropertyAccessorElement? getSetter(String name);
-}
-
-/// The result of applying augmentations to a [InterfaceElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedInterfaceElement
- implements AugmentedNamedInstanceElement {
- @override
- InterfaceElement get declaration;
-
- /// The interfaces implemented by this element.
- ///
- /// This is a union of interfaces declared by the class declaration and
- /// all its augmentations.
- List<InterfaceType> get interfaces;
-
- /// The mixins applied by this class or in its augmentations.
- ///
- /// This is a union of mixins applied by the class declaration and all its
- /// augmentations.
- List<InterfaceType> get mixins;
-}
-
-/// The result of applying augmentations to a [MixinElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedMixinElement extends AugmentedInterfaceElement {
- /// The superclass constraints of this element.
- ///
- /// This is a union of constraints declared by the class declaration and
- /// all its augmentations.
- List<InterfaceType> get superclassConstraints;
-}
-
-/// The result of applying augmentations to a [NamedInstanceElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class AugmentedNamedInstanceElement
- implements AugmentedInstanceElement {
- /// The constructors declared in this element.
- ///
- /// [ConstructorAugmentationElement]s replace corresponding elements,
- /// other [ConstructorElement]s are appended.
- List<ConstructorElement> get constructors;
-
- @override
- NamedInstanceElement get declaration;
-
- /// The unnamed constructor from [constructors].
- ConstructorElement? get unnamedConstructor;
-
- /// Returns the constructor from [constructors] that has the given [name].
- ConstructorElement? getNamedConstructor(String name);
-}
-
-/// A pattern variable that is explicitly declared.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class BindPatternVariableElement implements PatternVariableElement {}
-
-/// An element that represents a class or a mixin. The class can be defined by
-/// either a class declaration (with a class body), a mixin application (without
-/// a class body), a mixin declaration, or an enum declaration.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ClassElement implements InterfaceElement {
- @experimental
- @override
- ClassElement? get augmentation;
-
- @experimental
- @override
- ClassElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedClassElement? get augmented;
-
- /// Whether the class or its superclass declares a non-final instance field.
- bool get hasNonFinalField;
-
- /// Whether the 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;
-
- /// Whether this class is a base class.
- ///
- /// A class is a base class if it has an explicit `base` modifier, or the
- /// class has a `base` induced modifier and [isSealed] is `true` as well.
- /// The base modifier allows the class to be extended but not implemented.
- bool get isBase;
-
- /// Whether the class can be instantiated.
- bool get isConstructable;
-
- /// Whether the class represents the class 'Enum' defined in `dart:core`.
- bool get isDartCoreEnum;
-
- /// Whether the class represents the class 'Object' defined in `dart:core`.
- bool get isDartCoreObject;
-
- /// Whether the class has the property where, in a switch, if you cover all
- /// of the subtypes of this element, then the compiler knows that you have
- /// covered all possible instances of the type.
- bool get isExhaustive;
-
- /// Whether the class is a final class.
- ///
- /// A class is a final class if it has an explicit `final` modifier, or the
- /// class has a `final` induced modifier and [isSealed] is `true` as well.
- /// The final modifier prohibits this class from being extended, implemented,
- /// or mixed in.
- bool get isFinal;
-
- /// Whether the class is an inline class.
- ///
- /// A class is an inline class if it has an explicit `inline` modifier.
- @experimental
- bool get isInline;
-
- /// Whether the class is an interface class.
- ///
- /// A class is an interface class if it has an explicit `interface` modifier,
- /// or the class has an `interface` induced modifier and [isSealed] is `true`
- /// as well. The interface modifier allows the class to be implemented, but
- /// not extended or mixed in.
- bool get isInterface;
-
- /// Whether the 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;
-
- /// Whether the class is a mixin class.
- ///
- /// A class is a mixin class if it has an explicit `mixin` modifier.
- bool get isMixinClass;
-
- /// Whether the class is a sealed class.
- ///
- /// A class is a sealed class if it has an explicit `sealed` modifier.
- bool get isSealed;
-
- /// Whether the class can validly be used as a mixin when defining
- /// another class.
- ///
- /// For classes defined by a class declaration or a mixin application, 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;
-
- /// Whether the class, assuming that it is within scope, is extendable to
- /// classes in the given [library].
- bool isExtendableIn(LibraryElement library);
-
- /// Whether the class, assuming that it is within scope, is
- /// implementable to classes, mixins, and enums in the given [library].
- bool isImplementableIn(LibraryElement library);
-
- /// Whether the class, assuming that it is within scope, is able to be
- /// mixed-in by classes and enums in the given [library].
- bool isMixableIn(LibraryElement library);
-}
-
-/// An element that is contained within a [ClassElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ClassMemberElement implements Element {
- // TODO(brianwilkerson) Either remove this class or rename it to something
- // more correct.
-
- @Deprecated('Use enclosingElement2 instead')
- @override
- Element get enclosingElement;
-
- @override
- Element get enclosingElement2;
-
- /// Whether the 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.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class CompilationUnitElement implements UriReferencedElement {
- /// The top-level accessors (getters and setters) declared in this
- /// compilation unit.
- List<PropertyAccessorElement> get accessors;
-
- /// The classes declared in this compilation unit.
- List<ClassElement> get classes;
-
- /// The library, or library augmentation that encloses this unit.
- @Deprecated('Use enclosingElement2 instead')
- @override
- LibraryOrAugmentationElement get enclosingElement;
-
- /// The library, or library augmentation that encloses this unit.
- @override
- LibraryOrAugmentationElement get enclosingElement2;
-
- /// The enums declared in this compilation unit.
- List<EnumElement> get enums;
-
- /// The extensions declared in this compilation unit.
- List<ExtensionElement> get extensions;
-
- /// The top-level functions declared in this compilation unit.
- List<FunctionElement> get functions;
-
- /// The [LineInfo] for the [source].
- LineInfo get lineInfo;
-
- /// The mixins declared in this compilation unit.
- List<MixinElement> get mixins;
-
- @override
- AnalysisSession get session;
-
- /// The top-level variables declared in this compilation unit.
- List<TopLevelVariableElement> get topLevelVariables;
-
- /// The type aliases declared in this compilation unit.
- List<TypeAliasElement> get typeAliases;
-
- /// Returns 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? getClass(String name);
-
- /// Returns 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.
- EnumElement? getEnum(String name);
-}
-
-/// An element representing a constructor or a factory method defined within a
-/// class.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ConstructorElement
- implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget {
- @experimental
- @override
- ConstructorElement? get augmentation;
-
- @experimental
- @override
- ConstructorElement? get augmentationTarget;
-
- @override
- ConstructorElement get declaration;
-
- @override
- String get displayName;
-
- @Deprecated('Use enclosingElement2 instead')
- @override
- InterfaceElement get enclosingElement;
-
- @override
- NamedInstanceElement get enclosingElement2;
-
- /// Whether the constructor is a const constructor.
- bool get isConst;
-
- /// Whether the constructor can be used as a default constructor - unnamed,
- /// and has no required parameters.
- bool get isDefaultConstructor;
-
- /// Whether the constructor represents a factory constructor.
- bool get isFactory;
-
- /// Whether the constructor represents a generative constructor.
- bool get isGenerative;
-
- @override
- String get name;
-
- /// The offset of the character immediately following the last character of
- /// this constructor's name, or `null` if not named.
- ///
- /// TODO(migration): encapsulate [nameEnd] and [periodOffset]?
- int? get nameEnd;
-
- /// The offset of the `.` before this constructor name, or `null` if not
- /// named.
- int? get periodOffset;
-
- /// 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;
-
- @Deprecated('Use returnType2 instead')
- @override
- InterfaceType get returnType;
-
- @override
- DartType get returnType2;
-}
-
-/// [ImportElementPrefix] that is used together with `deferred`.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DeferredImportElementPrefix implements ImportElementPrefix {}
-
-/// Meaning of a URI referenced in a directive.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUri {}
-
-/// [DirectiveUriWithSource] that references a [LibraryAugmentationElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUriWithAugmentation extends DirectiveUriWithSource {
- /// The library augmentation referenced by the [source].
- LibraryAugmentationElement get augmentation;
-}
-
-/// [DirectiveUriWithSource] that references a [LibraryElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUriWithLibrary extends DirectiveUriWithSource {
- /// The library referenced by the [source].
- LibraryElement get library;
-}
-
-/// [DirectiveUriWithRelativeUriString] that can be parsed into a relative URI.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUriWithRelativeUri
- extends DirectiveUriWithRelativeUriString {
- /// The relative URI, parsed from [relativeUriString].
- Uri get relativeUri;
-}
-
-/// [DirectiveUri] for which we can get its relative URI string.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUriWithRelativeUriString extends DirectiveUri {
- /// The relative URI string specified in code.
- String get relativeUriString;
-}
-
-/// [DirectiveUriWithRelativeUri] that resolves to a [Source].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUriWithSource extends DirectiveUriWithRelativeUri {
- /// The result of resolving [relativeUri] against the enclosing URI.
- Source get source;
-}
-
-/// [DirectiveUriWithSource] that references a [CompilationUnitElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class DirectiveUriWithUnit extends DirectiveUriWithSource {
- /// The unit referenced by the [source].
- CompilationUnitElement get unit;
-}
-
-/// 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.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class Element implements AnalysisTarget {
- /// A list of this element's children.
- ///
- /// There is no guarantee of the order in which the children will be included.
- List<Element> get children;
-
- /// The analysis context in which this element is defined.
- AnalysisContext get context;
-
- /// The declaration of this element.
- ///
- /// If the element is a view on an element, e.g. a method from an interface
- /// type, with substituted type parameters, return the corresponding element
- /// from the class, without any substitutions. If this element is already a
- /// declaration (or a synthetic element, e.g. a synthetic property accessor),
- /// return itself.
- Element? get declaration;
-
- /// The display name of this element, possibly the empty string if the
- /// 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;
-
- /// The content of the documentation comment (including delimiters) for this
- /// element, or `null` if this element does not or cannot have documentation.
- String? get documentationComment;
-
- /// 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.
- @Deprecated('Use enclosingElement2 instead')
- Element? get enclosingElement;
-
- /// 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 enclosingElement2;
-
- /// Whether the element has an annotation of the form `@alwaysThrows`.
- bool get hasAlwaysThrows;
-
- /// Whether the element has an annotation of the form `@deprecated`
- /// or `@Deprecated('..')`.
- bool get hasDeprecated;
-
- /// Whether the element has an annotation of the form `@doNotStore`.
- bool get hasDoNotStore;
-
- /// Whether the element has an annotation of the form `@factory`.
- bool get hasFactory;
-
- /// Whether the element has an annotation of the form `@internal`.
- bool get hasInternal;
-
- /// Whether the element has an annotation of the form `@isTest`.
- bool get hasIsTest;
-
- /// Whether the element has an annotation of the form `@isTestGroup`.
- bool get hasIsTestGroup;
-
- /// Whether the element has an annotation of the form `@JS(..)`.
- bool get hasJS;
-
- /// Whether the element has an annotation of the form `@literal`.
- bool get hasLiteral;
-
- /// Whether the element has an annotation of the form `@mustBeOverridden`.
- bool get hasMustBeOverridden;
-
- /// Whether the element has an annotation of the form `@mustCallSuper`.
- bool get hasMustCallSuper;
-
- /// Whether the element has an annotation of the form `@nonVirtual`.
- bool get hasNonVirtual;
-
- /// Whether the element has an annotation of the form `@optionalTypeArgs`.
- bool get hasOptionalTypeArgs;
-
- /// Whether the element has an annotation of the form `@override`.
- bool get hasOverride;
-
- /// Whether the element has an annotation of the form `@protected`.
- bool get hasProtected;
-
- /// Whether the element has an annotation of the form `@reopen`.
- bool get hasReopen;
-
- /// Whether the element has an annotation of the form `@required`.
- bool get hasRequired;
-
- /// Whether the element has an annotation of the form `@sealed`.
- bool get hasSealed;
-
- /// Whether the element has an annotation of the form `@useResult`
- /// or `@UseResult('..')`.
- bool get hasUseResult;
-
- /// Whether the element has an annotation of the form `@visibleForOverriding`.
- bool get hasVisibleForOverriding;
-
- /// Whether the element has an annotation of the form `@visibleForTemplate`.
- bool get hasVisibleForTemplate;
-
- /// Whether the element has an annotation of the form `@visibleForTesting`.
- bool get hasVisibleForTesting;
-
- /// Whether the element has an annotation of the form
- /// `@visibleOutsideTemplate`.
- bool get hasVisibleOutsideTemplate;
-
- /// The unique integer identifier of this element.
- int get id;
-
- /// Whether the element is private.
- ///
- /// Private elements are visible only within the library in which they are
- /// declared.
- bool get isPrivate;
-
- /// Whether the element is public.
- ///
- /// Public elements are visible within any library that imports the library
- /// in which they are declared.
- bool get isPublic;
-
- /// Whether the 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;
-
- /// The kind of element that this is.
- ElementKind get kind;
-
- /// Tibrary that contains this element.
- ///
- /// This will be the element itself if it is a library element. This will be
- /// `null` if this element is [MultiplyDefinedElement] that is not contained
- /// in a library.
- LibraryElement? get library;
-
- /// 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;
-
- /// 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;
-
- /// The name of this element, or `null` if this element does not have a name.
- String? get name;
-
- /// 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;
-
- /// 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;
-
- /// The non-synthetic element that caused this element to be created.
- ///
- /// If this element is not synthetic, then the element itself is returned.
- ///
- /// If this element is synthetic, then the corresponding non-synthetic
- /// element is returned. For example, for a synthetic getter of a
- /// non-synthetic field the field is returned; for a synthetic constructor
- /// the enclosing class is returned.
- Element get nonSynthetic;
-
- /// The analysis session in which this element is defined.
- AnalysisSession? get session;
-
- /// The version where this SDK API was added.
- ///
- /// A `@Since()` annotation can be applied to a library declaration,
- /// any public declaration in a library, or in a class, or to an optional
- /// parameter, etc.
- ///
- /// The returned version is "effective", so that if a library is annotated
- /// then all elements of the library inherit it; or if a class is annotated
- /// then all members and constructors of the class inherit it.
- ///
- /// If multiple `@Since()` annotations apply to the same element, the latest
- /// version takes precedence.
- ///
- /// Returns `null` if the element is not declared in SDK, or does not have
- /// a `@Since()` annotation applicable to it.
- Version? get sinceSdkVersion;
-
- @override
- Source? get source;
-
- /// Uses the given [visitor] to visit this element.
- ///
- /// Returns the value returned by the visitor as a result of visiting this
- /// element.
- T? accept<T>(ElementVisitor<T> visitor);
-
- /// Returns the presentation of this element as it should appear when
- /// presented to users.
- ///
- /// If [withNullability] is `true`, then [NullabilitySuffix.question] and
- /// [NullabilitySuffix.star] in types will be represented as `?` and `*`.
- /// [NullabilitySuffix.none] does not have any explicit presentation.
- ///
- /// If [withNullability] is `false`, nullability suffixes will not be
- /// included into the presentation.
- ///
- /// If [multiline] is `true`, the string may be wrapped over multiple lines
- /// with newlines to improve formatting. For example function signatures may
- /// be formatted as if they had trailing commas.
- ///
- /// Clients should not depend on the content of the returned value as it will
- /// be changed if doing so would improve the UX.
- String getDisplayString({
- required bool withNullability,
- bool multiline = false,
- });
-
- /// Returns 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 [displayName] 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);
-
- /// Whether the 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 6.2:
- /// <blockquote>
- /// A declaration <i>m</i> is accessible to a 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);
-
- /// Returns either this element or the most immediate ancestor of this element
- /// for which the [predicate] returns `true`, or `null` if there is no such
- /// element.
- E? thisOrAncestorMatching<E extends Element>(
- bool Function(Element) predicate,
- );
-
- /// Returns either this element or the most immediate ancestor of this element
- /// that has the given type, or `null` if there is no such element.
- E? thisOrAncestorOfType<E extends Element>();
-
- /// Uses 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.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ElementAnnotation implements ConstantEvaluationTarget {
- /// The errors that were produced while computing a value for this
- /// annotation, or `null` if no value has been computed.
- ///
- /// If a value has been produced but no errors were generated, then the
- /// list will be empty.
- List<AnalysisError>? get constantEvaluationErrors;
-
- /// Returns the element referenced by this annotation.
- ///
- /// In valid code this element can be a [PropertyAccessorElement] getter
- /// of a constant top-level variable, or a constant static field of a
- /// class; or a constant [ConstructorElement].
- ///
- /// In invalid code this element can be `null`, or a reference to any
- /// other element.
- Element? get element;
-
- /// Whether the annotation marks the associated function as always throwing.
- bool get isAlwaysThrows;
-
- /// Whether the annotation marks the associated element as being deprecated.
- bool get isDeprecated;
-
- /// Whether the annotation marks the associated element as not to be stored.
- bool get isDoNotStore;
-
- /// Whether the annotation marks the associated member as a factory.
- bool get isFactory;
-
- /// Whether the annotation marks the associated class and its subclasses as
- /// being immutable.
- bool get isImmutable;
-
- /// Whether the annotation marks the associated element as being internal to
- /// its package.
- bool get isInternal;
-
- /// Whether the annotation marks the associated member as running a single
- /// test.
- bool get isIsTest;
-
- /// Whether the annotation marks the associated member as running a test
- /// group.
- bool get isIsTestGroup;
-
- /// Whether the annotation marks the associated element with the `JS`
- /// annotation.
- bool get isJS;
-
- /// Whether the annotation marks the associated constructor as being literal.
- bool get isLiteral;
-
- /// Whether the annotation marks the associated member as requiring
- /// subclasses to override this member.
- bool get isMustBeOverridden;
-
- /// Whether the annotation marks the associated member as requiring
- /// overriding methods to call super.
- bool get isMustCallSuper;
-
- /// Whether the annotation marks the associated member as being non-virtual.
- bool get isNonVirtual;
-
- /// Whether the annotation marks the associated type as having "optional"
- /// type arguments.
- bool get isOptionalTypeArgs;
-
- /// Whether the annotation marks the associated method as being expected to
- /// override an inherited method.
- bool get isOverride;
-
- /// Whether the annotation marks the associated member as being protected.
- bool get isProtected;
-
- /// Whether the annotation marks the associated class as implementing a proxy
- /// object.
- bool get isProxy;
-
- /// Whether the marks the associated member as being reopened.
- bool get isReopen;
-
- /// Whether the annotation marks the associated member as being required.
- bool get isRequired;
-
- /// Whether the annotation marks the associated class as being sealed.
- bool get isSealed;
-
- /// Whether the annotation marks the associated class as being intended to
- /// be used as an annotation.
- bool get isTarget;
-
- /// Whether the annotation marks the associated returned element as
- /// requiring use.
- bool get isUseResult;
-
- /// Whether the annotation marks the associated member as being visible for
- /// overriding only.
- bool get isVisibleForOverriding;
-
- /// Whether the annotation marks the associated member as being visible for
- /// template files.
- bool get isVisibleForTemplate;
-
- /// Whether the annotation marks the associated member as being visible for
- /// testing.
- bool get isVisibleForTesting;
-
- /// Whether the annotation marks the associated member as being visible
- /// outside of template files.
- bool get isVisibleOutsideTemplate;
-
- /// Returns a representation of the value of this annotation, forcing the
- /// value to be computed if it had not previously been computed, or `null`
- /// if the value of this annotation could not be computed because of errors.
- DartObject? computeConstantValue();
-
- /// Returns a textual description of this annotation in a form approximating
- /// valid source.
- ///
- /// The returned string will not be valid source primarily in the case where
- /// the annotation itself is not well-formed.
- String toSource();
-}
+export 'package:analyzer/src/dart/element/element.dart'
+ show
+ AugmentationImportElement,
+ AugmentedClassElement,
+ AugmentedEnumElement,
+ AugmentedExtensionElement,
+ AugmentedInlineClassElement,
+ AugmentedInstanceElement,
+ AugmentedInterfaceElement,
+ AugmentedMixinElement,
+ AugmentedNamedInstanceElement,
+ BindPatternVariableElement,
+ ClassElement,
+ ClassMemberElement,
+ CompilationUnitElement,
+ ConstructorElement,
+ DeferredImportElementPrefix,
+ DirectiveUri,
+ DirectiveUriWithAugmentation,
+ DirectiveUriWithLibrary,
+ DirectiveUriWithRelativeUri,
+ DirectiveUriWithRelativeUriString,
+ DirectiveUriWithSource,
+ DirectiveUriWithUnit,
+ Element,
+ ElementAnnotation,
+ EnumElement,
+ ExecutableElement,
+ ExtensionElement,
+ FieldElement,
+ FieldFormalParameterElement,
+ FunctionElement,
+ FunctionTypedElement,
+ GenericFunctionTypeElement,
+ HideElementCombinator,
+ ImportElementPrefix,
+ InlineClassElement,
+ InstanceElement,
+ InterfaceElement,
+ JoinPatternVariableElement,
+ LabelElement,
+ LibraryAugmentationElement,
+ LibraryElement,
+ LibraryExportElement,
+ LibraryImportElement,
+ LibraryOrAugmentationElement,
+ LocalElement,
+ LocalVariableElement,
+ MethodElement,
+ MixinElement,
+ MultiplyDefinedElement,
+ MultiplyInheritedExecutableElement,
+ NamedInstanceElement,
+ NamespaceCombinator,
+ ParameterElement,
+ PartElement,
+ PatternVariableElement,
+ PrefixElement,
+ PromotableElement,
+ PropertyAccessorElement,
+ PropertyInducingElement,
+ ShowElementCombinator,
+ SuperFormalParameterElement,
+ TopLevelVariableElement,
+ TypeAliasElement,
+ TypeDefiningElement,
+ TypeParameterElement,
+ TypeParameterizedElement,
+ UndefinedElement,
+ UriReferencedElement,
+ VariableElement;
/// The kind of elements in the element model.
///
@@ -1158,752 +340,6 @@
R? visitTypeParameterElement(TypeParameterElement element);
}
-/// An element that represents an enum.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class EnumElement implements InterfaceElement {
- @experimental
- @override
- EnumElement? get augmentation;
-
- @experimental
- @override
- EnumElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedEnumElement? get augmented;
-}
-
-/// An element representing an executable object, including functions, methods,
-/// constructors, getters, and setters.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ExecutableElement implements FunctionTypedElement {
- /// The immediate augmentation of this element, or `null` if there are no
- /// augmentations.
- ///
- /// [ExecutableElement.augmentationTarget] will point back at this element.
- @experimental
- ExecutableElement? get augmentation;
-
- /// The element that is augmented by this augmentation.
- ///
- /// The chain of augmentations normally ends with a [ExecutableElement] that
- /// is not an augmentation, but might end with `null` immediately or after a
- /// few intermediate [ExecutableElement]s in case of invalid code when an
- /// augmentation is declared without the corresponding declaration.
- @experimental
- ExecutableElement? get augmentationTarget;
-
- @override
- ExecutableElement get declaration;
-
- @override
- String get displayName;
-
- @Deprecated('Use enclosingElement2 instead')
- @override
- Element get enclosingElement;
-
- @override
- Element get enclosingElement2;
-
- /// Whether the executable element did not have an explicit return type
- /// specified for it in the original source.
- bool get hasImplicitReturnType;
-
- /// Whether the executable element is abstract.
- ///
- /// Executable elements are abstract if they are not external, and have no
- /// body.
- bool get isAbstract;
-
- /// Whether the executable element has body marked as being asynchronous.
- bool get isAsynchronous;
-
- /// Whether the element is an augmentation.
- ///
- /// If `true`, declaration has the explicit `augment` modifier.
- bool get isAugmentation;
-
- /// Whether the executable element is external.
- ///
- /// Executable elements are external if they are explicitly marked as such
- /// using the 'external' keyword.
- bool get isExternal;
-
- /// Whether the executable element has a body marked as being a generator.
- bool get isGenerator;
-
- /// Whether the 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;
-
- /// Whether the 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;
-
- /// Whether the executable element has a body marked as being synchronous.
- bool get isSynchronous;
-
- @override
- String get name;
-}
-
-/// An element that represents an extension.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ExtensionElement implements InstanceElement {
- @experimental
- @override
- ExtensionElement? get augmentation;
-
- @experimental
- @override
- ExtensionElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedExtensionElement? get augmented;
-
- /// The type that is extended by this extension.
- DartType get extendedType;
-
- /// Returns the element representing the field with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// field with the given name.
- FieldElement? getField(String name);
-
- /// Returns the element representing the getter with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// getter with the given name.
- PropertyAccessorElement? getGetter(String name);
-
- /// Returns the element representing the method with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// method with the given name.
- MethodElement? getMethod(String name);
-
- /// Returns the element representing the setter with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// setter with the given name.
- PropertyAccessorElement? getSetter(String name);
-}
-
-/// A field defined within a class.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class FieldElement
- implements ClassMemberElement, PropertyInducingElement {
- @override
- FieldElement get declaration;
-
- /// Whether the field is abstract.
- ///
- /// Executable fields are abstract if they are declared with the `abstract`
- /// keyword.
- bool get isAbstract;
-
- /// Whether the field was explicitly marked as being covariant.
- bool get isCovariant;
-
- /// Whether the element is an enum constant.
- bool get isEnumConstant;
-
- /// Whether the field was explicitly marked as being external.
- bool get isExternal;
-
- /// Whether the field can be type promoted.
- bool get isPromotable;
-
- /// Whether the 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.
- @override
- bool get isStatic;
-}
-
-/// A field formal parameter defined within a constructor element.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class FieldFormalParameterElement implements ParameterElement {
- /// 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 (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.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class FunctionElement implements ExecutableElement, LocalElement {
- /// 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";
-
- @experimental
- @override
- FunctionElement? get augmentation;
-
- @experimental
- @override
- FunctionElement? get augmentationTarget;
-
- /// Whether the function represents `identical` from the `dart:core` library.
- bool get isDartCoreIdentical;
-
- /// Whether the function is an entry point, i.e. a top-level function and
- /// has the name `main`.
- bool get isEntryPoint;
-}
-
-/// An element that has a [FunctionType] as its [type].
-///
-/// This also provides convenient access to the parameters and return type.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class FunctionTypedElement implements TypeParameterizedElement {
- /// The parameters defined by this executable element.
- List<ParameterElement> get parameters;
-
- /// The return type defined by this element.
- @Deprecated('Use returnType2 instead')
- DartType get returnType;
-
- /// The return type defined by this element.
- DartType get returnType2;
-
- /// The type defined by this element.
- FunctionType get type;
-}
-
-/// The pseudo-declaration that defines a generic function type.
-///
-/// Clients may not extend, implement, or mix-in this class.
-abstract class GenericFunctionTypeElement implements FunctionTypedElement {}
-
-/// A combinator that causes some of the names in a namespace to be hidden when
-/// being imported.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class HideElementCombinator implements NamespaceCombinator {
- /// 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;
-}
-
-/// Usage of a [PrefixElement] in an `import` directive.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ImportElementPrefix {
- /// The prefix that was specified as part of the import directive, or `null`
- /// if there was no prefix specified.
- PrefixElement get element;
-}
-
-/// An element that represents an inline class.
-///
-/// Clients may not extend, implement or mix-in this class.
-@experimental
-abstract class InlineClassElement implements NamedInstanceElement {
- @experimental
- @override
- InlineClassElement? get augmentation;
-
- @experimental
- @override
- InlineClassElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedInlineClassElement? get augmented;
-
- /// The direct [InlineClassType]s that are implemented by this inline class.
- List<InlineClassType> get implemented;
-}
-
-/// An element that has `this`.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class InstanceElement
- implements TypeDefiningElement, TypeParameterizedElement {
- /// The declared accessors (getters and setters).
- List<PropertyAccessorElement> get accessors;
-
- /// The immediate augmentation of this element, or `null` if there are no
- /// augmentations.
- ///
- /// [InstanceElement.augmentationTarget] will point back at this element.
- @experimental
- InstanceElement? get augmentation;
-
- /// The element that is augmented by this augmentation; or `null` if
- /// [isAugmentation] is `false`, or there is no corresponding element to be
- /// augmented.
- ///
- /// The chain of augmentations should normally end with a not augmentation
- /// [InstanceElement], but might end with `null` immediately or after a few
- /// intermediate elements in case of invalid code when an augmentation is
- /// declared without the corresponding declaration.
- @experimental
- InstanceElement? get augmentationTarget;
-
- /// The result of applying augmentations.
- @experimental
- AugmentedInstanceElement? get augmented;
-
- @Deprecated('Use enclosingElement2 instead')
- @override
- CompilationUnitElement get enclosingElement;
-
- @override
- CompilationUnitElement get enclosingElement2;
-
- /// The declared fields.
- List<FieldElement> get fields;
-
- /// Whether the element is an augmentation.
- ///
- /// If `true`, declaration has the explicit `augment` modifier.
- bool get isAugmentation;
-
- /// The declared methods.
- List<MethodElement> get methods;
-
- /// The type of `this` expression.
- ///
- /// For a class like `class MyClass<T, U> {}` the returned type is equivalent
- /// to the type `MyClass<T, U>`. So, the type arguments are the types of the
- /// type parameters, and either `none` or `star` is used for the nullability
- /// suffix is used, depending on the nullability status of the declaring
- /// library.
- DartType get thisType;
-}
-
-/// An element that defines an [InterfaceType].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class InterfaceElement implements NamedInstanceElement {
- /// All the supertypes defined for this element and its supertypes.
- ///
- /// This includes superclasses, mixins, interfaces, and superclass constraints.
- List<InterfaceType> get allSupertypes;
-
- @override
- InterfaceElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedInterfaceElement? get augmented;
-
- /// 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;
-
- /// The mixins that are applied to the class being extended in order to
- /// derive the superclass of this class.
- ///
- /// [ClassElement] and [EnumElement] can have mixins.
- ///
- /// [MixinElement] cannot have mixins, so the empty list is 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.
- List<InterfaceType> get mixins;
-
- /// The superclass of this element.
- ///
- /// For [ClassElement] returns `null` only if this class is `Object`. If the
- /// superclass is not explicitly specified, or the superclass cannot be
- /// resolved, then the implicit superclass `Object` is returned.
- ///
- /// For [EnumElement] returns `Enum` from `dart:core`.
- ///
- /// For [MixinElement] always returns `null`.
- ///
- /// <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 thisType;
-
- /// The field (synthetic or explicit) defined directly in this class or
- /// augmentation that has the given [name].
- /// TODO(scheglov) Deprecate and remove it.
- FieldElement? getField(String name);
-
- /// The getter (synthetic or explicit) defined directly in this class or
- /// augmentation that has the given [name].
- /// TODO(scheglov) Deprecate and remove it.
- PropertyAccessorElement? getGetter(String name);
-
- /// The method defined directly in this class or augmentation that has the
- /// given [name].
- /// TODO(scheglov) Deprecate and remove it.
- MethodElement? getMethod(String name);
-
- /// The setter (synthetic or explicit) defined directly in this class or
- /// augmentation that has the given [name].
- /// TODO(scheglov) Deprecate and remove it.
- PropertyAccessorElement? getSetter(String name);
-
- @override
- InterfaceType instantiate({
- required List<DartType> typeArguments,
- required NullabilitySuffix nullabilitySuffix,
- });
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- MethodElement? lookUpConcreteMethod(
- String methodName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- PropertyAccessorElement? lookUpGetter(
- String getterName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- PropertyAccessorElement? lookUpInheritedConcreteGetter(
- String getterName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- MethodElement? lookUpInheritedConcreteMethod(
- String methodName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- PropertyAccessorElement? lookUpInheritedConcreteSetter(
- String setterName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- MethodElement? lookUpInheritedMethod(
- String methodName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- MethodElement? lookUpMethod(String methodName, LibraryElement library);
-
- /// Returns 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>
- /// TODO(scheglov) Deprecate and remove it.
- PropertyAccessorElement? lookUpSetter(
- String setterName, LibraryElement library);
-}
-
-/// A pattern variable that is a join of other pattern variables, created
-/// for a logical-or patterns, or shared `case` bodies in `switch` statements.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class JoinPatternVariableElement implements PatternVariableElement {
- /// Whether the [variables] are consistent, present in all branches,
- /// and have the same type and finality.
- bool get isConsistent;
-
- /// The variables that join into this variable.
- List<PatternVariableElement> get variables;
-}
-
-/// A label associated with a statement.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class LabelElement implements Element {
- @Deprecated('Use enclosingElement2 instead')
- @override
- ExecutableElement get enclosingElement;
-
- @override
- ExecutableElement get enclosingElement2;
-
- @override
- String get name;
-}
-
-/// A library augmentation.
-///
-/// Clients may not extend, implement or mix-in this class.
-@experimental
-abstract class LibraryAugmentationElement
- implements LibraryOrAugmentationElement, _ExistingElement {
- /// The library that is augmented by this augmentation.
- LibraryOrAugmentationElement get augmentationTarget;
-}
-
-/// A library.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class LibraryElement
- implements LibraryOrAugmentationElement, _ExistingElement {
- /// 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;
-
- /// The libraries that are exported from this library.
- List<LibraryElement> get exportedLibraries;
-
- /// The export [Namespace] of this library.
- Namespace get exportNamespace;
-
- /// The identifier that uniquely identifies this element among the children
- /// of this element's parent.
- String get identifier;
-
- /// The libraries that are imported into this library.
- ///
- /// This includes all of the libraries that are imported using a prefix, and
- /// those that are imported without a prefix.
- List<LibraryElement> get importedLibraries;
-
- /// Whether the library is an application that can be run in the browser.
- bool get isBrowserApplication;
-
- /// Whether the library is the `dart:async` library.
- bool get isDartAsync;
-
- /// Whether the library is the `dart:core` library.
- bool get isDartCore;
-
- /// Whether the library is part of the SDK.
- bool get isInSdk;
-
- /// 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;
-
- /// The name of this library, possibly the empty string if this library does
- /// not have an explicit name.
- @override
- String get name;
-
- /// The list of `part` directives of this library.
- List<PartElement> get parts;
-
- /// The public [Namespace] of this library.
- Namespace get publicNamespace;
-
- /// The top-level elements defined in each of the compilation units that are
- /// included in this library. This includes both public and private elements,
- /// but does not include imports, exports, or synthetic elements.
- Iterable<Element> get topLevelElements;
-
- /// The compilation units this library consists of.
- ///
- /// This includes the defining compilation unit and units included using the
- /// `part` directive.
- List<CompilationUnitElement> get units;
-
- /// 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? getClass(String name);
-
- /// If a legacy library, returns the legacy view on the [element].
- ///
- /// Otherwise, return the original element.
- T toLegacyElementIfOptOut<T extends Element>(T element);
-
- /// If a legacy library, return the legacy version of the [type].
- /// Otherwise, return the original type.
- DartType toLegacyTypeIfOptOut(DartType type);
-}
-
-/// A single export directive within a library.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class LibraryExportElement implements _ExistingElement {
- /// The combinators that were specified as part of the `export` directive in
- /// the order in which they were specified.
- List<NamespaceCombinator> get combinators;
-
- /// The [LibraryElement], if [uri] is a [DirectiveUriWithLibrary].
- LibraryElement? get exportedLibrary;
-
- /// The offset of the `export` keyword.
- int get exportKeywordOffset;
-
- /// The interpretation of the URI specified in the directive.
- DirectiveUri get uri;
-}
-
-/// A single import directive within a library.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class LibraryImportElement implements _ExistingElement {
- /// The combinators that were specified as part of the `import` directive in
- /// the order in which they were specified.
- List<NamespaceCombinator> get combinators;
-
- /// The [LibraryElement], if [uri] is a [DirectiveUriWithLibrary].
- LibraryElement? get importedLibrary;
-
- /// The offset of the `import` keyword.
- int get importKeywordOffset;
-
- /// The [Namespace] that this directive contributes to the containing library.
- Namespace get namespace;
-
- /// The prefix that was specified as part of the import directive, or `null`
- /// if there was no prefix specified.
- ImportElementPrefix? get prefix;
-
- /// The interpretation of the URI specified in the directive.
- DirectiveUri get uri;
-}
-
class LibraryLanguageVersion {
/// The version for the whole package that contains this library.
final Version package;
@@ -1921,680 +357,3 @@
return override ?? package;
}
}
-
-/// Shared interface between [LibraryElement] and [LibraryAugmentationElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-@experimental
-abstract class LibraryOrAugmentationElement implements Element {
- /// The extension elements accessible within this library.
- List<ExtensionElement> get accessibleExtensions;
-
- /// The augmentation imports specified in this library.
- @experimental
- List<AugmentationImportElement> get augmentationImports;
-
- /// The compilation unit that defines this library.
- CompilationUnitElement get definingCompilationUnit;
-
- /// The set of features available to this library.
- ///
- /// Determined by the combination of the language version for the enclosing
- /// package, enabled experiments, and the presence of a `// @dart` language
- /// version override comment at the top of the file.
- FeatureSet get featureSet;
-
- bool get isNonNullableByDefault;
-
- /// The language version for this library.
- LibraryLanguageVersion get languageVersion;
-
- @override
- LibraryElement get library;
-
- /// The exports defined in this library.
- List<LibraryExportElement> get libraryExports;
-
- /// The imports defined in this library.
- List<LibraryImportElement> get libraryImports;
-
- /// 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 name lookup scope for this library.
- ///
- /// It consists of elements that are either declared in the library, or
- /// imported into it.
- Scope get scope;
-
- @override
- AnalysisSession get session;
-
- /// The [TypeProvider] that is used in this library.
- TypeProvider get typeProvider;
-
- /// The [TypeSystem] that is used in this library.
- TypeSystem get typeSystem;
-}
-
-/// An element that can be (but is not required to be) defined within a method
-/// or function (an [ExecutableElement]).
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class LocalElement implements Element {}
-
-/// A local variable.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class LocalVariableElement implements PromotableElement {
- /// Whether the variable has an initializer at declaration.
- bool get hasInitializer;
-
- @override
- String get name;
-}
-
-/// An element that represents a method defined within a class.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class MethodElement implements ClassMemberElement, ExecutableElement {
- @experimental
- @override
- MethodElement? get augmentation;
-
- @experimental
- @override
- MethodElement? get augmentationTarget;
-
- @override
- MethodElement get declaration;
-}
-
-/// An element that represents a mixin.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class MixinElement implements InterfaceElement {
- @experimental
- @override
- MixinElement? get augmentation;
-
- @experimental
- @override
- MixinElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedMixinElement? get augmented;
-
- /// Whether the mixin is a base mixin.
- ///
- /// A mixin is a base mixin if it has an explicit `base` modifier.
- /// The base modifier allows a mixin to be mixed in, but not implemented.
- bool get isBase;
-
- /// The superclass constraints defined for this mixin.
- ///
- /// If the declaration does not have an `on` clause, then the list will
- /// contain the type for the class `Object`.
- ///
- /// <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 superclassConstraints;
-
- /// Whether the element, assuming that it is within scope, is
- /// implementable to classes, mixins, and enums in the given [library].
- bool isImplementableIn(LibraryElement library);
-}
-
-/// 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.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class MultiplyDefinedElement implements Element {
- /// The elements that were defined within the scope to have the same name.
- List<Element> get conflictingElements;
-}
-
-/// An [ExecutableElement], with the additional information of a list of
-/// [ExecutableElement]s from which this element was composed.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class MultiplyInheritedExecutableElement implements ExecutableElement {
- /// The executable elements defined within this executable element.
- List<ExecutableElement> get inheritedElements;
-}
-
-/// An element that represents a named [InstanceElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-@experimental
-abstract class NamedInstanceElement implements InstanceElement {
- @override
- NamedInstanceElement? get augmentationTarget;
-
- @experimental
- @override
- AugmentedNamedInstanceElement? get augmented;
-
- /// The declared constructors.
- ///
- /// The list is empty for [MixinElement].
- List<ConstructorElement> get constructors;
-
- @override
- String get name;
-
- /// The unnamed constructor declared directly in this class.
- ///
- /// If the class does not declare any constructors, a synthetic default
- /// constructor will be returned.
- /// TODO(scheglov) Deprecate and remove it.
- ConstructorElement? get unnamedConstructor;
-
- /// The constructor defined directly in this class or augmentation
- /// that has the given [name].
- /// TODO(scheglov) Deprecate and remove it.
- ConstructorElement? getNamedConstructor(String name);
-
- /// Create the [DartType] for this element with the given [typeArguments]
- /// and [nullabilitySuffix].
- DartType instantiate({
- required List<DartType> typeArguments,
- required NullabilitySuffix nullabilitySuffix,
- });
-}
-
-/// An object that controls how namespaces are combined.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class NamespaceCombinator {}
-
-/// A parameter defined within an executable element.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ParameterElement
- implements PromotableElement, ConstantEvaluationTarget {
- @override
- ParameterElement get declaration;
-
- /// The code of the default value, or `null` if no default value.
- String? get defaultValueCode;
-
- /// Whether the parameter has a default value.
- bool get hasDefaultValue;
-
- /// Whether the parameter is covariant, meaning it is allowed to have a
- /// narrower type in an override.
- bool get isCovariant;
-
- /// Whether the parameter is an initializing formal parameter.
- bool get isInitializingFormal;
-
- /// Whether the parameter is a named parameter.
- ///
- /// Named parameters that are annotated with the `@required` annotation are
- /// considered optional. Named parameters that are annotated with the
- /// `required` syntax are considered required.
- bool get isNamed;
-
- /// Whether the parameter is an optional parameter.
- ///
- /// Optional parameters can either be positional or named. Named parameters
- /// that are annotated with the `@required` annotation are considered
- /// optional. Named parameters that are annotated with the `required` syntax
- /// are considered required.
- bool get isOptional;
-
- /// Whether the parameter is both an optional and named parameter.
- ///
- /// Named parameters that are annotated with the `@required` annotation are
- /// considered optional. Named parameters that are annotated with the
- /// `required` syntax are considered required.
- bool get isOptionalNamed;
-
- /// Whether the parameter is both an optional and positional parameter.
- bool get isOptionalPositional;
-
- /// Whether the parameter is a positional parameter.
- ///
- /// Positional parameters can either be required or optional.
- bool get isPositional;
-
- /// Whether the parameter is either a required positional parameter, or a
- /// named parameter with the `required` keyword.
- ///
- /// Note: the presence or absence of the `@required` annotation does not
- /// change the meaning of this getter. The parameter `{@required int x}`
- /// will return `false` and the parameter `{@required required int x}`
- /// will return `true`.
- bool get isRequired;
-
- /// Whether the parameter is both a required and named parameter.
- ///
- /// Named parameters that are annotated with the `@required` annotation are
- /// considered optional. Named parameters that are annotated with the
- /// `required` syntax are considered required.
- bool get isRequiredNamed;
-
- /// Whether the parameter is both a required and positional parameter.
- bool get isRequiredPositional;
-
- /// Whether the parameter is a super formal parameter.
- bool get isSuperFormal;
-
- @override
- String get name;
-
- /// The kind of this parameter.
- @Deprecated('Use the getters isOptionalNamed, isOptionalPositional, '
- 'isRequiredNamed, and isRequiredPositional')
- ParameterKind get parameterKind;
-
- /// The parameters defined by this parameter.
- ///
- /// A parameter will only define other parameters if it is a function typed
- /// parameter.
- List<ParameterElement> get parameters;
-
- /// The type parameters defined by this parameter.
- ///
- /// A parameter will only define type parameters if it is a function typed
- /// parameter.
- List<TypeParameterElement> get typeParameters;
-
- /// Appends the type, name and possibly the default value of this parameter
- /// to the given [buffer].
- void appendToWithoutDelimiters(
- StringBuffer buffer, {
- bool withNullability = false,
- });
-}
-
-/// A 'part' directive within a library.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class PartElement implements _ExistingElement {
- /// The interpretation of the URI specified in the directive.
- DirectiveUri get uri;
-}
-
-/// A pattern variable.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class PatternVariableElement implements LocalVariableElement {
- /// The variable in which this variable joins with other pattern variables
- /// with the same name, in a logical-or pattern, or shared case scope.
- JoinPatternVariableElement? get join;
-}
-
-/// A prefix used to import one or more libraries into another library.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class PrefixElement implements _ExistingElement {
- /// The library, or library augmentation that encloses this element.
- @Deprecated('Use enclosingElement2 instead')
- @override
- LibraryOrAugmentationElement get enclosingElement;
-
- /// The library, or library augmentation that encloses this element.
- @override
- LibraryOrAugmentationElement get enclosingElement2;
-
- /// The imports that share this prefix.
- List<LibraryImportElement> get imports;
-
- @override
- String get name;
-
- /// The name lookup scope for this import prefix.
- ///
- /// It consists of elements imported into the enclosing library with this
- /// prefix. The namespace combinators of the import directives are taken
- /// into account.
- Scope get scope;
-}
-
-/// A variable that might be subject to type promotion. This might be a local
-/// variable or a parameter.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class PromotableElement implements LocalElement, VariableElement {
- // Promotable elements are guaranteed to have a name.
- @override
- String get name;
-}
-
-/// 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].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class PropertyAccessorElement implements ExecutableElement {
- @experimental
- @override
- PropertyAccessorElement? get augmentation;
-
- @experimental
- @override
- PropertyAccessorElement? get augmentationTarget;
-
- /// 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;
-
- /// 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;
-
- @override
- PropertyAccessorElement get declaration;
-
- @Deprecated('Use enclosingElement2 instead')
- @override
- Element get enclosingElement;
-
- @override
- Element get enclosingElement2;
-
- /// Whether the accessor represents a getter.
- bool get isGetter;
-
- /// Whether the accessor represents a setter.
- bool get isSetter;
-
- /// 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;
-}
-
-/// 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].
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class PropertyInducingElement implements VariableElement {
- @override
- String get displayName;
-
- /// 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;
-
- /// Whether the variable has an initializer at declaration.
- bool get hasInitializer;
-
- @override
- LibraryElement get library;
-
- @override
- String get name;
-
- /// 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 combinator that cause some of the names in a namespace to be visible (and
-/// the rest hidden) when being imported.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class ShowElementCombinator implements NamespaceCombinator {
- /// The offset of the character immediately following the last character of
- /// this node.
- int get end;
-
- /// The offset of the 'show' keyword of this element.
- int get offset;
-
- /// 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 super formal parameter defined within a constructor element.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class SuperFormalParameterElement implements ParameterElement {
- /// The associated super-constructor parameter, from the super-constructor
- /// that is referenced by the implicit or explicit super-constructor
- /// invocation.
- ///
- /// Can be `null` for erroneous code - not existing super-constructor,
- /// no corresponding parameter in the super-constructor.
- ParameterElement? get superConstructorParameter;
-}
-
-/// A top-level variable.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class TopLevelVariableElement implements PropertyInducingElement {
- @override
- TopLevelVariableElement get declaration;
-
- /// Whether the field was explicitly marked as being external.
- bool get isExternal;
-}
-
-/// A type alias (`typedef`).
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class TypeAliasElement
- implements TypeParameterizedElement, TypeDefiningElement {
- /// If the aliased type has structure, return the corresponding element.
- /// For example it could be [GenericFunctionTypeElement].
- ///
- /// If there is no structure, return `null`.
- Element? get aliasedElement;
-
- /// The aliased type.
- ///
- /// If non-function type aliases feature is enabled for the enclosing library,
- /// this type might be just anything. If the feature is disabled, return
- /// a [FunctionType].
- DartType get aliasedType;
-
- @Deprecated('Use enclosingElement2 instead')
- @override
- CompilationUnitElement get enclosingElement;
-
- @override
- CompilationUnitElement get enclosingElement2;
-
- @override
- String get name;
-
- /// Produces the type resulting from instantiating this typedef with the given
- /// [typeArguments] and [nullabilitySuffix].
- ///
- /// Note that this always instantiates the typedef itself, so for a
- /// [TypeAliasElement] the returned [DartType] might still be a generic
- /// type, with type formals. For example, if the typedef is:
- /// typedef F<T> = void Function<U>(T, U);
- /// then `F<int>` will produce `void Function<U>(int, U)`.
- DartType instantiate({
- required List<DartType> typeArguments,
- required NullabilitySuffix nullabilitySuffix,
- });
-}
-
-/// An element that defines a type.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class TypeDefiningElement implements Element {}
-
-/// A type parameter.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class TypeParameterElement implements TypeDefiningElement {
- /// The type representing the bound associated with this parameter, or `null`
- /// if this parameter does not have an explicit bound. Being able to
- /// distinguish between an implicit and explicit bound is needed by the
- /// instantiate to bounds algorithm.
- DartType? get bound;
-
- @override
- TypeParameterElement get declaration;
-
- @override
- String get displayName;
-
- @override
- String get name;
-
- /// Creates the [TypeParameterType] with the given [nullabilitySuffix] for
- /// this type parameter.
- TypeParameterType instantiate({
- required NullabilitySuffix nullabilitySuffix,
- });
-}
-
-/// An element that has type parameters, such as a class or a typedef. This also
-/// includes functions and methods if support for generic methods is enabled.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class TypeParameterizedElement implements _ExistingElement {
- /// If the element defines a type, indicates whether the type may safely
- /// appear without explicit type parameters as the bounds of a type parameter
- /// declaration.
- ///
- /// If the element does not define a type, returns `true`.
- bool get isSimplyBounded;
-
- /// The type parameters declared by this element directly.
- ///
- /// This does not include type parameters that are declared by any enclosing
- /// elements.
- List<TypeParameterElement> get typeParameters;
-}
-
-/// 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.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class UndefinedElement implements Element {}
-
-/// An element included into a library using some URI.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class UriReferencedElement implements _ExistingElement {
- /// 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;
-
- /// The offset of the character immediately following the last character of
- /// this node's URI, or `-1` for synthetic import.
- int get uriEnd;
-
- /// The offset of the URI in the file, or `-1` if this element is synthetic.
- int get uriOffset;
-}
-
-/// A variable. There are more specific subclasses for more specific kinds of
-/// variables.
-///
-/// Clients may not extend, implement or mix-in this class.
-abstract class VariableElement implements Element, ConstantEvaluationTarget {
- @override
- VariableElement get declaration;
-
- /// Whether the variable element did not have an explicit type specified
- /// for it.
- bool get hasImplicitType;
-
- /// Whether the variable was declared with the 'const' modifier.
- bool get isConst;
-
- /// Whether the 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;
-
- /// Whether the variable uses late evaluation semantics.
- ///
- /// This will always return `false` unless the experiment 'non-nullable' is
- /// enabled.
- bool get isLate;
-
- /// Whether the 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;
-
- @override
- String get name;
-
- /// The declared type of this variable.
- DartType get type;
-
- /// Returns a representation of the value of this variable, forcing the value
- /// to be computed if it had not previously been computed, or `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? computeConstantValue();
-}
-
-/// This class exists to provide non-nullable overrides for existing elements,
-/// as opposite to artificial "multiply defined" element.
-abstract class _ExistingElement implements Element {
- @override
- Element get declaration;
-
- @override
- LibraryElement get library;
-
- @override
- Source get librarySource;
-
- @override
- Source get source;
-}
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 313b3a5..062408f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/context/source.dart';
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index e6736b9..b1537b1 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -8,8 +8,6 @@
import 'package:_fe_analyzer_shared/src/macros/executor/multi_executor.dart'
as macro;
import 'package:analyzer/dart/analysis/declared_variables.dart';
-import 'package:analyzer/dart/element/element.dart'
- show CompilationUnitElement, LibraryElement;
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index 74e5ca2..7640cda 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -13,7 +13,6 @@
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/constant/value.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index cac3b04..77ecc40 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -8,7 +8,6 @@
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/analyzer/lib/src/dart/constant/utilities.dart b/pkg/analyzer/lib/src/dart/constant/utilities.dart
index 10ce599..8f7f2de 100644
--- a/pkg/analyzer/lib/src/dart/constant/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/constant/utilities.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/constant/evaluation.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/constant/value.dart b/pkg/analyzer/lib/src/dart/constant/value.dart
index b767d76..49ff3df 100644
--- a/pkg/analyzer/lib/src/dart/constant/value.dart
+++ b/pkg/analyzer/lib/src/dart/constant/value.dart
@@ -10,7 +10,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/constant/value.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/diagnostic/diagnostic.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/class_hierarchy.dart b/pkg/analyzer/lib/src/dart/element/class_hierarchy.dart
index 9032702..a17c6f8 100644
--- a/pkg/analyzer/lib/src/dart/element/class_hierarchy.dart
+++ b/pkg/analyzer/lib/src/dart/element/class_hierarchy.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/extensions.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 81026a5..2a7d101 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -49,13 +49,38 @@
import 'package:analyzer/src/summary2/macro.dart';
import 'package:analyzer/src/summary2/macro_application_error.dart';
import 'package:analyzer/src/summary2/reference.dart';
+import 'package:analyzer/src/task/api/model.dart' show AnalysisTarget;
import 'package:analyzer/src/task/inference_error.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/utilities/extensions/collection.dart';
import 'package:analyzer/src/utilities/extensions/string.dart';
import 'package:collection/collection.dart';
+import 'package:meta/meta.dart';
import 'package:pub_semver/pub_semver.dart';
+/// A library augmentation import directive within a library.
+///
+/// Clients may not extend, implement or mix-in this class.
+@experimental
+abstract class AugmentationImportElement implements _ExistingElement {
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ LibraryOrAugmentationElement get enclosingElement;
+
+ @override
+ LibraryOrAugmentationElement get enclosingElement2;
+
+ /// The [LibraryAugmentationElement], if [uri] is a
+ /// [DirectiveUriWithAugmentation].
+ LibraryAugmentationElement? get importedAugmentation;
+
+ /// The offset of the `import` keyword.
+ int get importKeywordOffset;
+
+ /// The interpretation of the URI specified in the directive.
+ DirectiveUri get uri;
+}
+
class AugmentationImportElementImpl extends _ExistingElementImpl
implements AugmentationImportElement {
@override
@@ -97,6 +122,14 @@
visitor.visitAugmentationImportElement(this);
}
+/// The result of applying augmentations to a [ClassElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedClassElement implements AugmentedInterfaceElement {
+ @override
+ ClassElement get declaration;
+}
+
class AugmentedClassElementImpl extends AugmentedInterfaceElementImpl
implements AugmentedClassElement {
@override
@@ -105,15 +138,75 @@
AugmentedClassElementImpl(this.declaration);
}
+/// The result of applying augmentations to an [EnumElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedEnumElement implements AugmentedInterfaceElement {}
+
class AugmentedEnumElementImpl extends AugmentedInterfaceElementImpl
implements AugmentedEnumElement {}
+/// The result of applying augmentations to an [ExtensionElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedExtensionElement implements AugmentedInstanceElement {}
+
class AugmentedExtensionElementImpl extends AugmentedInstanceElementImpl
implements AugmentedExtensionElement {}
+/// The result of applying augmentations to an [InlineClassElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedInlineClassElement
+ implements AugmentedNamedInstanceElement {}
+
class AugmentedInlineClassElementImpl extends AugmentedNamedInstanceElementImpl
implements AugmentedInlineClassElement {}
+/// The result of applying augmentations to a [InstanceElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedInstanceElement {
+ /// The accessors (getters and setters) declared in this element.
+ ///
+ /// [PropertyAccessorElement]s replace corresponding elements,
+ /// other [PropertyAccessorElement]s are appended.
+ List<PropertyAccessorElement> get accessors;
+
+ /// The declaration (not augmentation) that owns this result.
+ InstanceElement get declaration;
+
+ /// The fields declared in this element.
+ ///
+ /// [FieldAugmentationElement]s replace corresponding elements, other
+ /// [FieldElement]s are appended.
+ List<FieldElement> get fields;
+
+ /// The metadata associated with this element.
+ ///
+ /// This is a union of annotations associated with the class declaration and
+ /// all its augmentations.
+ List<ElementAnnotation> get metadata;
+
+ /// The methods declared in this element.
+ ///
+ /// [MethodAugmentationElement]s replace corresponding elements, other
+ /// [MethodElement]s are appended.
+ List<MethodElement> get methods;
+
+ /// Returns the field from [fields] that has the given [name].
+ FieldElement? getField(String name);
+
+ /// Returns the getter from [accessors] that has the given [name].
+ PropertyAccessorElement? getGetter(String name);
+
+ /// Returns the method from [methods] that has the given [name].
+ MethodElement? getMethod(String name);
+
+ /// Returns the setter from [accessors] that has the given [name].
+ PropertyAccessorElement? getSetter(String name);
+}
+
abstract class AugmentedInstanceElementImpl
implements AugmentedInstanceElement {
@override
@@ -188,6 +281,27 @@
}
}
+/// The result of applying augmentations to a [InterfaceElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedInterfaceElement
+ implements AugmentedNamedInstanceElement {
+ @override
+ InterfaceElement get declaration;
+
+ /// The interfaces implemented by this element.
+ ///
+ /// This is a union of interfaces declared by the class declaration and
+ /// all its augmentations.
+ List<InterfaceType> get interfaces;
+
+ /// The mixins applied by this class or in its augmentations.
+ ///
+ /// This is a union of mixins applied by the class declaration and all its
+ /// augmentations.
+ List<InterfaceType> get mixins;
+}
+
abstract class AugmentedInterfaceElementImpl
extends AugmentedNamedInstanceElementImpl
implements AugmentedInterfaceElement {
@@ -202,6 +316,17 @@
InterfaceElement get declaration => throw UnimplementedError();
}
+/// The result of applying augmentations to a [MixinElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedMixinElement extends AugmentedInterfaceElement {
+ /// The superclass constraints of this element.
+ ///
+ /// This is a union of constraints declared by the class declaration and
+ /// all its augmentations.
+ List<InterfaceType> get superclassConstraints;
+}
+
class AugmentedMixinElementImpl extends AugmentedInterfaceElementImpl
implements AugmentedMixinElement {
@override
@@ -213,6 +338,27 @@
AugmentedMixinElementImpl(this.declaration);
}
+/// The result of applying augmentations to a [NamedInstanceElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class AugmentedNamedInstanceElement
+ implements AugmentedInstanceElement {
+ /// The constructors declared in this element.
+ ///
+ /// [ConstructorAugmentationElement]s replace corresponding elements,
+ /// other [ConstructorElement]s are appended.
+ List<ConstructorElement> get constructors;
+
+ @override
+ NamedInstanceElement get declaration;
+
+ /// The unnamed constructor from [constructors].
+ ConstructorElement? get unnamedConstructor;
+
+ /// Returns the constructor from [constructors] that has the given [name].
+ ConstructorElement? getNamedConstructor(String name);
+}
+
abstract class AugmentedNamedInstanceElementImpl
extends AugmentedInstanceElementImpl
implements AugmentedNamedInstanceElement {
@@ -235,6 +381,11 @@
}
}
+/// A pattern variable that is explicitly declared.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class BindPatternVariableElement implements PatternVariableElement {}
+
class BindPatternVariableElementImpl extends PatternVariableElementImpl
implements BindPatternVariableElement {
final DeclaredVariablePatternImpl node;
@@ -246,6 +397,118 @@
BindPatternVariableElementImpl(this.node, super.name, super.offset);
}
+/// An element that represents a class or a mixin. The class can be defined by
+/// either a class declaration (with a class body), a mixin application (without
+/// a class body), a mixin declaration, or an enum declaration.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ClassElement implements InterfaceElement {
+ @experimental
+ @override
+ ClassElement? get augmentation;
+
+ @experimental
+ @override
+ ClassElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedClassElement? get augmented;
+
+ /// Whether the class or its superclass declares a non-final instance field.
+ bool get hasNonFinalField;
+
+ /// Whether the 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;
+
+ /// Whether this class is a base class.
+ ///
+ /// A class is a base class if it has an explicit `base` modifier, or the
+ /// class has a `base` induced modifier and [isSealed] is `true` as well.
+ /// The base modifier allows the class to be extended but not implemented.
+ bool get isBase;
+
+ /// Whether the class can be instantiated.
+ bool get isConstructable;
+
+ /// Whether the class represents the class 'Enum' defined in `dart:core`.
+ bool get isDartCoreEnum;
+
+ /// Whether the class represents the class 'Object' defined in `dart:core`.
+ bool get isDartCoreObject;
+
+ /// Whether the class has the property where, in a switch, if you cover all
+ /// of the subtypes of this element, then the compiler knows that you have
+ /// covered all possible instances of the type.
+ bool get isExhaustive;
+
+ /// Whether the class is a final class.
+ ///
+ /// A class is a final class if it has an explicit `final` modifier, or the
+ /// class has a `final` induced modifier and [isSealed] is `true` as well.
+ /// The final modifier prohibits this class from being extended, implemented,
+ /// or mixed in.
+ bool get isFinal;
+
+ /// Whether the class is an inline class.
+ ///
+ /// A class is an inline class if it has an explicit `inline` modifier.
+ @experimental
+ bool get isInline;
+
+ /// Whether the class is an interface class.
+ ///
+ /// A class is an interface class if it has an explicit `interface` modifier,
+ /// or the class has an `interface` induced modifier and [isSealed] is `true`
+ /// as well. The interface modifier allows the class to be implemented, but
+ /// not extended or mixed in.
+ bool get isInterface;
+
+ /// Whether the 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;
+
+ /// Whether the class is a mixin class.
+ ///
+ /// A class is a mixin class if it has an explicit `mixin` modifier.
+ bool get isMixinClass;
+
+ /// Whether the class is a sealed class.
+ ///
+ /// A class is a sealed class if it has an explicit `sealed` modifier.
+ bool get isSealed;
+
+ /// Whether the class can validly be used as a mixin when defining
+ /// another class.
+ ///
+ /// For classes defined by a class declaration or a mixin application, 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;
+
+ /// Whether the class, assuming that it is within scope, is extendable to
+ /// classes in the given [library].
+ bool isExtendableIn(LibraryElement library);
+
+ /// Whether the class, assuming that it is within scope, is
+ /// implementable to classes, mixins, and enums in the given [library].
+ bool isImplementableIn(LibraryElement library);
+
+ /// Whether the class, assuming that it is within scope, is able to be
+ /// mixed-in by classes and enums in the given [library].
+ bool isMixableIn(LibraryElement library);
+}
+
/// An [InterfaceElementImpl] which is a class.
class ClassElementImpl extends ClassOrMixinElementImpl
with _HasAugmentation<ClassElementImpl>
@@ -691,6 +954,27 @@
}
}
+/// An element that is contained within a [ClassElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ClassMemberElement implements Element {
+ // TODO(brianwilkerson) Either remove this class or rename it to something
+ // more correct.
+
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ Element get enclosingElement;
+
+ @override
+ Element get enclosingElement2;
+
+ /// Whether the 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;
+}
+
abstract class ClassOrMixinElementImpl extends InterfaceElementImpl {
/// Initialize a newly created class element to have the given [name] at the
/// given [offset] in the file that contains the declaration of this element.
@@ -709,6 +993,61 @@
ElementKind get kind => ElementKind.CLASS;
}
+/// An element representing a compilation unit.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class CompilationUnitElement implements UriReferencedElement {
+ /// The top-level accessors (getters and setters) declared in this
+ /// compilation unit.
+ List<PropertyAccessorElement> get accessors;
+
+ /// The classes declared in this compilation unit.
+ List<ClassElement> get classes;
+
+ /// The library, or library augmentation that encloses this unit.
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ LibraryOrAugmentationElement get enclosingElement;
+
+ /// The library, or library augmentation that encloses this unit.
+ @override
+ LibraryOrAugmentationElement get enclosingElement2;
+
+ /// The enums declared in this compilation unit.
+ List<EnumElement> get enums;
+
+ /// The extensions declared in this compilation unit.
+ List<ExtensionElement> get extensions;
+
+ /// The top-level functions declared in this compilation unit.
+ List<FunctionElement> get functions;
+
+ /// The [LineInfo] for the [source].
+ LineInfo get lineInfo;
+
+ /// The mixins declared in this compilation unit.
+ List<MixinElement> get mixins;
+
+ @override
+ AnalysisSession get session;
+
+ /// The top-level variables declared in this compilation unit.
+ List<TopLevelVariableElement> get topLevelVariables;
+
+ /// The type aliases declared in this compilation unit.
+ List<TypeAliasElement> get typeAliases;
+
+ /// Returns 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? getClass(String name);
+
+ /// Returns 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.
+ EnumElement? getEnum(String name);
+}
+
/// A concrete implementation of a [CompilationUnitElement].
class CompilationUnitElementImpl extends UriReferencedElementImpl
implements CompilationUnitElement, MacroTargetElementContainer {
@@ -989,6 +1328,72 @@
ConstLocalVariableElementImpl(super.name, super.offset);
}
+/// An element representing a constructor or a factory method defined within a
+/// class.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ConstructorElement
+ implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget {
+ @experimental
+ @override
+ ConstructorElement? get augmentation;
+
+ @experimental
+ @override
+ ConstructorElement? get augmentationTarget;
+
+ @override
+ ConstructorElement get declaration;
+
+ @override
+ String get displayName;
+
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ InterfaceElement get enclosingElement;
+
+ @override
+ NamedInstanceElement get enclosingElement2;
+
+ /// Whether the constructor is a const constructor.
+ bool get isConst;
+
+ /// Whether the constructor can be used as a default constructor - unnamed,
+ /// and has no required parameters.
+ bool get isDefaultConstructor;
+
+ /// Whether the constructor represents a factory constructor.
+ bool get isFactory;
+
+ /// Whether the constructor represents a generative constructor.
+ bool get isGenerative;
+
+ @override
+ String get name;
+
+ /// The offset of the character immediately following the last character of
+ /// this constructor's name, or `null` if not named.
+ ///
+ /// TODO(migration): encapsulate [nameEnd] and [periodOffset]?
+ int? get nameEnd;
+
+ /// The offset of the `.` before this constructor name, or `null` if not
+ /// named.
+ int? get periodOffset;
+
+ /// 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;
+
+ @Deprecated('Use returnType2 instead')
+ @override
+ InterfaceType get returnType;
+
+ @override
+ DartType get returnType2;
+}
+
/// A concrete implementation of a [ConstructorElement].
class ConstructorElementImpl extends ExecutableElementImpl
with ConstructorElementMixin
@@ -1383,6 +1788,11 @@
}
}
+/// [ImportElementPrefix] that is used together with `deferred`.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DeferredImportElementPrefix implements ImportElementPrefix {}
+
class DeferredImportElementPrefixImpl extends ImportElementPrefixImpl
implements DeferredImportElementPrefix {
DeferredImportElementPrefixImpl({
@@ -1390,8 +1800,21 @@
});
}
+/// Meaning of a URI referenced in a directive.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUri {}
+
class DirectiveUriImpl implements DirectiveUri {}
+/// [DirectiveUriWithSource] that references a [LibraryAugmentationElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUriWithAugmentation extends DirectiveUriWithSource {
+ /// The library augmentation referenced by the [source].
+ LibraryAugmentationElement get augmentation;
+}
+
class DirectiveUriWithAugmentationImpl extends DirectiveUriWithSourceImpl
implements DirectiveUriWithAugmentation {
@override
@@ -1405,6 +1828,14 @@
});
}
+/// [DirectiveUriWithSource] that references a [LibraryElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUriWithLibrary extends DirectiveUriWithSource {
+ /// The library referenced by the [source].
+ LibraryElement get library;
+}
+
class DirectiveUriWithLibraryImpl extends DirectiveUriWithSourceImpl
implements DirectiveUriWithLibrary {
@override
@@ -1424,6 +1855,15 @@
});
}
+/// [DirectiveUriWithRelativeUriString] that can be parsed into a relative URI.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUriWithRelativeUri
+ extends DirectiveUriWithRelativeUriString {
+ /// The relative URI, parsed from [relativeUriString].
+ Uri get relativeUri;
+}
+
class DirectiveUriWithRelativeUriImpl
extends DirectiveUriWithRelativeUriStringImpl
implements DirectiveUriWithRelativeUri {
@@ -1436,6 +1876,14 @@
});
}
+/// [DirectiveUri] for which we can get its relative URI string.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUriWithRelativeUriString extends DirectiveUri {
+ /// The relative URI string specified in code.
+ String get relativeUriString;
+}
+
class DirectiveUriWithRelativeUriStringImpl extends DirectiveUriImpl
implements DirectiveUriWithRelativeUriString {
@override
@@ -1446,6 +1894,14 @@
});
}
+/// [DirectiveUriWithRelativeUri] that resolves to a [Source].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUriWithSource extends DirectiveUriWithRelativeUri {
+ /// The result of resolving [relativeUri] against the enclosing URI.
+ Source get source;
+}
+
class DirectiveUriWithSourceImpl extends DirectiveUriWithRelativeUriImpl
implements DirectiveUriWithSource {
@override
@@ -1458,6 +1914,14 @@
});
}
+/// [DirectiveUriWithSource] that references a [CompilationUnitElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class DirectiveUriWithUnit extends DirectiveUriWithSource {
+ /// The unit referenced by the [source].
+ CompilationUnitElement get unit;
+}
+
class DirectiveUriWithUnitImpl extends DirectiveUriWithRelativeUriImpl
implements DirectiveUriWithUnit {
@override
@@ -1493,6 +1957,419 @@
T? accept<T>(ElementVisitor<T> visitor) => null;
}
+/// 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.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class Element implements AnalysisTarget {
+ /// A list of this element's children.
+ ///
+ /// There is no guarantee of the order in which the children will be included.
+ List<Element> get children;
+
+ /// The analysis context in which this element is defined.
+ AnalysisContext get context;
+
+ /// The declaration of this element.
+ ///
+ /// If the element is a view on an element, e.g. a method from an interface
+ /// type, with substituted type parameters, return the corresponding element
+ /// from the class, without any substitutions. If this element is already a
+ /// declaration (or a synthetic element, e.g. a synthetic property accessor),
+ /// return itself.
+ Element? get declaration;
+
+ /// The display name of this element, possibly the empty string if the
+ /// 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;
+
+ /// The content of the documentation comment (including delimiters) for this
+ /// element, or `null` if this element does not or cannot have documentation.
+ String? get documentationComment;
+
+ /// 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.
+ @Deprecated('Use enclosingElement2 instead')
+ Element? get enclosingElement;
+
+ /// 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 enclosingElement2;
+
+ /// Whether the element has an annotation of the form `@alwaysThrows`.
+ bool get hasAlwaysThrows;
+
+ /// Whether the element has an annotation of the form `@deprecated`
+ /// or `@Deprecated('..')`.
+ bool get hasDeprecated;
+
+ /// Whether the element has an annotation of the form `@doNotStore`.
+ bool get hasDoNotStore;
+
+ /// Whether the element has an annotation of the form `@factory`.
+ bool get hasFactory;
+
+ /// Whether the element has an annotation of the form `@internal`.
+ bool get hasInternal;
+
+ /// Whether the element has an annotation of the form `@isTest`.
+ bool get hasIsTest;
+
+ /// Whether the element has an annotation of the form `@isTestGroup`.
+ bool get hasIsTestGroup;
+
+ /// Whether the element has an annotation of the form `@JS(..)`.
+ bool get hasJS;
+
+ /// Whether the element has an annotation of the form `@literal`.
+ bool get hasLiteral;
+
+ /// Whether the element has an annotation of the form `@mustBeOverridden`.
+ bool get hasMustBeOverridden;
+
+ /// Whether the element has an annotation of the form `@mustCallSuper`.
+ bool get hasMustCallSuper;
+
+ /// Whether the element has an annotation of the form `@nonVirtual`.
+ bool get hasNonVirtual;
+
+ /// Whether the element has an annotation of the form `@optionalTypeArgs`.
+ bool get hasOptionalTypeArgs;
+
+ /// Whether the element has an annotation of the form `@override`.
+ bool get hasOverride;
+
+ /// Whether the element has an annotation of the form `@protected`.
+ bool get hasProtected;
+
+ /// Whether the element has an annotation of the form `@reopen`.
+ bool get hasReopen;
+
+ /// Whether the element has an annotation of the form `@required`.
+ bool get hasRequired;
+
+ /// Whether the element has an annotation of the form `@sealed`.
+ bool get hasSealed;
+
+ /// Whether the element has an annotation of the form `@useResult`
+ /// or `@UseResult('..')`.
+ bool get hasUseResult;
+
+ /// Whether the element has an annotation of the form `@visibleForOverriding`.
+ bool get hasVisibleForOverriding;
+
+ /// Whether the element has an annotation of the form `@visibleForTemplate`.
+ bool get hasVisibleForTemplate;
+
+ /// Whether the element has an annotation of the form `@visibleForTesting`.
+ bool get hasVisibleForTesting;
+
+ /// Whether the element has an annotation of the form
+ /// `@visibleOutsideTemplate`.
+ bool get hasVisibleOutsideTemplate;
+
+ /// The unique integer identifier of this element.
+ int get id;
+
+ /// Whether the element is private.
+ ///
+ /// Private elements are visible only within the library in which they are
+ /// declared.
+ bool get isPrivate;
+
+ /// Whether the element is public.
+ ///
+ /// Public elements are visible within any library that imports the library
+ /// in which they are declared.
+ bool get isPublic;
+
+ /// Whether the 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;
+
+ /// The kind of element that this is.
+ ElementKind get kind;
+
+ /// Tibrary that contains this element.
+ ///
+ /// This will be the element itself if it is a library element. This will be
+ /// `null` if this element is [MultiplyDefinedElement] that is not contained
+ /// in a library.
+ LibraryElement? get library;
+
+ /// 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;
+
+ /// 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;
+
+ /// The name of this element, or `null` if this element does not have a name.
+ String? get name;
+
+ /// 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;
+
+ /// 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;
+
+ /// The non-synthetic element that caused this element to be created.
+ ///
+ /// If this element is not synthetic, then the element itself is returned.
+ ///
+ /// If this element is synthetic, then the corresponding non-synthetic
+ /// element is returned. For example, for a synthetic getter of a
+ /// non-synthetic field the field is returned; for a synthetic constructor
+ /// the enclosing class is returned.
+ Element get nonSynthetic;
+
+ /// The analysis session in which this element is defined.
+ AnalysisSession? get session;
+
+ /// The version where this SDK API was added.
+ ///
+ /// A `@Since()` annotation can be applied to a library declaration,
+ /// any public declaration in a library, or in a class, or to an optional
+ /// parameter, etc.
+ ///
+ /// The returned version is "effective", so that if a library is annotated
+ /// then all elements of the library inherit it; or if a class is annotated
+ /// then all members and constructors of the class inherit it.
+ ///
+ /// If multiple `@Since()` annotations apply to the same element, the latest
+ /// version takes precedence.
+ ///
+ /// Returns `null` if the element is not declared in SDK, or does not have
+ /// a `@Since()` annotation applicable to it.
+ Version? get sinceSdkVersion;
+
+ @override
+ Source? get source;
+
+ /// Uses the given [visitor] to visit this element.
+ ///
+ /// Returns the value returned by the visitor as a result of visiting this
+ /// element.
+ T? accept<T>(ElementVisitor<T> visitor);
+
+ /// Returns the presentation of this element as it should appear when
+ /// presented to users.
+ ///
+ /// If [withNullability] is `true`, then [NullabilitySuffix.question] and
+ /// [NullabilitySuffix.star] in types will be represented as `?` and `*`.
+ /// [NullabilitySuffix.none] does not have any explicit presentation.
+ ///
+ /// If [withNullability] is `false`, nullability suffixes will not be
+ /// included into the presentation.
+ ///
+ /// If [multiline] is `true`, the string may be wrapped over multiple lines
+ /// with newlines to improve formatting. For example function signatures may
+ /// be formatted as if they had trailing commas.
+ ///
+ /// Clients should not depend on the content of the returned value as it will
+ /// be changed if doing so would improve the UX.
+ String getDisplayString({
+ required bool withNullability,
+ bool multiline = false,
+ });
+
+ /// Returns 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 [displayName] 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);
+
+ /// Whether the 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 6.2:
+ /// <blockquote>
+ /// A declaration <i>m</i> is accessible to a 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);
+
+ /// Returns either this element or the most immediate ancestor of this element
+ /// for which the [predicate] returns `true`, or `null` if there is no such
+ /// element.
+ E? thisOrAncestorMatching<E extends Element>(
+ bool Function(Element) predicate,
+ );
+
+ /// Returns either this element or the most immediate ancestor of this element
+ /// that has the given type, or `null` if there is no such element.
+ E? thisOrAncestorOfType<E extends Element>();
+
+ /// Uses 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.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ElementAnnotation implements ConstantEvaluationTarget {
+ /// The errors that were produced while computing a value for this
+ /// annotation, or `null` if no value has been computed.
+ ///
+ /// If a value has been produced but no errors were generated, then the
+ /// list will be empty.
+ List<AnalysisError>? get constantEvaluationErrors;
+
+ /// Returns the element referenced by this annotation.
+ ///
+ /// In valid code this element can be a [PropertyAccessorElement] getter
+ /// of a constant top-level variable, or a constant static field of a
+ /// class; or a constant [ConstructorElement].
+ ///
+ /// In invalid code this element can be `null`, or a reference to any
+ /// other element.
+ Element? get element;
+
+ /// Whether the annotation marks the associated function as always throwing.
+ bool get isAlwaysThrows;
+
+ /// Whether the annotation marks the associated element as being deprecated.
+ bool get isDeprecated;
+
+ /// Whether the annotation marks the associated element as not to be stored.
+ bool get isDoNotStore;
+
+ /// Whether the annotation marks the associated member as a factory.
+ bool get isFactory;
+
+ /// Whether the annotation marks the associated class and its subclasses as
+ /// being immutable.
+ bool get isImmutable;
+
+ /// Whether the annotation marks the associated element as being internal to
+ /// its package.
+ bool get isInternal;
+
+ /// Whether the annotation marks the associated member as running a single
+ /// test.
+ bool get isIsTest;
+
+ /// Whether the annotation marks the associated member as running a test
+ /// group.
+ bool get isIsTestGroup;
+
+ /// Whether the annotation marks the associated element with the `JS`
+ /// annotation.
+ bool get isJS;
+
+ /// Whether the annotation marks the associated constructor as being literal.
+ bool get isLiteral;
+
+ /// Whether the annotation marks the associated member as requiring
+ /// subclasses to override this member.
+ bool get isMustBeOverridden;
+
+ /// Whether the annotation marks the associated member as requiring
+ /// overriding methods to call super.
+ bool get isMustCallSuper;
+
+ /// Whether the annotation marks the associated member as being non-virtual.
+ bool get isNonVirtual;
+
+ /// Whether the annotation marks the associated type as having "optional"
+ /// type arguments.
+ bool get isOptionalTypeArgs;
+
+ /// Whether the annotation marks the associated method as being expected to
+ /// override an inherited method.
+ bool get isOverride;
+
+ /// Whether the annotation marks the associated member as being protected.
+ bool get isProtected;
+
+ /// Whether the annotation marks the associated class as implementing a proxy
+ /// object.
+ bool get isProxy;
+
+ /// Whether the marks the associated member as being reopened.
+ bool get isReopen;
+
+ /// Whether the annotation marks the associated member as being required.
+ bool get isRequired;
+
+ /// Whether the annotation marks the associated class as being sealed.
+ bool get isSealed;
+
+ /// Whether the annotation marks the associated class as being intended to
+ /// be used as an annotation.
+ bool get isTarget;
+
+ /// Whether the annotation marks the associated returned element as
+ /// requiring use.
+ bool get isUseResult;
+
+ /// Whether the annotation marks the associated member as being visible for
+ /// overriding only.
+ bool get isVisibleForOverriding;
+
+ /// Whether the annotation marks the associated member as being visible for
+ /// template files.
+ bool get isVisibleForTemplate;
+
+ /// Whether the annotation marks the associated member as being visible for
+ /// testing.
+ bool get isVisibleForTesting;
+
+ /// Whether the annotation marks the associated member as being visible
+ /// outside of template files.
+ bool get isVisibleOutsideTemplate;
+
+ /// Returns a representation of the value of this annotation, forcing the
+ /// value to be computed if it had not previously been computed, or `null`
+ /// if the value of this annotation could not be computed because of errors.
+ DartObject? computeConstantValue();
+
+ /// Returns a textual description of this annotation in a form approximating
+ /// valid source.
+ ///
+ /// The returned string will not be valid source primarily in the case where
+ /// the annotation itself is not well-formed.
+ String toSource();
+}
+
/// A concrete implementation of an [ElementAnnotation].
class ElementAnnotationImpl implements ElementAnnotation {
/// The name of the top-level variable used to mark that a function always
@@ -2611,6 +3488,23 @@
}
}
+/// An element that represents an enum.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class EnumElement implements InterfaceElement {
+ @experimental
+ @override
+ EnumElement? get augmentation;
+
+ @experimental
+ @override
+ EnumElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedEnumElement? get augmented;
+}
+
/// An [InterfaceElementImpl] which is an enum.
class EnumElementImpl extends InterfaceElementImpl implements EnumElement {
late AugmentedEnumElement augmentedInternal =
@@ -2665,6 +3559,86 @@
}
}
+/// An element representing an executable object, including functions, methods,
+/// constructors, getters, and setters.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ExecutableElement implements FunctionTypedElement {
+ /// The immediate augmentation of this element, or `null` if there are no
+ /// augmentations.
+ ///
+ /// [ExecutableElement.augmentationTarget] will point back at this element.
+ @experimental
+ ExecutableElement? get augmentation;
+
+ /// The element that is augmented by this augmentation.
+ ///
+ /// The chain of augmentations normally ends with a [ExecutableElement] that
+ /// is not an augmentation, but might end with `null` immediately or after a
+ /// few intermediate [ExecutableElement]s in case of invalid code when an
+ /// augmentation is declared without the corresponding declaration.
+ @experimental
+ ExecutableElement? get augmentationTarget;
+
+ @override
+ ExecutableElement get declaration;
+
+ @override
+ String get displayName;
+
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ Element get enclosingElement;
+
+ @override
+ Element get enclosingElement2;
+
+ /// Whether the executable element did not have an explicit return type
+ /// specified for it in the original source.
+ bool get hasImplicitReturnType;
+
+ /// Whether the executable element is abstract.
+ ///
+ /// Executable elements are abstract if they are not external, and have no
+ /// body.
+ bool get isAbstract;
+
+ /// Whether the executable element has body marked as being asynchronous.
+ bool get isAsynchronous;
+
+ /// Whether the element is an augmentation.
+ ///
+ /// If `true`, declaration has the explicit `augment` modifier.
+ bool get isAugmentation;
+
+ /// Whether the executable element is external.
+ ///
+ /// Executable elements are external if they are explicitly marked as such
+ /// using the 'external' keyword.
+ bool get isExternal;
+
+ /// Whether the executable element has a body marked as being a generator.
+ bool get isGenerator;
+
+ /// Whether the 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;
+
+ /// Whether the 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;
+
+ /// Whether the executable element has a body marked as being synchronous.
+ bool get isSynchronous;
+
+ @override
+ String get name;
+}
+
/// A base class for concrete implementations of an [ExecutableElement].
abstract class ExecutableElementImpl extends _ExistingElementImpl
with TypeParameterizedElementMixin, HasCompletionData
@@ -2881,6 +3855,46 @@
}
}
+/// An element that represents an extension.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ExtensionElement implements InstanceElement {
+ @experimental
+ @override
+ ExtensionElement? get augmentation;
+
+ @experimental
+ @override
+ ExtensionElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedExtensionElement? get augmented;
+
+ /// The type that is extended by this extension.
+ DartType get extendedType;
+
+ /// Returns the element representing the field with the given [name] that is
+ /// declared in this extension, or `null` if this extension does not declare a
+ /// field with the given name.
+ FieldElement? getField(String name);
+
+ /// Returns the element representing the getter with the given [name] that is
+ /// declared in this extension, or `null` if this extension does not declare a
+ /// getter with the given name.
+ PropertyAccessorElement? getGetter(String name);
+
+ /// Returns the element representing the method with the given [name] that is
+ /// declared in this extension, or `null` if this extension does not declare a
+ /// method with the given name.
+ MethodElement? getMethod(String name);
+
+ /// Returns the element representing the setter with the given [name] that is
+ /// declared in this extension, or `null` if this extension does not declare a
+ /// setter with the given name.
+ PropertyAccessorElement? getSetter(String name);
+}
+
/// A concrete implementation of an [ExtensionElement].
class ExtensionElementImpl extends InstanceElementImpl
with HasCompletionData
@@ -3022,6 +4036,40 @@
}
}
+/// A field defined within a class.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class FieldElement
+ implements ClassMemberElement, PropertyInducingElement {
+ @override
+ FieldElement get declaration;
+
+ /// Whether the field is abstract.
+ ///
+ /// Executable fields are abstract if they are declared with the `abstract`
+ /// keyword.
+ bool get isAbstract;
+
+ /// Whether the field was explicitly marked as being covariant.
+ bool get isCovariant;
+
+ /// Whether the element is an enum constant.
+ bool get isEnumConstant;
+
+ /// Whether the field was explicitly marked as being external.
+ bool get isExternal;
+
+ /// Whether the field can be type promoted.
+ bool get isPromotable;
+
+ /// Whether the 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.
+ @override
+ bool get isStatic;
+}
+
/// A concrete implementation of a [FieldElement].
class FieldElementImpl extends PropertyInducingElementImpl
with HasCompletionData
@@ -3102,6 +4150,15 @@
T? accept<T>(ElementVisitor<T> visitor) => visitor.visitFieldElement(this);
}
+/// A field formal parameter defined within a constructor element.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class FieldFormalParameterElement implements ParameterElement {
+ /// 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.
class FieldFormalParameterElementImpl extends ParameterElementImpl
@@ -3134,6 +4191,43 @@
visitor.visitFieldFormalParameterElement(this);
}
+/// 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.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class FunctionElement implements ExecutableElement, LocalElement {
+ /// 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";
+
+ @experimental
+ @override
+ FunctionElement? get augmentation;
+
+ @experimental
+ @override
+ FunctionElement? get augmentationTarget;
+
+ /// Whether the function represents `identical` from the `dart:core` library.
+ bool get isDartCoreIdentical;
+
+ /// Whether the function is an entry point, i.e. a top-level function and
+ /// has the name `main`.
+ bool get isEntryPoint;
+}
+
/// A concrete implementation of a [FunctionElement].
class FunctionElementImpl extends ExecutableElementImpl
implements FunctionElement, FunctionTypedElementImpl {
@@ -3181,6 +4275,26 @@
T? accept<T>(ElementVisitor<T> visitor) => visitor.visitFunctionElement(this);
}
+/// An element that has a [FunctionType] as its [type].
+///
+/// This also provides convenient access to the parameters and return type.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class FunctionTypedElement implements TypeParameterizedElement {
+ /// The parameters defined by this executable element.
+ List<ParameterElement> get parameters;
+
+ /// The return type defined by this element.
+ @Deprecated('Use returnType2 instead')
+ DartType get returnType;
+
+ /// The return type defined by this element.
+ DartType get returnType2;
+
+ /// The type defined by this element.
+ FunctionType get type;
+}
+
/// Common internal interface shared by elements whose type is a function type.
///
/// Clients may not extend, implement or mix-in this class.
@@ -3189,6 +4303,11 @@
set returnType(DartType returnType);
}
+/// The pseudo-declaration that defines a generic function type.
+///
+/// Clients may not extend, implement, or mix-in this class.
+abstract class GenericFunctionTypeElement implements FunctionTypedElement {}
+
/// The element used for a generic function type.
///
/// Clients may not extend, implement or mix-in this class.
@@ -3310,6 +4429,16 @@
Object? completionData;
}
+/// A combinator that causes some of the names in a namespace to be hidden when
+/// being imported.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class HideElementCombinator implements NamespaceCombinator {
+ /// 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 {
@override
@@ -3330,6 +4459,15 @@
}
}
+/// Usage of a [PrefixElement] in an `import` directive.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ImportElementPrefix {
+ /// The prefix that was specified as part of the import directive, or `null`
+ /// if there was no prefix specified.
+ PrefixElement get element;
+}
+
class ImportElementPrefixImpl implements ImportElementPrefix {
@override
final PrefixElementImpl element;
@@ -3339,6 +4477,27 @@
});
}
+/// An element that represents an inline class.
+///
+/// Clients may not extend, implement or mix-in this class.
+@experimental
+abstract class InlineClassElement implements NamedInstanceElement {
+ @experimental
+ @override
+ InlineClassElement? get augmentation;
+
+ @experimental
+ @override
+ InlineClassElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedInlineClassElement? get augmented;
+
+ /// The direct [InlineClassType]s that are implemented by this inline class.
+ List<InlineClassType> get implemented;
+}
+
class InlineClassElementImpl extends NamedInstanceElementImpl
implements InlineClassElement {
InlineClassElementImpl(super.name, super.nameOffset);
@@ -3392,6 +4551,64 @@
}
}
+/// An element that has `this`.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class InstanceElement
+ implements TypeDefiningElement, TypeParameterizedElement {
+ /// The declared accessors (getters and setters).
+ List<PropertyAccessorElement> get accessors;
+
+ /// The immediate augmentation of this element, or `null` if there are no
+ /// augmentations.
+ ///
+ /// [InstanceElement.augmentationTarget] will point back at this element.
+ @experimental
+ InstanceElement? get augmentation;
+
+ /// The element that is augmented by this augmentation; or `null` if
+ /// [isAugmentation] is `false`, or there is no corresponding element to be
+ /// augmented.
+ ///
+ /// The chain of augmentations should normally end with a not augmentation
+ /// [InstanceElement], but might end with `null` immediately or after a few
+ /// intermediate elements in case of invalid code when an augmentation is
+ /// declared without the corresponding declaration.
+ @experimental
+ InstanceElement? get augmentationTarget;
+
+ /// The result of applying augmentations.
+ @experimental
+ AugmentedInstanceElement? get augmented;
+
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ CompilationUnitElement get enclosingElement;
+
+ @override
+ CompilationUnitElement get enclosingElement2;
+
+ /// The declared fields.
+ List<FieldElement> get fields;
+
+ /// Whether the element is an augmentation.
+ ///
+ /// If `true`, declaration has the explicit `augment` modifier.
+ bool get isAugmentation;
+
+ /// The declared methods.
+ List<MethodElement> get methods;
+
+ /// The type of `this` expression.
+ ///
+ /// For a class like `class MyClass<T, U> {}` the returned type is equivalent
+ /// to the type `MyClass<T, U>`. So, the type arguments are the types of the
+ /// type parameters, and either `none` or `star` is used for the nullability
+ /// suffix is used, depending on the nullability status of the declaring
+ /// library.
+ DartType get thisType;
+}
+
abstract class InstanceElementImpl extends _ExistingElementImpl
with TypeParameterizedElementMixin
implements InstanceElement {
@@ -3495,6 +4712,250 @@
}
}
+/// An element that defines an [InterfaceType].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class InterfaceElement implements NamedInstanceElement {
+ /// All the supertypes defined for this element and its supertypes.
+ ///
+ /// This includes superclasses, mixins, interfaces, and superclass constraints.
+ List<InterfaceType> get allSupertypes;
+
+ @override
+ InterfaceElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedInterfaceElement? get augmented;
+
+ /// 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;
+
+ /// The mixins that are applied to the class being extended in order to
+ /// derive the superclass of this class.
+ ///
+ /// [ClassElement] and [EnumElement] can have mixins.
+ ///
+ /// [MixinElement] cannot have mixins, so the empty list is 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.
+ List<InterfaceType> get mixins;
+
+ /// The superclass of this element.
+ ///
+ /// For [ClassElement] returns `null` only if this class is `Object`. If the
+ /// superclass is not explicitly specified, or the superclass cannot be
+ /// resolved, then the implicit superclass `Object` is returned.
+ ///
+ /// For [EnumElement] returns `Enum` from `dart:core`.
+ ///
+ /// For [MixinElement] always returns `null`.
+ ///
+ /// <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 thisType;
+
+ /// The field (synthetic or explicit) defined directly in this class or
+ /// augmentation that has the given [name].
+ /// TODO(scheglov) Deprecate and remove it.
+ FieldElement? getField(String name);
+
+ /// The getter (synthetic or explicit) defined directly in this class or
+ /// augmentation that has the given [name].
+ /// TODO(scheglov) Deprecate and remove it.
+ PropertyAccessorElement? getGetter(String name);
+
+ /// The method defined directly in this class or augmentation that has the
+ /// given [name].
+ /// TODO(scheglov) Deprecate and remove it.
+ MethodElement? getMethod(String name);
+
+ /// The setter (synthetic or explicit) defined directly in this class or
+ /// augmentation that has the given [name].
+ /// TODO(scheglov) Deprecate and remove it.
+ PropertyAccessorElement? getSetter(String name);
+
+ @override
+ InterfaceType instantiate({
+ required List<DartType> typeArguments,
+ required NullabilitySuffix nullabilitySuffix,
+ });
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ MethodElement? lookUpConcreteMethod(
+ String methodName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ PropertyAccessorElement? lookUpGetter(
+ String getterName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ PropertyAccessorElement? lookUpInheritedConcreteGetter(
+ String getterName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ MethodElement? lookUpInheritedConcreteMethod(
+ String methodName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ PropertyAccessorElement? lookUpInheritedConcreteSetter(
+ String setterName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ MethodElement? lookUpInheritedMethod(
+ String methodName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ MethodElement? lookUpMethod(String methodName, LibraryElement library);
+
+ /// Returns 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>
+ /// TODO(scheglov) Deprecate and remove it.
+ PropertyAccessorElement? lookUpSetter(
+ String setterName, LibraryElement library);
+}
+
abstract class InterfaceElementImpl extends NamedInstanceElementImpl
with HasCompletionData, MacroTargetElement
implements InterfaceElement {
@@ -3894,6 +5355,19 @@
}
}
+/// A pattern variable that is a join of other pattern variables, created
+/// for a logical-or patterns, or shared `case` bodies in `switch` statements.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class JoinPatternVariableElement implements PatternVariableElement {
+ /// Whether the [variables] are consistent, present in all branches,
+ /// and have the same type and finality.
+ bool get isConsistent;
+
+ /// The variables that join into this variable.
+ List<PatternVariableElement> get variables;
+}
+
class JoinPatternVariableElementImpl extends PatternVariableElementImpl
implements JoinPatternVariableElement {
@override
@@ -3944,6 +5418,21 @@
bool operator ==(Object other) => identical(other, this);
}
+/// A label associated with a statement.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class LabelElement implements Element {
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ ExecutableElement get enclosingElement;
+
+ @override
+ ExecutableElement get enclosingElement2;
+
+ @override
+ String get name;
+}
+
/// A concrete implementation of a [LabelElement].
class LabelElementImpl extends ElementImpl implements LabelElement {
/// A flag indicating whether this label is associated with a `switch` member
@@ -3982,6 +5471,16 @@
T? accept<T>(ElementVisitor<T> visitor) => visitor.visitLabelElement(this);
}
+/// A library augmentation.
+///
+/// Clients may not extend, implement or mix-in this class.
+@experimental
+abstract class LibraryAugmentationElement
+ implements LibraryOrAugmentationElement, _ExistingElement {
+ /// The library that is augmented by this augmentation.
+ LibraryOrAugmentationElement get augmentationTarget;
+}
+
class LibraryAugmentationElementImpl extends LibraryOrAugmentationElementImpl
implements LibraryAugmentationElement {
@override
@@ -4055,6 +5554,87 @@
}
}
+/// A library.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class LibraryElement
+ implements LibraryOrAugmentationElement, _ExistingElement {
+ /// 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;
+
+ /// The libraries that are exported from this library.
+ List<LibraryElement> get exportedLibraries;
+
+ /// The export [Namespace] of this library.
+ Namespace get exportNamespace;
+
+ /// The identifier that uniquely identifies this element among the children
+ /// of this element's parent.
+ String get identifier;
+
+ /// The libraries that are imported into this library.
+ ///
+ /// This includes all of the libraries that are imported using a prefix, and
+ /// those that are imported without a prefix.
+ List<LibraryElement> get importedLibraries;
+
+ /// Whether the library is an application that can be run in the browser.
+ bool get isBrowserApplication;
+
+ /// Whether the library is the `dart:async` library.
+ bool get isDartAsync;
+
+ /// Whether the library is the `dart:core` library.
+ bool get isDartCore;
+
+ /// Whether the library is part of the SDK.
+ bool get isInSdk;
+
+ /// 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;
+
+ /// The name of this library, possibly the empty string if this library does
+ /// not have an explicit name.
+ @override
+ String get name;
+
+ /// The list of `part` directives of this library.
+ List<PartElement> get parts;
+
+ /// The public [Namespace] of this library.
+ Namespace get publicNamespace;
+
+ /// The top-level elements defined in each of the compilation units that are
+ /// included in this library. This includes both public and private elements,
+ /// but does not include imports, exports, or synthetic elements.
+ Iterable<Element> get topLevelElements;
+
+ /// The compilation units this library consists of.
+ ///
+ /// This includes the defining compilation unit and units included using the
+ /// `part` directive.
+ List<CompilationUnitElement> get units;
+
+ /// 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? getClass(String name);
+
+ /// If a legacy library, returns the legacy view on the [element].
+ ///
+ /// Otherwise, return the original element.
+ T toLegacyElementIfOptOut<T extends Element>(T element);
+
+ /// If a legacy library, return the legacy version of the [type].
+ /// Otherwise, return the original type.
+ DartType toLegacyTypeIfOptOut(DartType type);
+}
+
/// A concrete implementation of a [LibraryElement].
class LibraryElementImpl extends LibraryOrAugmentationElementImpl
with _HasLibraryMixin
@@ -4542,6 +6122,24 @@
}
}
+/// A single export directive within a library.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class LibraryExportElement implements _ExistingElement {
+ /// The combinators that were specified as part of the `export` directive in
+ /// the order in which they were specified.
+ List<NamespaceCombinator> get combinators;
+
+ /// The [LibraryElement], if [uri] is a [DirectiveUriWithLibrary].
+ LibraryElement? get exportedLibrary;
+
+ /// The offset of the `export` keyword.
+ int get exportKeywordOffset;
+
+ /// The interpretation of the URI specified in the directive.
+ DirectiveUri get uri;
+}
+
class LibraryExportElementImpl extends _ExistingElementImpl
implements LibraryExportElement {
@override
@@ -4593,6 +6191,31 @@
}
}
+/// A single import directive within a library.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class LibraryImportElement implements _ExistingElement {
+ /// The combinators that were specified as part of the `import` directive in
+ /// the order in which they were specified.
+ List<NamespaceCombinator> get combinators;
+
+ /// The [LibraryElement], if [uri] is a [DirectiveUriWithLibrary].
+ LibraryElement? get importedLibrary;
+
+ /// The offset of the `import` keyword.
+ int get importKeywordOffset;
+
+ /// The [Namespace] that this directive contributes to the containing library.
+ Namespace get namespace;
+
+ /// The prefix that was specified as part of the import directive, or `null`
+ /// if there was no prefix specified.
+ ImportElementPrefix? get prefix;
+
+ /// The interpretation of the URI specified in the directive.
+ DirectiveUri get uri;
+}
+
class LibraryImportElementImpl extends _ExistingElementImpl
implements LibraryImportElement {
@override
@@ -4664,6 +6287,63 @@
}
}
+/// Shared interface between [LibraryElement] and [LibraryAugmentationElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+@experimental
+abstract class LibraryOrAugmentationElement implements Element {
+ /// The extension elements accessible within this library.
+ List<ExtensionElement> get accessibleExtensions;
+
+ /// The augmentation imports specified in this library.
+ @experimental
+ List<AugmentationImportElement> get augmentationImports;
+
+ /// The compilation unit that defines this library.
+ CompilationUnitElement get definingCompilationUnit;
+
+ /// The set of features available to this library.
+ ///
+ /// Determined by the combination of the language version for the enclosing
+ /// package, enabled experiments, and the presence of a `// @dart` language
+ /// version override comment at the top of the file.
+ FeatureSet get featureSet;
+
+ bool get isNonNullableByDefault;
+
+ /// The language version for this library.
+ LibraryLanguageVersion get languageVersion;
+
+ @override
+ LibraryElement get library;
+
+ /// The exports defined in this library.
+ List<LibraryExportElement> get libraryExports;
+
+ /// The imports defined in this library.
+ List<LibraryImportElement> get libraryImports;
+
+ /// 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 name lookup scope for this library.
+ ///
+ /// It consists of elements that are either declared in the library, or
+ /// imported into it.
+ Scope get scope;
+
+ @override
+ AnalysisSession get session;
+
+ /// The [TypeProvider] that is used in this library.
+ TypeProvider get typeProvider;
+
+ /// The [TypeSystem] that is used in this library.
+ TypeSystem get typeSystem;
+}
+
/// A concrete implementation of a [LibraryOrAugmentationElement].
abstract class LibraryOrAugmentationElementImpl extends ElementImpl
implements LibraryOrAugmentationElement, MacroTargetElementContainer {
@@ -4807,6 +6487,23 @@
}
}
+/// An element that can be (but is not required to be) defined within a method
+/// or function (an [ExecutableElement]).
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class LocalElement implements Element {}
+
+/// A local variable.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class LocalVariableElement implements PromotableElement {
+ /// Whether the variable has an initializer at declaration.
+ bool get hasInitializer;
+
+ @override
+ String get name;
+}
+
/// A concrete implementation of a [LocalVariableElement].
class LocalVariableElementImpl extends NonParameterVariableElementImpl
implements LocalVariableElement {
@@ -4847,6 +6544,22 @@
/// Marker interface for elements that may have [MacroTargetElement]s.
class MacroTargetElementContainer {}
+/// An element that represents a method defined within a class.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class MethodElement implements ClassMemberElement, ExecutableElement {
+ @experimental
+ @override
+ MethodElement? get augmentation;
+
+ @experimental
+ @override
+ MethodElement? get augmentationTarget;
+
+ @override
+ MethodElement get declaration;
+}
+
/// A concrete implementation of a [MethodElement].
class MethodElementImpl extends ExecutableElementImpl
with _HasAugmentation<MethodElementImpl>
@@ -4923,6 +6636,45 @@
T? accept<T>(ElementVisitor<T> visitor) => visitor.visitMethodElement(this);
}
+/// An element that represents a mixin.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class MixinElement implements InterfaceElement {
+ @experimental
+ @override
+ MixinElement? get augmentation;
+
+ @experimental
+ @override
+ MixinElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedMixinElement? get augmented;
+
+ /// Whether the mixin is a base mixin.
+ ///
+ /// A mixin is a base mixin if it has an explicit `base` modifier.
+ /// The base modifier allows a mixin to be mixed in, but not implemented.
+ bool get isBase;
+
+ /// The superclass constraints defined for this mixin.
+ ///
+ /// If the declaration does not have an `on` clause, then the list will
+ /// contain the type for the class `Object`.
+ ///
+ /// <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 superclassConstraints;
+
+ /// Whether the element, assuming that it is within scope, is
+ /// implementable to classes, mixins, and enums in the given [library].
+ bool isImplementableIn(LibraryElement library);
+}
+
/// A [ClassElementImpl] representing a mixin declaration.
class MixinElementImpl extends ClassOrMixinElementImpl
with _HasAugmentation<MixinElementImpl>
@@ -5181,6 +6933,18 @@
String toString() => name;
}
+/// 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.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class MultiplyDefinedElement implements Element {
+ /// The elements that were defined within the scope to have the same name.
+ List<Element> get conflictingElements;
+}
+
/// A concrete implementation of a [MultiplyDefinedElement].
class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
/// The unique integer identifier of this element.
@@ -5417,6 +7181,55 @@
}
}
+/// An [ExecutableElement], with the additional information of a list of
+/// [ExecutableElement]s from which this element was composed.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class MultiplyInheritedExecutableElement implements ExecutableElement {
+ /// The executable elements defined within this executable element.
+ List<ExecutableElement> get inheritedElements;
+}
+
+/// An element that represents a named [InstanceElement].
+///
+/// Clients may not extend, implement or mix-in this class.
+@experimental
+abstract class NamedInstanceElement implements InstanceElement {
+ @override
+ NamedInstanceElement? get augmentationTarget;
+
+ @experimental
+ @override
+ AugmentedNamedInstanceElement? get augmented;
+
+ /// The declared constructors.
+ ///
+ /// The list is empty for [MixinElement].
+ List<ConstructorElement> get constructors;
+
+ @override
+ String get name;
+
+ /// The unnamed constructor declared directly in this class.
+ ///
+ /// If the class does not declare any constructors, a synthetic default
+ /// constructor will be returned.
+ /// TODO(scheglov) Deprecate and remove it.
+ ConstructorElement? get unnamedConstructor;
+
+ /// The constructor defined directly in this class or augmentation
+ /// that has the given [name].
+ /// TODO(scheglov) Deprecate and remove it.
+ ConstructorElement? getNamedConstructor(String name);
+
+ /// Create the [DartType] for this element with the given [typeArguments]
+ /// and [nullabilitySuffix].
+ DartType instantiate({
+ required List<DartType> typeArguments,
+ required NullabilitySuffix nullabilitySuffix,
+ });
+}
+
abstract class NamedInstanceElementImpl extends InstanceElementImpl
implements NamedInstanceElement {
List<ConstructorElementImpl> _constructors = _Sentinel.constructorElement;
@@ -5470,6 +7283,11 @@
void _buildMixinAppConstructors() {}
}
+/// An object that controls how namespaces are combined.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class NamespaceCombinator {}
+
/// The synthetic element representing the declaration of the type `Never`.
class NeverElementImpl extends ElementImpl implements TypeDefiningElement {
/// The unique instance of this class.
@@ -5702,6 +7520,107 @@
}
}
+/// A parameter defined within an executable element.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ParameterElement
+ implements PromotableElement, ConstantEvaluationTarget {
+ @override
+ ParameterElement get declaration;
+
+ /// The code of the default value, or `null` if no default value.
+ String? get defaultValueCode;
+
+ /// Whether the parameter has a default value.
+ bool get hasDefaultValue;
+
+ /// Whether the parameter is covariant, meaning it is allowed to have a
+ /// narrower type in an override.
+ bool get isCovariant;
+
+ /// Whether the parameter is an initializing formal parameter.
+ bool get isInitializingFormal;
+
+ /// Whether the parameter is a named parameter.
+ ///
+ /// Named parameters that are annotated with the `@required` annotation are
+ /// considered optional. Named parameters that are annotated with the
+ /// `required` syntax are considered required.
+ bool get isNamed;
+
+ /// Whether the parameter is an optional parameter.
+ ///
+ /// Optional parameters can either be positional or named. Named parameters
+ /// that are annotated with the `@required` annotation are considered
+ /// optional. Named parameters that are annotated with the `required` syntax
+ /// are considered required.
+ bool get isOptional;
+
+ /// Whether the parameter is both an optional and named parameter.
+ ///
+ /// Named parameters that are annotated with the `@required` annotation are
+ /// considered optional. Named parameters that are annotated with the
+ /// `required` syntax are considered required.
+ bool get isOptionalNamed;
+
+ /// Whether the parameter is both an optional and positional parameter.
+ bool get isOptionalPositional;
+
+ /// Whether the parameter is a positional parameter.
+ ///
+ /// Positional parameters can either be required or optional.
+ bool get isPositional;
+
+ /// Whether the parameter is either a required positional parameter, or a
+ /// named parameter with the `required` keyword.
+ ///
+ /// Note: the presence or absence of the `@required` annotation does not
+ /// change the meaning of this getter. The parameter `{@required int x}`
+ /// will return `false` and the parameter `{@required required int x}`
+ /// will return `true`.
+ bool get isRequired;
+
+ /// Whether the parameter is both a required and named parameter.
+ ///
+ /// Named parameters that are annotated with the `@required` annotation are
+ /// considered optional. Named parameters that are annotated with the
+ /// `required` syntax are considered required.
+ bool get isRequiredNamed;
+
+ /// Whether the parameter is both a required and positional parameter.
+ bool get isRequiredPositional;
+
+ /// Whether the parameter is a super formal parameter.
+ bool get isSuperFormal;
+
+ @override
+ String get name;
+
+ /// The kind of this parameter.
+ @Deprecated('Use the getters isOptionalNamed, isOptionalPositional, '
+ 'isRequiredNamed, and isRequiredPositional')
+ ParameterKind get parameterKind;
+
+ /// The parameters defined by this parameter.
+ ///
+ /// A parameter will only define other parameters if it is a function typed
+ /// parameter.
+ List<ParameterElement> get parameters;
+
+ /// The type parameters defined by this parameter.
+ ///
+ /// A parameter will only define type parameters if it is a function typed
+ /// parameter.
+ List<TypeParameterElement> get typeParameters;
+
+ /// Appends the type, name and possibly the default value of this parameter
+ /// to the given [buffer].
+ void appendToWithoutDelimiters(
+ StringBuffer buffer, {
+ bool withNullability = false,
+ });
+}
+
/// A concrete implementation of a [ParameterElement].
class ParameterElementImpl extends VariableElementImpl
with ParameterElementMixin
@@ -5943,6 +7862,14 @@
}
}
+/// A 'part' directive within a library.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class PartElement implements _ExistingElement {
+ /// The interpretation of the URI specified in the directive.
+ DirectiveUri get uri;
+}
+
class PartElementImpl extends _ExistingElementImpl implements PartElement {
@override
final DirectiveUri uri;
@@ -5972,6 +7899,15 @@
}
}
+/// A pattern variable.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class PatternVariableElement implements LocalVariableElement {
+ /// The variable in which this variable joins with other pattern variables
+ /// with the same name, in a logical-or pattern, or shared case scope.
+ JoinPatternVariableElement? get join;
+}
+
class PatternVariableElementImpl extends LocalVariableElementImpl
implements PatternVariableElement {
@override
@@ -5989,6 +7925,33 @@
}
}
+/// A prefix used to import one or more libraries into another library.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class PrefixElement implements _ExistingElement {
+ /// The library, or library augmentation that encloses this element.
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ LibraryOrAugmentationElement get enclosingElement;
+
+ /// The library, or library augmentation that encloses this element.
+ @override
+ LibraryOrAugmentationElement get enclosingElement2;
+
+ /// The imports that share this prefix.
+ List<LibraryImportElement> get imports;
+
+ @override
+ String get name;
+
+ /// The name lookup scope for this import prefix.
+ ///
+ /// It consists of elements imported into the enclosing library with this
+ /// prefix. The namespace combinators of the import directives are taken
+ /// into account.
+ Scope get scope;
+}
+
/// A concrete implementation of a [PrefixElement].
class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
/// The scope of this prefix, `null` if it has not been created yet.
@@ -6037,6 +8000,71 @@
}
}
+/// A variable that might be subject to type promotion. This might be a local
+/// variable or a parameter.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class PromotableElement implements LocalElement, VariableElement {
+ // Promotable elements are guaranteed to have a name.
+ @override
+ String get name;
+}
+
+/// 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].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class PropertyAccessorElement implements ExecutableElement {
+ @experimental
+ @override
+ PropertyAccessorElement? get augmentation;
+
+ @experimental
+ @override
+ PropertyAccessorElement? get augmentationTarget;
+
+ /// 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;
+
+ /// 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;
+
+ @override
+ PropertyAccessorElement get declaration;
+
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ Element get enclosingElement;
+
+ @override
+ Element get enclosingElement2;
+
+ /// Whether the accessor represents a getter.
+ bool get isGetter;
+
+ /// Whether the accessor represents a setter.
+ bool get isSetter;
+
+ /// 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;
+}
+
/// A concrete implementation of a [PropertyAccessorElement].
class PropertyAccessorElementImpl extends ExecutableElementImpl
with _HasAugmentation<PropertyAccessorElementImpl>
@@ -6311,6 +8339,54 @@
}
}
+/// 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].
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class PropertyInducingElement implements VariableElement {
+ @override
+ String get displayName;
+
+ /// 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;
+
+ /// Whether the variable has an initializer at declaration.
+ bool get hasInitializer;
+
+ @override
+ LibraryElement get library;
+
+ @override
+ String get name;
+
+ /// 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 NonParameterVariableElementImpl implements PropertyInducingElement {
@@ -6461,6 +8537,23 @@
DartType perform();
}
+/// A combinator that cause some of the names in a namespace to be visible (and
+/// the rest hidden) when being imported.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class ShowElementCombinator implements NamespaceCombinator {
+ /// The offset of the character immediately following the last character of
+ /// this node.
+ int get end;
+
+ /// The offset of the 'show' keyword of this element.
+ int get offset;
+
+ /// 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 {
@override
@@ -6487,6 +8580,19 @@
}
}
+/// A super formal parameter defined within a constructor element.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class SuperFormalParameterElement implements ParameterElement {
+ /// The associated super-constructor parameter, from the super-constructor
+ /// that is referenced by the implicit or explicit super-constructor
+ /// invocation.
+ ///
+ /// Can be `null` for erroneous code - not existing super-constructor,
+ /// no corresponding parameter in the super-constructor.
+ ParameterElement? get superConstructorParameter;
+}
+
class SuperFormalParameterElementImpl extends ParameterElementImpl
implements SuperFormalParameterElement {
/// Initialize a newly created parameter element to have the given [name] and
@@ -6541,6 +8647,17 @@
}
}
+/// A top-level variable.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class TopLevelVariableElement implements PropertyInducingElement {
+ @override
+ TopLevelVariableElement get declaration;
+
+ /// Whether the field was explicitly marked as being external.
+ bool get isExternal;
+}
+
/// A concrete implementation of a [TopLevelVariableElement].
class TopLevelVariableElementImpl extends PropertyInducingElementImpl
with HasCompletionData
@@ -6574,6 +8691,48 @@
visitor.visitTopLevelVariableElement(this);
}
+/// A type alias (`typedef`).
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class TypeAliasElement
+ implements TypeParameterizedElement, TypeDefiningElement {
+ /// If the aliased type has structure, return the corresponding element.
+ /// For example it could be [GenericFunctionTypeElement].
+ ///
+ /// If there is no structure, return `null`.
+ Element? get aliasedElement;
+
+ /// The aliased type.
+ ///
+ /// If non-function type aliases feature is enabled for the enclosing library,
+ /// this type might be just anything. If the feature is disabled, return
+ /// a [FunctionType].
+ DartType get aliasedType;
+
+ @Deprecated('Use enclosingElement2 instead')
+ @override
+ CompilationUnitElement get enclosingElement;
+
+ @override
+ CompilationUnitElement get enclosingElement2;
+
+ @override
+ String get name;
+
+ /// Produces the type resulting from instantiating this typedef with the given
+ /// [typeArguments] and [nullabilitySuffix].
+ ///
+ /// Note that this always instantiates the typedef itself, so for a
+ /// [TypeAliasElement] the returned [DartType] might still be a generic
+ /// type, with type formals. For example, if the typedef is:
+ /// typedef F<T> = void Function<U>(T, U);
+ /// then `F<int>` will produce `void Function<U>(int, U)`.
+ DartType instantiate({
+ required List<DartType> typeArguments,
+ required NullabilitySuffix nullabilitySuffix,
+ });
+}
+
/// An element that represents [GenericTypeAlias].
///
/// Clients may not extend, implement or mix-in this class.
@@ -6808,6 +8967,37 @@
}
}
+/// An element that defines a type.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class TypeDefiningElement implements Element {}
+
+/// A type parameter.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class TypeParameterElement implements TypeDefiningElement {
+ /// The type representing the bound associated with this parameter, or `null`
+ /// if this parameter does not have an explicit bound. Being able to
+ /// distinguish between an implicit and explicit bound is needed by the
+ /// instantiate to bounds algorithm.
+ DartType? get bound;
+
+ @override
+ TypeParameterElement get declaration;
+
+ @override
+ String get displayName;
+
+ @override
+ String get name;
+
+ /// Creates the [TypeParameterType] with the given [nullabilitySuffix] for
+ /// this type parameter.
+ TypeParameterType instantiate({
+ required NullabilitySuffix nullabilitySuffix,
+ });
+}
+
/// A concrete implementation of a [TypeParameterElement].
class TypeParameterElementImpl extends ElementImpl
implements TypeParameterElement {
@@ -6904,6 +9094,25 @@
}
}
+/// An element that has type parameters, such as a class or a typedef. This also
+/// includes functions and methods if support for generic methods is enabled.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class TypeParameterizedElement implements _ExistingElement {
+ /// If the element defines a type, indicates whether the type may safely
+ /// appear without explicit type parameters as the bounds of a type parameter
+ /// declaration.
+ ///
+ /// If the element does not define a type, returns `true`.
+ bool get isSimplyBounded;
+
+ /// The type parameters declared by this element directly.
+ ///
+ /// This does not include type parameters that are declared by any enclosing
+ /// elements.
+ List<TypeParameterElement> get typeParameters;
+}
+
/// Mixin representing an element which can have type parameters.
mixin TypeParameterizedElementMixin
implements _ExistingElementImpl, TypeParameterizedElement {
@@ -6924,6 +9133,30 @@
}
}
+/// 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.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class UndefinedElement implements Element {}
+
+/// An element included into a library using some URI.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class UriReferencedElement implements _ExistingElement {
+ /// 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;
+
+ /// The offset of the character immediately following the last character of
+ /// this node's URI, or `-1` for synthetic import.
+ int get uriEnd;
+
+ /// 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 _ExistingElementImpl
implements UriReferencedElement {
@@ -6972,6 +9205,57 @@
}
}
+/// A variable. There are more specific subclasses for more specific kinds of
+/// variables.
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class VariableElement implements Element, ConstantEvaluationTarget {
+ @override
+ VariableElement get declaration;
+
+ /// Whether the variable element did not have an explicit type specified
+ /// for it.
+ bool get hasImplicitType;
+
+ /// Whether the variable was declared with the 'const' modifier.
+ bool get isConst;
+
+ /// Whether the 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;
+
+ /// Whether the variable uses late evaluation semantics.
+ ///
+ /// This will always return `false` unless the experiment 'non-nullable' is
+ /// enabled.
+ bool get isLate;
+
+ /// Whether the 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;
+
+ @override
+ String get name;
+
+ /// The declared type of this variable.
+ DartType get type;
+
+ /// Returns a representation of the value of this variable, forcing the value
+ /// to be computed if it had not previously been computed, or `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? computeConstantValue();
+}
+
/// A concrete implementation of a [VariableElement].
abstract class VariableElementImpl extends ElementImpl
implements VariableElement {
@@ -7089,6 +9373,22 @@
DartObject? computeConstantValue() => null;
}
+/// This class exists to provide non-nullable overrides for existing elements,
+/// as opposite to artificial "multiply defined" element.
+abstract class _ExistingElement implements Element {
+ @override
+ Element get declaration;
+
+ @override
+ LibraryElement get library;
+
+ @override
+ Source get librarySource;
+
+ @override
+ Source get source;
+}
+
abstract class _ExistingElementImpl extends ElementImpl with _HasLibraryMixin {
_ExistingElementImpl(super.name, super.offset, {super.reference});
}
diff --git a/pkg/analyzer/lib/src/dart/element/extensions.dart b/pkg/analyzer/lib/src/dart/element/extensions.dart
index 725ef73..deafed3 100644
--- a/pkg/analyzer/lib/src/dart/element/extensions.dart
+++ b/pkg/analyzer/lib/src/dart/element/extensions.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
index 58b05f0..10946d8 100644
--- a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
@@ -13,7 +13,6 @@
Expression,
InvocationExpression,
SimpleIdentifier;
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart' show ErrorReporter;
import 'package:analyzer/src/dart/ast/extensions.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart b/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
index 16f5abc..35dc97e 100644
--- a/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
+++ b/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
@@ -4,7 +4,6 @@
import 'dart:math' show max;
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/normalize.dart b/pkg/analyzer/lib/src/dart/element/normalize.dart
index d924a44..20abd06 100644
--- a/pkg/analyzer/lib/src/dart/element/normalize.dart
+++ b/pkg/analyzer/lib/src/dart/element/normalize.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart b/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart
index 9956ee2..572b854 100644
--- a/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_visitor.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/runtime_type_equality.dart b/pkg/analyzer/lib/src/dart/element/runtime_type_equality.dart
index 5364c58..f9a411f 100644
--- a/pkg/analyzer/lib/src/dart/element/runtime_type_equality.dart
+++ b/pkg/analyzer/lib/src/dart/element/runtime_type_equality.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_visitor.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/scope.dart b/pkg/analyzer/lib/src/dart/element/scope.dart
index 7884ca1..ea97427 100644
--- a/pkg/analyzer/lib/src/dart/element/scope.dart
+++ b/pkg/analyzer/lib/src/dart/element/scope.dart
@@ -4,7 +4,6 @@
import 'package:_fe_analyzer_shared/src/scanner/string_canonicalizer.dart';
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary2/combinator.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/subtype.dart b/pkg/analyzer/lib/src/dart/element/subtype.dart
index 1138b13..2966484 100644
--- a/pkg/analyzer/lib/src/dart/element/subtype.dart
+++ b/pkg/analyzer/lib/src/dart/element/subtype.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/top_merge.dart b/pkg/analyzer/lib/src/dart/element/top_merge.dart
index a0bf1fa..cef2c45 100644
--- a/pkg/analyzer/lib/src/dart/element/top_merge.dart
+++ b/pkg/analyzer/lib/src/dart/element/top_merge.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/type_algebra.dart b/pkg/analyzer/lib/src/dart/element/type_algebra.dart
index 96af702..4df9716 100644
--- a/pkg/analyzer/lib/src/dart/element/type_algebra.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_algebra.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_visitor.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart b/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart
index 95ecafd..fe35d2f 100644
--- a/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart
index bd98d34..904d6c8 100644
--- a/pkg/analyzer/lib/src/dart/element/type_system.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_system.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/ast/ast.dart' show AstNode;
import 'package:analyzer/dart/ast/token.dart' show TokenType;
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/analyzer/lib/src/dart/micro/utils.dart b/pkg/analyzer/lib/src/dart/micro/utils.dart
index f6e6276..5792026 100644
--- a/pkg/analyzer/lib/src/dart/micro/utils.dart
+++ b/pkg/analyzer/lib/src/dart/micro/utils.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/element_locator.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart b/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
index 26a1072..3a0f16d 100644
--- a/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/generic_inferrer.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart
index 6d6a55a..485cbfb 100644
--- a/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart
index 6b632a7..85181fe 100644
--- a/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
index 963cb13..8fe1b6f 100644
--- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart
index bd00f85..60919e7 100644
--- a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/dart/element/type.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/prefixed_identifier_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/prefixed_identifier_resolver.dart
index f67112a..7940b51 100644
--- a/pkg/analyzer/lib/src/dart/resolver/prefixed_identifier_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/prefixed_identifier_resolver.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
index 01fe63a..03538df 100644
--- a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
@@ -7,7 +7,6 @@
import 'package:_fe_analyzer_shared/src/type_inference/variable_bindings.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/dart/element/type.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/scope.dart b/pkg/analyzer/lib/src/dart/resolver/scope.dart
index 06b8664..d5fb40e 100644
--- a/pkg/analyzer/lib/src/dart/resolver/scope.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/scope.dart
@@ -5,7 +5,6 @@
import 'dart:collection';
import 'package:_fe_analyzer_shared/src/scanner/string_canonicalizer.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/simple_identifier_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/simple_identifier_resolver.dart
index edc5496..4565f8c 100644
--- a/pkg/analyzer/lib/src/dart/resolver/simple_identifier_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/simple_identifier_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
index fc638df..f75cf2c 100644
--- a/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/syntactic_entity.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/diagnostic/diagnostic.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
index 80737f3..b92439f 100644
--- a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
index 38e732e..c59a5d2 100644
--- a/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/dart/resolver/variance.dart b/pkg/analyzer/lib/src/dart/resolver/variance.dart
index b248774..492618d 100644
--- a/pkg/analyzer/lib/src/dart/resolver/variance.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/variance.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/error/assignment_verifier.dart b/pkg/analyzer/lib/src/error/assignment_verifier.dart
index c0dd0c4..3a1bad3 100644
--- a/pkg/analyzer/lib/src/error/assignment_verifier.dart
+++ b/pkg/analyzer/lib/src/error/assignment_verifier.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/error/base_or_final_type_verifier.dart b/pkg/analyzer/lib/src/error/base_or_final_type_verifier.dart
index ca9b8dd..e022021 100644
--- a/pkg/analyzer/lib/src/error/base_or_final_type_verifier.dart
+++ b/pkg/analyzer/lib/src/error/base_or_final_type_verifier.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/diagnostic/diagnostic.dart';
import 'package:analyzer/error/listener.dart';
diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
index 3ade523..942a914 100644
--- a/pkg/analyzer/lib/src/error/best_practices_verifier.dart
+++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
@@ -8,7 +8,6 @@
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
diff --git a/pkg/analyzer/lib/src/error/constructor_fields_verifier.dart b/pkg/analyzer/lib/src/error/constructor_fields_verifier.dart
index 13fe69c..0edcaf7 100644
--- a/pkg/analyzer/lib/src/error/constructor_fields_verifier.dart
+++ b/pkg/analyzer/lib/src/error/constructor_fields_verifier.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
diff --git a/pkg/analyzer/lib/src/error/correct_override.dart b/pkg/analyzer/lib/src/error/correct_override.dart
index c2e585c..7eea108 100644
--- a/pkg/analyzer/lib/src/error/correct_override.dart
+++ b/pkg/analyzer/lib/src/error/correct_override.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/syntactic_entity.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
diff --git a/pkg/analyzer/lib/src/error/inheritance_override.dart b/pkg/analyzer/lib/src/error/inheritance_override.dart
index d55559e..42a6239 100644
--- a/pkg/analyzer/lib/src/error/inheritance_override.dart
+++ b/pkg/analyzer/lib/src/error/inheritance_override.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/error/error.dart';
diff --git a/pkg/analyzer/lib/src/error/must_call_super_verifier.dart b/pkg/analyzer/lib/src/error/must_call_super_verifier.dart
index 99eb9f6..df20490 100644
--- a/pkg/analyzer/lib/src/error/must_call_super_verifier.dart
+++ b/pkg/analyzer/lib/src/error/must_call_super_verifier.dart
@@ -5,7 +5,6 @@
import 'dart:collection';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/error/required_parameters_verifier.dart b/pkg/analyzer/lib/src/error/required_parameters_verifier.dart
index 293a487..bffc29a 100644
--- a/pkg/analyzer/lib/src/error/required_parameters_verifier.dart
+++ b/pkg/analyzer/lib/src/error/required_parameters_verifier.dart
@@ -5,7 +5,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
index e61ae89..5b3abc2 100644
--- a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
+++ b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
@@ -7,7 +7,6 @@
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index 59da727..7838f24 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/generated/element_type_provider.dart b/pkg/analyzer/lib/src/generated/element_type_provider.dart
index e2f076c..d024019 100644
--- a/pkg/analyzer/lib/src/generated/element_type_provider.dart
+++ b/pkg/analyzer/lib/src/generated/element_type_provider.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/generated/element_walker.dart b/pkg/analyzer/lib/src/generated/element_walker.dart
index b636d2b..e54e863 100644
--- a/pkg/analyzer/lib/src/generated/element_walker.dart
+++ b/pkg/analyzer/lib/src/generated/element_walker.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
/// Keeps track of the set of non-synthetic child elements of an element,
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index af4f415..634086c 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -9,7 +9,6 @@
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/analyzer/lib/src/generated/exhaustiveness.dart b/pkg/analyzer/lib/src/generated/exhaustiveness.dart
index f46f80e..ae80e01 100644
--- a/pkg/analyzer/lib/src/generated/exhaustiveness.dart
+++ b/pkg/analyzer/lib/src/generated/exhaustiveness.dart
@@ -11,7 +11,6 @@
import 'package:_fe_analyzer_shared/src/exhaustiveness/static_type.dart';
import 'package:_fe_analyzer_shared/src/exhaustiveness/types.dart';
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/generated/ffi_verifier.dart b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
index 6965f6d..884a5c9 100644
--- a/pkg/analyzer/lib/src/generated/ffi_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
@@ -5,7 +5,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
index 63ec5ac..f0f8fe0 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
diff --git a/pkg/analyzer/lib/src/lint/linter.dart b/pkg/analyzer/lib/src/lint/linter.dart
index 8581316..9d3972f 100644
--- a/pkg/analyzer/lib/src/lint/linter.dart
+++ b/pkg/analyzer/lib/src/lint/linter.dart
@@ -8,7 +8,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/constant/value.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/dart/element/type_system.dart';
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
index 79d3d6f..b049d6d 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
@@ -4,7 +4,6 @@
import 'package:_fe_analyzer_shared/src/scanner/string_canonicalizer.dart';
import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/token.dart';
diff --git a/pkg/analyzer/lib/src/summary2/ast_resolver.dart b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
index 5c834ca..8b38e9c 100644
--- a/pkg/analyzer/lib/src/summary2/ast_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
diff --git a/pkg/analyzer/lib/src/summary2/default_types_builder.dart b/pkg/analyzer/lib/src/summary2/default_types_builder.dart
index 06e5dcc..e08db44 100644
--- a/pkg/analyzer/lib/src/summary2/default_types_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/default_types_builder.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
diff --git a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
index 822bdf5..03f326f 100644
--- a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
diff --git a/pkg/analyzer/lib/src/summary2/detach_nodes.dart b/pkg/analyzer/lib/src/summary2/detach_nodes.dart
index 6740020..9d2bbcc 100644
--- a/pkg/analyzer/lib/src/summary2/detach_nodes.dart
+++ b/pkg/analyzer/lib/src/summary2/detach_nodes.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index 2a16066..ea2401f 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/invokes_super_self.dart';
import 'package:analyzer/src/dart/ast/token.dart';
diff --git a/pkg/analyzer/lib/src/summary2/function_type_builder.dart b/pkg/analyzer/lib/src/summary2/function_type_builder.dart
index 75afe66..d863f9c2 100644
--- a/pkg/analyzer/lib/src/summary2/function_type_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/function_type_builder.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_visitor.dart';
diff --git a/pkg/analyzer/lib/src/summary2/informative_data.dart b/pkg/analyzer/lib/src/summary2/informative_data.dart
index 0c1f5c7..c605b19 100644
--- a/pkg/analyzer/lib/src/summary2/informative_data.dart
+++ b/pkg/analyzer/lib/src/summary2/informative_data.dart
@@ -7,7 +7,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/source.dart';
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index 9a6e8a9..2c97171 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -5,7 +5,6 @@
import 'package:_fe_analyzer_shared/src/field_promotability.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/analysis/utilities.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart' hide DirectiveUri;
import 'package:analyzer/src/dart/analysis/file_state.dart' as file_state;
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 5d708f6..5c778e58 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -8,7 +8,6 @@
as macro;
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/ast/ast.dart' as ast;
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index c4079ba..8fb3f70 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -4,7 +4,6 @@
import 'dart:collection';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/summary2/named_type_builder.dart b/pkg/analyzer/lib/src/summary2/named_type_builder.dart
index d7fa593..1075f68 100644
--- a/pkg/analyzer/lib/src/summary2/named_type_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/named_type_builder.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_visitor.dart';
diff --git a/pkg/analyzer/lib/src/summary2/reference_resolver.dart b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
index c2082fb..2fdcd67 100644
--- a/pkg/analyzer/lib/src/summary2/reference_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/summary2/simply_bounded.dart b/pkg/analyzer/lib/src/summary2/simply_bounded.dart
index d8d2d69..ba164731 100644
--- a/pkg/analyzer/lib/src/summary2/simply_bounded.dart
+++ b/pkg/analyzer/lib/src/summary2/simply_bounded.dart
@@ -5,7 +5,6 @@
import 'package:_fe_analyzer_shared/src/util/dependency_walker.dart' as graph
show DependencyWalker, Node;
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary2/link.dart';
diff --git a/pkg/analyzer/lib/src/summary2/super_constructor_resolver.dart b/pkg/analyzer/lib/src/summary2/super_constructor_resolver.dart
index 694f27d..67ae677 100644
--- a/pkg/analyzer/lib/src/summary2/super_constructor_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/super_constructor_resolver.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary2/link.dart';
import 'package:collection/collection.dart';
diff --git a/pkg/analyzer/lib/src/summary2/top_level_inference.dart b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
index 099b9e3..e509285 100644
--- a/pkg/analyzer/lib/src/summary2/top_level_inference.dart
+++ b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/scope.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
diff --git a/pkg/analyzer/lib/src/summary2/types_builder.dart b/pkg/analyzer/lib/src/summary2/types_builder.dart
index 9963a6e..16d24f6 100644
--- a/pkg/analyzer/lib/src/summary2/types_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/types_builder.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/analyzer/lib/src/summary2/variance_builder.dart b/pkg/analyzer/lib/src/summary2/variance_builder.dart
index 4e84f44..d83f183 100644
--- a/pkg/analyzer/lib/src/summary2/variance_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/variance_builder.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
diff --git a/pkg/analyzer/lib/src/task/strong_mode.dart b/pkg/analyzer/lib/src/task/strong_mode.dart
index 016f75d..3bc38b5 100644
--- a/pkg/analyzer/lib/src/task/strong_mode.dart
+++ b/pkg/analyzer/lib/src/task/strong_mode.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
index 12da463..40f150c 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/source/line_info.dart';
diff --git a/pkg/analyzer/test/generated/constant_test.dart b/pkg/analyzer/test/generated/constant_test.dart
index 533f4ee..69cb644 100644
--- a/pkg/analyzer/test/generated/constant_test.dart
+++ b/pkg/analyzer/test/generated/constant_test.dart
@@ -6,7 +6,6 @@
library analyzer.test.constant_test;
import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
diff --git a/pkg/analyzer/test/generated/elements_types_mixin.dart b/pkg/analyzer/test/generated/elements_types_mixin.dart
index 8c058fc..b720f9d 100644
--- a/pkg/analyzer/test/generated/elements_types_mixin.dart
+++ b/pkg/analyzer/test/generated/elements_types_mixin.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 893110d..eb7c77f 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/file_system.dart';
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index 705e85e..a48a865 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/search.dart';
diff --git a/pkg/analyzer/test/src/dart/element/class_element_test.dart b/pkg/analyzer/test/src/dart/element/class_element_test.dart
index 7270987..c123f4d 100644
--- a/pkg/analyzer/test/src/dart/element/class_element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/class_element_test.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:test/test.dart';
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index d402755..a4fccd0 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/constant/value.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
diff --git a/pkg/analyzer/test/src/dart/element/least_upper_bound_helper_test.dart b/pkg/analyzer/test/src/dart/element/least_upper_bound_helper_test.dart
index a801642..7a74e20 100644
--- a/pkg/analyzer/test/src/dart/element/least_upper_bound_helper_test.dart
+++ b/pkg/analyzer/test/src/dart/element/least_upper_bound_helper_test.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/least_upper_bound.dart';
diff --git a/pkg/analyzer/test/src/dart/resolution/constant_test.dart b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
index bfcf3ee..20335bb 100644
--- a/pkg/analyzer/test/src/dart/resolution/constant_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/constant/value.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/error/codes.dart';
diff --git a/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart b/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart
index abb3692..0b9fa8c 100644
--- a/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 26bcd8d..53d699c 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/constant/value.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/error/error.dart';
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index cb3db06..f5ecefa 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary2/export.dart';
diff --git a/pkg/analyzer/test/src/summary/elements_test.dart b/pkg/analyzer/test/src/summary/elements_test.dart
index eaaed1a..26fcd0b 100644
--- a/pkg/analyzer/test/src/summary/elements_test.dart
+++ b/pkg/analyzer/test/src/summary/elements_test.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
diff --git a/pkg/analyzer/test/src/summary/macro_test.dart b/pkg/analyzer/test/src/summary/macro_test.dart
index 3522cee..acb6bf4 100644
--- a/pkg/analyzer/test/src/summary/macro_test.dart
+++ b/pkg/analyzer/test/src/summary/macro_test.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary2/macro_application_error.dart';
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
diff --git a/pkg/analyzer/test/util/element_printer.dart b/pkg/analyzer/test/util/element_printer.dart
index f58b3c9..34a1dab 100644
--- a/pkg/analyzer/test/util/element_printer.dart
+++ b/pkg/analyzer/test/util/element_printer.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/member.dart';
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
index 691b013..7de2236 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
diff --git a/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart b/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
index 891b0a5fa..8c31d29 100644
--- a/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
+++ b/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
diff --git a/pkg/nnbd_migration/lib/src/decorated_type.dart b/pkg/nnbd_migration/lib/src/decorated_type.dart
index 9881c55..f558136 100644
--- a/pkg/nnbd_migration/lib/src/decorated_type.dart
+++ b/pkg/nnbd_migration/lib/src/decorated_type.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/nnbd_migration/lib/src/edge_builder.dart b/pkg/nnbd_migration/lib/src/edge_builder.dart
index 47d5be6..97d3836 100644
--- a/pkg/nnbd_migration/lib/src/edge_builder.dart
+++ b/pkg/nnbd_migration/lib/src/edge_builder.dart
@@ -6,7 +6,6 @@
import 'package:_fe_analyzer_shared/src/type_inference/assigned_variables.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/nnbd_migration/lib/src/fix_builder.dart b/pkg/nnbd_migration/lib/src/fix_builder.dart
index 2cbad61..281fc3a 100644
--- a/pkg/nnbd_migration/lib/src/fix_builder.dart
+++ b/pkg/nnbd_migration/lib/src/fix_builder.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/nnbd_migration/lib/src/nullability_migration_impl.dart b/pkg/nnbd_migration/lib/src/nullability_migration_impl.dart
index 905cb58..511f80b 100644
--- a/pkg/nnbd_migration/lib/src/nullability_migration_impl.dart
+++ b/pkg/nnbd_migration/lib/src/nullability_migration_impl.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
diff --git a/pkg/nnbd_migration/lib/src/variables.dart b/pkg/nnbd_migration/lib/src/variables.dart
index 3d073db..581e494 100644
--- a/pkg/nnbd_migration/lib/src/variables.dart
+++ b/pkg/nnbd_migration/lib/src/variables.dart
@@ -5,7 +5,6 @@
import 'dart:math' as math;
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart b/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart
index c599e9b..d680106 100644
--- a/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart
+++ b/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/nnbd_migration/test/edge_builder_test.dart b/pkg/nnbd_migration/test/edge_builder_test.dart
index 472b416..75ade3c 100644
--- a/pkg/nnbd_migration/test/edge_builder_test.dart
+++ b/pkg/nnbd_migration/test/edge_builder_test.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
diff --git a/pkg/nnbd_migration/test/migration_visitor_test_base.dart b/pkg/nnbd_migration/test/migration_visitor_test_base.dart
index 4977171..6f49b88 100644
--- a/pkg/nnbd_migration/test/migration_visitor_test_base.dart
+++ b/pkg/nnbd_migration/test/migration_visitor_test_base.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/element/element.dart';