dart/element/element2 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 Element2), 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 LocalVariableElement2 are declared by a single declaration, but most elements can be declared by multiple declarations. A fragment represents a single declararation 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 LibraryElement2. 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.
BindPatternVariableElement2
A pattern variable that is explicitly declared.
BindPatternVariableFragment
The portion of a BindPatternVariableElement2 contributed by a single declaration.
ClassElement2
A class.
ClassFragment
The portion of a ClassElement2 contributed by a single declaration.
ConstructorElement2
An element representing a constructor defined by a class, enum, or extension type.
ConstructorFragment
The portion of a ConstructorElement2 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 CompilationUnitElement.
Element2
The base class for all of the elements in the element model.
ElementAnnotation
A single annotation associated with an element.
ElementKind
The kind of elements in the element model.
ElementLocation
The location of an element within the element model.
ElementVisitor2<R>
An object that can be used to visit an element structure.
EnumElement2
An element that represents an enum.
EnumFragment
The portion of an EnumElement2 contributed by a single declaration.
ExecutableElement2
An element representing an executable object, including functions, methods, constructors, getters, and setters.
ExecutableFragment
The portion of an ExecutableElement2 contributed by a single declaration.
ExtensionElement2
An extension.
ExtensionFragment
The portion of an ExtensionElement2 contributed by a single declaration.
ExtensionTypeElement2
An extension type.
ExtensionTypeFragment
The portion of an ExtensionTypeElement2 contributed by a single declaration.
FieldElement2
A field defined within a class, enum, extension, or mixin.
FieldFormalParameterElement2
A field formal parameter defined within a constructor element.
FieldFormalParameterFragment
The portion of a FieldFormalParameterElement2 contributed by a single declaration.
FieldFragment
The portion of a FieldElement2 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.
FunctionTypedElement2
An element that has a FunctionType as its type.
FunctionTypedFragment
The portion of a FunctionTypedElement2 contributed by a single declaration.
GenericFunctionTypeElement2
The pseudo-declaration that defines a generic function type.
GenericFunctionTypeFragment
The portion of a GenericFunctionTypeElement2 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.
InstanceElement2
An element whose instance members can refer to this.
InstanceFragment
The portion of an InstanceElement2 contributed by a single declaration.
InterfaceElement2
An element that defines an InterfaceType.
InterfaceFragment
The portion of an InterfaceElement2 contributed by a single declaration.
JoinPatternVariableElement2
A pattern variable that is a join of other pattern variables, created for a logical-or patterns, or shared case bodies in switch statements.
JoinPatternVariableFragment
The portion of a JoinPatternVariableElement2 contributed by a single declaration.
LabelElement2
A label associated with a statement.
LabelFragment
The portion of a LabelElement2 contributed by a single declaration.
LibraryElement2
A library.
LibraryExport
An export directive within a library fragment.
LibraryFragment
The portion of a LibraryElement2 coming from a single compilation unit.
LibraryImport
An import directive within a library fragment.
LocalFunctionElement
A local function.
LocalFunctionFragment
The portion of a LocalFunctionElement2 contributed by a single declaration.
LocalVariableElement2
A local variable.
LocalVariableFragment
The portion of a LocalVariableElement2 contributed by a single declaration.
Metadata
The metadata (annotations) associated with an element or fragment.
MethodElement2
A method.
MethodFragment
The portion of a MethodElement2 contributed by a single declaration.
MixinElement2
An element that represents a mixin.
MixinFragment
The portion of a PrefixElement2 contributed by a single declaration.
MultiplyDefinedElement2
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 MultiplyDefinedElement2.
NamespaceCombinator
An object that controls how namespaces are combined.
PartInclude
A 'part' directive within a library fragment.
PatternVariableElement2
A pattern variable.
PatternVariableFragment
The portion of a PatternVariableElement2 contributed by a single declaration.
PrefixElement2
A prefix used to import one or more libraries into another library.
PrefixFragment
The portion of a PrefixElement2 contributed by a single declaration.
PromotableElement2
A variable that might be subject to type promotion. This might be a local variable or a parameter.
PromotableFragment
The portion of a PromotableElement2 contributed by a single declaration.
PropertyAccessorElement2
A getter or a setter.
PropertyAccessorFragment
The portion of a GetterElement contributed by a single declaration.
PropertyInducingElement2
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 PropertyInducingElement2 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.
SuperFormalParameterElement2
A super formal parameter.
SuperFormalParameterFragment
The portion of a SuperFormalParameterElement2 contributed by a single declaration.
TopLevelFunctionElement
A top-level function.
TopLevelFunctionFragment
The portion of a TopLevelFunctionElement contributed by a single declaration.
TopLevelVariableElement2
A top-level variable.
TopLevelVariableFragment
The portion of a TopLevelVariableElement2 contributed by a single declaration.
TypeAliasElement2
A type alias (typedef).
TypeAliasFragment
The portion of a TypeAliasElement2 contributed by a single declaration.
TypeDefiningElement2
An element that defines a type.
TypeDefiningFragment
The portion of a TypeDefiningElement2 contributed by a single declaration.
TypeParameterElement2
A type parameter.
TypeParameterFragment
The portion of a TypeParameterElement2 contributed by a single declaration.
TypeParameterizedElement2
An element that has type parameters, such as a class, typedef, or method.
TypeParameterizedFragment
The portion of a TypeParameterizedElement2 contributed by a single declaration.
VariableElement2
A variable.
VariableFragment
The portion of a VariableElement2 contributed by a single declaration.