BridgeGenerator class

Generates D4rt BridgedClass implementations from Dart source files.

Constructors

BridgeGenerator({required String workspacePath, String? packageName, String helpersImport = 'package:tom_d4rt/tom_d4rt.dart', String d4rtImport = 'package:tom_d4rt/d4rt.dart', String? sourceImport, List<String> sourceImports = const [], Map<String, String> sourceFileToBarrel = const {}, bool readOnly = false, bool skipPrivate = true, bool verbose = false, bool enableVmWebSkewCoercion = false, List<String> followPackages = const [], List<String>? librarySummaryPaths, String? sdkSummaryPath, List<RecursiveBoundType>? recursiveBoundTypes, UserBridgeScanner? userBridgeScanner})
Creates a bridge generator.

Properties

classLookup Map<String, ClassInfo>
Read-only view of the class lookup built during bridge generation.
no setter
d4rtImport String
Import path for the core D4rt runtime package.
final
deprecatedAllowlist Set<String>
A.5: per-symbol opt-in for deprecated elements. A deprecated element is emitted when generateDeprecatedElements is true OR its simple name is in this set. Empty by default ⇒ historical behaviour (all deprecated skipped).
getter/setter pair
enableVmWebSkewCoercion bool
Whether to emit ?? default coercion for known VM↔web signature-skew parameters (B5/R6). See _vmWebSkewNonNullParams.
final
externalClassLookup Map<String, ClassInfo>
External class lookup for cross-package inheritance resolution. Set this before generating bridges to include classes from other packages in the inheritance lookup (e.g., TomBaseException for TomException). Key is class name, value is ClassInfo from the external package.
getter/setter pair
externalTypeWarnings List<ExternalTypeWarning>
External types that require wrapper classes (detected during generation).
final
followPackages List<String>
Packages to follow for external type dependencies. Format: package names without 'package:' prefix (e.g., 'tom_core_kernel', 'tom_core_server')
getter/setter pair
gen075Classes Set<String>
Read-only view of classes with GEN-075 type-dispatch switches.
no setter
generateDeprecatedElements bool
Whether to generate bridging code for deprecated elements. When false (default), deprecated elements are skipped and counted. Set this before calling generate methods if needed.
getter/setter pair
genericExtractionSites List<GenericExtractionSite>
Read-only view of generic extraction sites collected during generation.
no setter
hashCode int
The hash code for this object.
no setterinherited
helpersImport String
Import path for helper functions.
final
librarySummaryPaths List<String>?
Optional analyzer-summary (.sum) paths for stable dependencies.
final
packageName String?
Package name for imports (e.g., 'tom_build').
final
readOnly bool
Whether to generate read-only bridges.
final
recursiveBoundTypes List<RecursiveBoundType>
Types to use for runtime dispatch when handling recursive type bounds.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sdkSummaryPath String?
Optional pre-built SDK summary .sum path.
final
skippedDeprecatedCount int
Counter for skipped deprecated elements (for reporting).
getter/setter pair
skipPrivate bool
Whether to skip private members.
final
sourceFileToBarrel Map<String, String>
Map of source file path to barrel file URI. Used to resolve which barrel exports each source file.
final
sourceImport String?
Barrel file import path for source code (e.g., 'src/tom/tom.dart'). If provided, this import is used in the generated file for accessing classes. @deprecated Use sourceImports instead for multiple barrel support.
final
sourceImports List<String>
Multiple barrel file import paths for source code. Each barrel is imported with a unique prefix ($pkg, $pkg2, etc.). When set, sourceImport is ignored.
final
userBridgeScanner → UserBridgeScanner
Expose user bridge scanner for testing.
no setter
verbose bool
Whether to output verbose information.
final
workspacePath String
Workspace root path.
final
yieldVoidCallbacks bool
B.14: when true, void bridged callbacks are emitted as async closures that await Future.delayed(const Duration(milliseconds: 1)) after invoking the interpreted callback. This hands a slice of the event loop back to the embedder during long synchronous interpreted runs (e.g. Timer.periodic game ticks), so queued keyboard/gesture input is no longer starved. A Future<void> Function(...) is assignable to a void Function(...) slot, so native APIs still accept the wrapped callback. Off by default ⇒ the historical synchronous wrapper (generated output is byte-identical), so flip it on for the tom_d4rt_flutter* configs only — CLI/build scripting keeps its sync throughput.
getter/setter pair

Methods

findFileForClass(String className) Future<String?>
Finds the file containing a specific class.
findFilesMatching(String pattern) Future<List<String>>
Finds files matching a glob pattern.
generateBridges({required List<String> sourceFiles, required String outputPath, String? classPattern, String? targetClassName, String? moduleName, List<String>? excludeClasses, List<String>? excludeEnums, List<String>? excludeFunctions, List<String>? excludeConstructors, List<String>? excludeVariables, List<String>? excludeSourcePatterns, Map<String, ExportInfo>? exportInfo, List<String> importShowClause = const [], List<String> importHideClause = const [], Map<String, String>? skipClassSources}) Future<BridgeGeneratorResult>
Generates bridges for the specified source files.
generateBridgesFromExports({required List<String> barrelFiles, required String outputPath, String? moduleName, List<String>? excludePatterns, List<String>? excludeClasses, List<String>? excludeEnums, List<String>? excludeFunctions, List<String>? excludeConstructors, List<String>? excludeVariables, List<String>? excludeSourcePatterns, bool followAllReExports = true, List<String>? skipReExports, List<String>? followReExports, List<String> importShowClause = const [], List<String> importHideClause = const [], Map<String, String>? skipClassSources}) Future<BridgeGeneratorResult>
Generates bridges from export barrel files.
generateBridgesFromExportsWithWriter({required List<String> barrelFiles, required FileId outputFileId, String? moduleName, List<String>? excludePatterns, List<String>? excludeClasses, List<String>? excludeEnums, List<String>? excludeFunctions, List<String>? excludeConstructors, List<String>? excludeVariables, List<String>? excludeSourcePatterns, bool followAllReExports = true, List<String>? skipReExports, List<String>? followReExports, required FileWriter fileWriter, List<String> importShowClause = const [], List<String> importHideClause = const []}) Future<BridgeGeneratorResult>
Generates bridges from export barrel files using a FileWriter.
generateBridgesWithWriter({required List<String> sourceFiles, required FileId outputFileId, String? classPattern, String? targetClassName, String? moduleName, List<String>? excludeClasses, List<String>? excludeEnums, List<String>? excludeFunctions, List<String>? excludeConstructors, List<String>? excludeVariables, List<String>? excludeSourcePatterns, Map<String, ExportInfo>? exportInfo, required FileWriter fileWriter, List<String> importShowClause = const [], List<String> importHideClause = const []}) Future<BridgeGeneratorResult>
Generates bridges for the specified source files using a FileWriter.
getOrCreateAnalysisContext() → AnalysisContextCollection
Phase 4 / summary-refactoring-plan: expose the primary analysis context so downstream stages (notably generateProxies in proxy_generator.dart) can reuse it instead of building a second summary-loaded AnalysisContextCollectionImpl per project.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
packageUriForTesting(String sourceFile) String
Test-only accessor for _getPackageUri.
parseExportFiles(List<String> barrelFiles, {Set<String>? visited, bool followAllReExports = true, List<String>? skipReExports, List<String>? followReExports, bool isTopLevel = true, String? originBarrelUri, List<String>? parentShowClause, List<String>? parentHideClause}) Future<Map<String, ExportInfo>>
Parses export barrel files to extract the list of exported source files.
parseFile(String filePath) Future<List<ClassInfo>>
Parses a Dart file and extracts class information with resolved types.
resolveDartUri(String dartUri) String?
Resolves a dart: URI to an absolute file path.
resolvePackageUri(String packageUri) Future<String?>
Resolves a package URI to an absolute file path.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

extractFunctionTypeInfoFromDartType(DartType dartType) FunctionTypeInfo?
Extracts FunctionTypeInfo from a resolved DartType. Returns null if the type is not a function type.