LibraryGenerator class abstract

Enhanced reflection generator that creates both metadata and reflector classes.

This abstract class provides functionality to generate reflection metadata for Dart libraries, including classes, mixins, enums, typedefs, and top-level declarations. It handles complex type relationships, inheritance hierarchies, and source code analysis to provide accurate reflection information.

Usage Example:

final generator = ConcreteLibraryGenerator(
  mirrorSystem: currentMirrorSystem(),
  forceLoadedMirrors: [],
  onInfo: print,
  onError: print,
  loader: RuntimeScanLoader(),
  packages: [currentPackage],
);

final libraries = await generator.generate();

Key Features:

  • Generates reflection metadata for entire libraries
  • Handles complex type relationships and generics
  • Supports source code analysis for accurate modifier detection
  • Caches results for performance
  • Provides detailed error reporting
Implementers

Constructors

LibraryGenerator({required MirrorSystem mirrorSystem, required List<LibraryMirror> forceLoadedMirrors, required void onInfo(String), required void onWarning(String), required void onError(String), required RuntimeScannerConfiguration configuration, required List<Package> packages})
Enhanced reflection generator that creates both metadata and reflector classes.

Properties

configuration RuntimeScannerConfiguration
The runtime scan loader configuration
final
forceLoadedMirrors List<LibraryMirror>
List of mirrors that should be force-loaded
final
hashCode int
The hash code for this object.
no setterinherited
mirrorSystem MirrorSystem
The mirror system used for reflection
final
onError → void Function(String)
Callback for error messages
final
onInfo → void Function(String)
Callback for informational messages
final
onWarning → void Function(String)
Callback for warning messages
final
packages List<Package>
List of packages to process
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

generate(List<File> dartFiles) Future<List<LibraryDeclaration>>
Generates both reflection metadata and concrete reflector classes.
getPackageNameFromUri(dynamic uri) String?
Parameters:
hasMirrorImport(String content) bool
isNonLoadableJetLeafFile(Uri uri) bool
Checks if the file matches any of the excluded JetLeaf internal paths.
isPartOf(String content) bool
Parameters:
isSkippableJetLeafPackage(Uri identifier) bool
Checks if the file matches any of the excluded JetLeaf internal paths.
isTest(String content) bool
Checks if content is a test file.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveUri(Uri uri) Future<Uri?>
Parameters:
shouldNotIncludeLibrary(Uri uri, RuntimeScannerConfiguration configuration) Future<bool>
Parameters:
toString() String
A string representation of this object.
inherited

Operators

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