StandardSourceDeclaration class final
Concrete implementation of SourceDeclaration representing source-level declarations.
Provides standardized reflection metadata for source code elements including:
- Name and location in source
- Parent library context
- Annotations
- Type information
{@template standard_source_declaration_features}
Key Features
- Complete source element metadata
- Annotation introspection
- Source location tracking
- Library context awareness
- Immutable value object
Typical Usage
Used by code generators and runtime systems to represent:
- Classes
- Functions
- Variables
- Parameters
- Other source declarations
Example Creation
final declaration = StandardSourceDeclaration(
element: classElement, // Optional analyzer Element
type: MyClass, // Required runtime Type
dartType: classDartType, // Optional analyzer DartType
name: 'MyClass', // Source name
debugger: 'my_class', // Optional debug identifier
annotations: annotations, // List of annotations
libraryDeclaration: libDecl,// Parent library
sourceLocation: classUri // Optional source URI
);
{@endtemplate}
- Inheritance
-
- Object
- Declaration
- StandardEntityDeclaration
- StandardSourceDeclaration
- Implemented types
- Implementers
Constructors
-
StandardSourceDeclaration({Element? element, required Type type, DartType? dartType, required String name, required bool isPublic, required bool isSynthetic, String? debugger, List<
AnnotationDeclaration> annotations = const [], required LibraryDeclaration libraryDeclaration, Uri? sourceLocation}) -
Creates a standard source declaration
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode
, andtoString
.override -
getAnnotations(
) → List< AnnotationDeclaration> -
Returns all annotations applied to this declaration.
override
-
getDartType(
) → DartType? -
The analyzer DartType of the entity for enhanced type operations.
inherited
-
getDebugIdentifier(
) → String -
The debug identifier for the entity.
inherited
-
getElement(
) → Element? -
The analyzer element associated with this declaration.
inherited
-
getIsPublic(
) → bool -
Checks if this declaration is a public declaration.
inherited
-
getIsSynthetic(
) → bool -
Checks if a declaration is a synthetic declaration.
inherited
-
getName(
) → String -
Gets the name of the declared element.
inherited
-
getParentLibrary(
) → LibraryDeclaration -
Returns the LibraryDeclaration in which this declaration is defined.
override
-
getSourceLocation(
) → Uri? -
Returns the source code location (e.g., file path or URI) where this declaration is defined,
or
null
if not available in the current reflection context.override -
getType(
) → Type -
Gets the runtime type of the declared element.
inherited
-
hasAnalyzerSupport(
) → bool -
Returns true if this declaration has analyzer information available.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, Object> -
Returns a JSON representation of this entity.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited