Element class abstract

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 don't have any corresponding declaration within the source code. Such elements are marked as being synthetic. Examples of synthetic elements include

  • default constructors in classes that don't 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 don't have, or are not required to have a name. These correspond to things like unnamed functions or extensions. They exist in order to more accurately represent the semantic structure of the program.

Clients may not extend, implement or mix-in this class.

Implementers

Constructors

Element.new()

Properties

baseElement Element
The non-SubstitutedElementImpl version of this element.
no setter
children List<Element>
The children of this element.
no setter
children2 List<Element>
The children of this element.
no setter
displayName String
The display name of this element, or an empty string if the element does not have a name.
no setter
documentationComment String?
The content of the documentation comment (including delimiters) for this element.
no setter
enclosingElement Element?
The element that either physically or logically encloses this element.
no setter
enclosingElement2 Element?
The element that either physically or logically encloses this element.
no setter
firstFragment Fragment
The first fragment in the chain of fragments that are merged to make this element.
no setter
fragments List<Fragment>
The fragments this element consists of.
no setter
hashCode int
The hash code for this object.
no setterinherited
id int
The unique integer identifier of this element.
no setter
isPrivate bool
Whether this element is private.
no setter
isPublic bool
Whether this element is public.
no setter
isSynthetic bool
Whether this element is synthetic.
no setter
kind ElementKind
The kind of this element.
no setter
library LibraryElement?
Library that contains this element.
no setter
library2 LibraryElement?
Library that contains this element.
no setter
lookupName String?
The name to use for lookup in maps.
no setter
metadata Metadata
The metadata associated with the element.
no setter
name String?
The name of this element.
no setter
name3 String?
The name of this element.
no setter
nonSynthetic Element
The non-synthetic element that caused this element to be created.
no setter
nonSynthetic2 Element
The non-synthetic element that caused this element to be created.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
session AnalysisSession?
The analysis session in which this element is defined.
no setter
sinceSdkVersion → Version?
The version where the associated SDK API was added.
no setter

Methods

accept<T>(ElementVisitor2<T> visitor) → T?
Uses the given visitor to visit this element.
accept2<T>(ElementVisitor2<T> visitor) → T?
Uses the given visitor to visit this element.
displayString({bool multiline = false, bool preferTypeAlias = false}) String
The presentation of this element as it should appear when presented to users.
displayString2({bool multiline = false, bool preferTypeAlias = false}) String
The presentation of this element as it should appear when presented to users.
getExtendedDisplayName({String? shortName}) String
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.
getExtendedDisplayName2({String? shortName}) String
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.
isAccessibleIn(LibraryElement library) bool
Whether the element, assuming that it is within scope, is accessible to code in the given library.
isAccessibleIn2(LibraryElement library) bool
Whether the element, assuming that it is within scope, is accessible to code in the given library.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
thisOrAncestorMatching(bool predicate(Element)) Element?
Returns either this element or the most immediate ancestor of this element for which the predicate returns true.
thisOrAncestorMatching2(bool predicate(Element)) Element?
Returns either this element or the most immediate ancestor of this element for which the predicate returns true.
thisOrAncestorOfType<E extends Element>() → E?
Returns either this element or the most immediate ancestor of this element that has the given type.
thisOrAncestorOfType2<E extends Element>() → E?
Returns either this element or the most immediate ancestor of this element that has the given type.
toString() String
A string representation of this object.
inherited
visitChildren<T>(ElementVisitor2<T> visitor) → void
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.
visitChildren2<T>(ElementVisitor2<T> visitor) → void
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.

Operators

operator ==(Object other) bool
The equality operator.
inherited