dart/element/element library
Defines the elements and fragments that are part of the element model.
The element model describes the semantic (as opposed to syntactic) structure of Dart code. The syntactic structure of the code is modeled by the AST structure.
The element model consists of three closely related kinds of objects: elements (instances of a subclass of Element), fragments (instances of a subclass of Fragment) and types. This library defines the elements and fragments; the types are defined in type.dart.
Generally speaking, an element represents something that is declared in the code, such as a class, method, or variable. Elements are organized in a tree structure in which the children of an element are the elements that are logically (and often syntactically) part of the declaration of the parent. For example, the elements representing the methods and fields in a class are children of the element representing the class.
Some elements, such as a LocalVariableElement are declared by a single declaration, but most elements can be declared by multiple declarations. A fragment represents a single declaration when the corresponding element can have multiple declarations. There is no fragment for an element that can only have one declaration.
As with elements, fragments are organized in a tree structure. The two structures parallel each other.
Every complete element structure is rooted by an instance of the class LibraryElement. A library element represents a single Dart library. Every library is defined by one or more compilation units (the library and all of its parts). The compilation units are represented by the class LibraryFragment.
The element model does not contain everything in the code, only those things that are declared by the code. For example, it does not include any representation of the statements in a method body, but if one of those statements declares a local variable then the local variable will be represented by an element.
Classes
- Annotatable
- An element or fragment that can have either annotations (metadata), a documentation comment, or both associated with it.
- BindPatternVariableElement
- A pattern variable that is explicitly declared.
- BindPatternVariableFragment
- The portion of a BindPatternVariableElement contributed by a single declaration.
- ClassElement
- A class.
- ClassFragment
- The portion of a ClassElement contributed by a single declaration.
- ConstructorElement
- An element representing a constructor defined by a class, enum, or extension type.
- ConstructorFragment
- The portion of a ConstructorElement contributed by a single declaration.
- DirectiveUri
- Meaning of a URI referenced in a directive.
- DirectiveUriWithLibrary
- DirectiveUriWithSource that references a LibraryElement.
- DirectiveUriWithRelativeUri
- DirectiveUriWithRelativeUriString that can be parsed into a relative URI.
- DirectiveUriWithRelativeUriString
- DirectiveUri for which we can get its relative URI string.
- DirectiveUriWithSource
- DirectiveUriWithRelativeUri that resolves to a Source.
- DirectiveUriWithUnit
- DirectiveUriWithSource that references a LibraryFragment.
- Element
- The base class for all of the elements in the element model.
- ElementAnnotation
- A single annotation associated with an element.
- ElementDirective
- A directive within a library fragment.
- ElementKind
- The kind of elements in the element model.
-
ElementVisitor2<
R> - An object that can be used to visit an element structure.
- EnumElement
- An element that represents an enum.
- EnumFragment
- The portion of an EnumElement contributed by a single declaration.
- ExecutableElement
- An element representing an executable object, including functions, methods, constructors, getters, and setters.
- ExecutableFragment
- The portion of an ExecutableElement contributed by a single declaration.
- ExtensionElement
- An extension.
- ExtensionFragment
- The portion of an ExtensionElement contributed by a single declaration.
- ExtensionTypeElement
- An extension type.
- ExtensionTypeFragment
- The portion of an ExtensionTypeElement contributed by a single declaration.
- FieldElement
- A field defined within a class, enum, extension, or mixin.
- FieldFormalParameterElement
- A field formal parameter defined within a constructor element.
- FieldFormalParameterFragment
- The portion of a FieldFormalParameterElement contributed by a single declaration.
- FieldFragment
- The portion of a FieldElement contributed by a single declaration.
- FormalParameterElement
- A formal parameter defined by an executable element.
- FormalParameterFragment
- The portion of a FormalParameterElement contributed by a single declaration.
- Fragment
- A fragment that wholly or partially defines an element.
- FunctionTypedElement
- An element that has a FunctionType as its type.
- FunctionTypedFragment
- The portion of a FunctionTypedElement contributed by a single declaration.
- GenericFunctionTypeElement
- The pseudo-declaration that defines a generic function type.
- GenericFunctionTypeFragment
- The portion of a GenericFunctionTypeElement coming from a single declaration.
- GetterElement
- A getter.
- GetterFragment
- The portion of a GetterElement contributed by a single declaration.
- HideElementCombinator
- A combinator that causes some of the names in a namespace to be hidden when being imported.
- InstanceElement
-
An element whose instance members can refer to
this
. - InstanceFragment
- The portion of an InstanceElement contributed by a single declaration.
- InterfaceElement
- An element that defines an InterfaceType.
- InterfaceFragment
- The portion of an InterfaceElement contributed by a single declaration.
- JoinPatternVariableElement
-
A pattern variable that is a join of other pattern variables, created
for a logical-or patterns, or shared
case
bodies inswitch
statements. - JoinPatternVariableFragment
- The portion of a JoinPatternVariableElement contributed by a single declaration.
- LabelElement
- A label associated with a statement.
- LabelFragment
- The portion of a LabelElement contributed by a single declaration.
- LibraryElement
- A library.
- LibraryExport
-
An
export
directive within a library fragment. - LibraryFragment
- The portion of a LibraryElement coming from a single compilation unit.
- LibraryImport
-
An
import
directive within a library fragment. - LibraryLanguageVersion
- LocalElement
- An element that can be (but is not required to be) defined within a method or function (an ExecutableFragment).
- LocalFragment
- The portion of an LocalElement contributed by a single declaration.
- LocalFunctionElement
- A local function.
- LocalFunctionFragment
- The portion of a LocalFunctionElement contributed by a single declaration.
- LocalVariableElement
- A local variable.
- LocalVariableFragment
- The portion of a LocalVariableElement contributed by a single declaration.
- Metadata
- The metadata (annotations) associated with an element or fragment.
- MethodElement
- A method.
- MethodFragment
- The portion of a MethodElement contributed by a single declaration.
- MixinElement
- An element that represents a mixin.
- MixinFragment
- The portion of a PrefixElement contributed by a single declaration.
- MultiplyDefinedElement
- 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.
- MultiplyDefinedFragment
- The fragment for a MultiplyDefinedElement.
- Name
- A public name, or a private name qualified by a library URI.
- NamespaceCombinator
- An object that controls how namespaces are combined.
- PartInclude
- A 'part' directive within a library fragment.
- PatternVariableElement
- A pattern variable.
- PatternVariableFragment
- The portion of a PatternVariableElement contributed by a single declaration.
- PrefixElement
- A prefix used to import one or more libraries into another library.
- PrefixFragment
- The portion of a PrefixElement contributed by a single declaration.
- PropertyAccessorElement
- A getter or a setter.
- PropertyAccessorFragment
- The portion of a GetterElement contributed by a single declaration.
- PropertyInducingElement
-
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: - PropertyInducingFragment
- The portion of a PropertyInducingElement contributed by a single declaration.
- SetterElement
- A setter.
- SetterFragment
- The portion of a SetterElement contributed by a single declaration.
- ShowElementCombinator
- A combinator that cause some of the names in a namespace to be visible (and the rest hidden) when being imported.
- SuperFormalParameterElement
- A super formal parameter.
- SuperFormalParameterFragment
- The portion of a SuperFormalParameterElement contributed by a single declaration.
- TopLevelFunctionElement
- A top-level function.
- TopLevelFunctionFragment
- The portion of a TopLevelFunctionElement contributed by a single declaration.
- TopLevelVariableElement
- A top-level variable.
- TopLevelVariableFragment
- The portion of a TopLevelVariableElement contributed by a single declaration.
- TypeAliasElement
-
A type alias (
typedef
). - TypeAliasFragment
- The portion of a TypeAliasElement contributed by a single declaration.
- TypeDefiningElement
- An element that defines a type.
- TypeDefiningFragment
- The portion of a TypeDefiningElement contributed by a single declaration.
- TypeParameterElement
- A type parameter.
- TypeParameterFragment
- The portion of a TypeParameterElement contributed by a single declaration.
- TypeParameterizedElement
- An element that has type parameters, such as a class, typedef, or method.
- TypeParameterizedFragment
- The portion of a TypeParameterizedElement contributed by a single declaration.
- VariableElement
- A variable.
- VariableFragment
- The portion of a VariableElement contributed by a single declaration.
Typedefs
- BindPatternVariableElement2 = BindPatternVariableElement
- ClassElement2 = ClassElement
- ConstructorElement2 = ConstructorElement
- Element2 = Element
- EnumElement2 = EnumElement
- ExecutableElement2 = ExecutableElement
- ExtensionElement2 = ExtensionElement
- ExtensionTypeElement2 = ExtensionTypeElement
- FieldElement2 = FieldElement
- FieldFormalParameterElement2 = FieldFormalParameterElement
- FunctionTypedElement2 = FunctionTypedElement
- GenericFunctionTypeElement2 = GenericFunctionTypeElement
- InstanceElement2 = InstanceElement
- InterfaceElement2 = InterfaceElement
- JoinPatternVariableElement2 = JoinPatternVariableElement
- LabelElement2 = LabelElement
- LibraryElement2 = LibraryElement
- LocalElement2 = LocalElement
- LocalVariableElement2 = LocalVariableElement
- MethodElement2 = MethodElement
- MixinElement2 = MixinElement
- MultiplyDefinedElement2 = MultiplyDefinedElement
- PatternVariableElement2 = PatternVariableElement
- PrefixElement2 = PrefixElement
- PropertyAccessorElement2 = PropertyAccessorElement
- PropertyInducingElement2 = PropertyInducingElement
- SuperFormalParameterElement2 = SuperFormalParameterElement
- TopLevelVariableElement2 = TopLevelVariableElement
- TypeAliasElement2 = TypeAliasElement
- TypeDefiningElement2 = TypeDefiningElement
- TypeParameterElement2 = TypeParameterElement
- TypeParameterizedElement2 = TypeParameterizedElement
- VariableElement2 = VariableElement