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 do not 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 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.
Constructors
- Element()
Properties
-
children
→ List<
Element> -
A list of this element's children.
no setter
- context → AnalysisContext
-
The analysis context in which this element is defined.
no setter
- declaration → Element?
-
The declaration of this element.
no setter
- displayName → String
-
The display name of this element, possibly the 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, or
null
if this element does not or cannot have documentation.no setter - enclosingElement → Element?
-
The element that either physically or logically encloses this element.
no setter
- enclosingElement3 → Element?
-
The element that either physically or logically encloses this element.
no setter
- hasAlwaysThrows → bool
-
Whether the element has an annotation of the form
@alwaysThrows
.no setter - hasDeprecated → bool
-
Whether the element has an annotation of the form
@deprecated
or@Deprecated('..')
.no setter - hasDoNotStore → bool
-
Whether the element has an annotation of the form
@doNotStore
.no setter - hasDoNotSubmit → bool
-
Whether the element has an annotation of the form
@doNotSubmit
.no setter - hasFactory → bool
-
Whether the element has an annotation of the form
@factory
.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- hasImmutable → bool
-
Whether the element has an annotation of the form
@immutable
.no setter - hasInternal → bool
-
Whether the element has an annotation of the form
@internal
.no setter - hasIsTest → bool
-
Whether the element has an annotation of the form
@isTest
.no setter - hasIsTestGroup → bool
-
Whether the element has an annotation of the form
@isTestGroup
.no setter - hasJS → bool
-
Whether the element has an annotation of the form
@JS(..)
.no setter - hasLiteral → bool
-
Whether the element has an annotation of the form
@literal
.no setter - hasMustBeConst → bool
-
Whether the element has an annotation of the form
@mustBeConst
.no setter - hasMustBeOverridden → bool
-
Whether the element has an annotation of the form
@mustBeOverridden
.no setter - hasMustCallSuper → bool
-
Whether the element has an annotation of the form
@mustCallSuper
.no setter - hasNonVirtual → bool
-
Whether the element has an annotation of the form
@nonVirtual
.no setter - hasOptionalTypeArgs → bool
-
Whether the element has an annotation of the form
@optionalTypeArgs
.no setter - hasOverride → bool
-
Whether the element has an annotation of the form
@override
.no setter - hasProtected → bool
-
Whether the element has an annotation of the form
@protected
.no setter - hasRedeclare → bool
-
Whether the element has an annotation of the form
@redeclare
.no setter - hasReopen → bool
-
Whether the element has an annotation of the form
@reopen
.no setter - hasRequired → bool
-
Whether the element has an annotation of the form
@required
.no setter - hasSealed → bool
-
Whether the element has an annotation of the form
@sealed
.no setter - hasUseResult → bool
-
Whether the element has an annotation of the form
@useResult
or@UseResult('..')
.no setter - hasVisibleForOverriding → bool
-
Whether the element has an annotation of the form
@visibleForOverriding
.no setter - hasVisibleForTemplate → bool
-
Whether the element has an annotation of the form
@visibleForTemplate
.no setter - hasVisibleForTesting → bool
-
Whether the element has an annotation of the form
@visibleForTesting
.no setter - hasVisibleOutsideTemplate → bool
-
Whether the element has an annotation of the form
@visibleOutsideTemplate
.no setter - id → int
-
The unique integer identifier of this element.
no setter
- isPrivate → bool
-
Whether the element is private.
no setter
- isPublic → bool
-
Whether the element is public.
no setter
- isSynthetic → bool
-
Whether the element is synthetic.
no setter
- kind → ElementKind
-
The kind of element that this is.
no setter
- library → LibraryElement?
-
Library that contains this element.
no setter
- librarySource → Source?
-
If this target is associated with a library, return the source of the
library's defining compilation unit; otherwise return
null
.no setterinherited - location → ElementLocation?
-
The location of this element in the element model.
no setter
-
metadata
→ List<
ElementAnnotation> -
All of the metadata associated with this element.
no setter
- name → String?
-
The name of this element, or
null
if this element does not have a name.no setter - nameLength → int
-
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.no setter - nameOffset → int
-
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.no setter - nonSynthetic → 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 this SDK API was added.
no setter
- source → Source?
-
Return the source associated with this target, or
null
if this target is not associated with a source.no setter
Methods
-
accept<
T> (ElementVisitor< T> visitor) → T? -
Uses the given
visitor
to visit this element. -
getDisplayString(
{bool withNullability = true, bool multiline = false}) → String - Returns 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
isnull
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
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
thisOrAncestorMatching<
E extends Element> (bool predicate(Element)) → E? -
Returns either this element or the most immediate ancestor of this element
for which the
predicate
returnstrue
, ornull
if there is no such element. -
thisOrAncestorMatching3<
E extends Element> (bool predicate(Element)) → E? -
Returns either this element or the most immediate ancestor of this element
for which the
predicate
returnstrue
, ornull
if there is no such element. -
thisOrAncestorOfType<
E extends Element> () → E? -
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. -
thisOrAncestorOfType3<
E extends Element> () → E? -
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. -
toString(
) → String -
A string representation of this object.
inherited
-
visitChildren(
ElementVisitor 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