Element2 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

Element2()

Properties

baseElement Element2
The non-Member version of this element.
no setter
children2 List<Element2>
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
enclosingElement2 Element2?
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
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
library2 LibraryElement2?
Library that contains this element.
no setter
location ElementLocation?
The location of this element in the element model.
no setter
lookupName String?
The name to use for lookup in maps.
no setter
name3 String?
The name of this element.
no setter
nonSynthetic2 Element2
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

Methods

accept2<T>(ElementVisitor2<T> visitor) → T?
Uses the given visitor to visit this element.
displayString2({bool multiline = false, bool preferTypeAlias = false}) String
The presentation of this element as it should appear when presented to users.
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.
isAccessibleIn2(LibraryElement2 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
thisOrAncestorMatching2(bool predicate(Element2)) Element2?
Returns either this element or the most immediate ancestor of this element for which the predicate returns true.
thisOrAncestorOfType2<E extends Element2>() → 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
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