tom_reflection_generator 1.4.0
tom_reflection_generator: ^1.4.0 copied to clipboard
Standalone reflection generator (builder + CLI) for the Tom framework.
Changelog #
1.4.0 #
-
The generated header names this generator. Every emitted
*.reflection.dartopened with// This file has been generated by the reflection package.followed byhttps://github.com/dart-lang/reflection— a package that does not exist and a repository that does not either, both inherited from thereflectablelineage this fork derives from. It is the first line of every artifact, which made it the most-reproduced wrong name in the workspace: 124 committed files carried it, and a reader who followed it searched pub.dev forreflectionand found something unrelated.The header is now the standard generated-code marker
tom_reflectoralready emits, followed by this package's name and its real repository:// GENERATED CODE - DO NOT MODIFY BY HAND // Generated by tom_reflection_generator. // https://github.com/al-the-bear/tom_reflectionConsumers see the change on their next
build_runnerrun; nothing but the comment differs, so a regenerated file is otherwise byte-identical.Pinned by three tests in
private_const_default_test.dart, asserted against the emitted text rather than the emitter's source, so a refactor that moves where the header is assembled cannot satisfy them by accident. -
New:
--checkverifies that committed*.reflection.dartfiles still match their sources. The generator runs exactly as usual and then compares what it would emit against what is on disk, instead of overwriting it; it exits non-zero naming every file that differs or is missing, and modifies nothing.This closes a gap in which a reflected signature change left its generated counterpart stale and nothing noticed. Widening a parameter from
String?toObject?in two packages changed a type index in each generated seed; neither was regenerated, and both were committed stale. Measured at the time:dart analyzewas clean and both suites fully green, with identical test counts before and after regeneration — the stale part is metadata the tests never exercise. "Remember to regenerate" was the only thing standing in the way of a committed mismatch, and a habit is not a control.Available on the CLI, in nested/buildkit mode (a stale file fails the item), and through each project's
reflection_generation.sh --check. A check costs a full generation run (~20–30 s per package) because answering the question means actually generating. Seedoc/reflection_generator.md§ Check Mode.
1.3.2 #
- Fix: a type annotation no longer carries the originating library's import
prefix into the generated file. Type annotations in constant expressions
were emitted by prepending the generated prefix to the annotation's source
text. For an annotation written through an import prefix —
lib.Imported, or a type argument such asList<lib.Imported>— the source prefix came along, producingprefixNN.lib.Imported: the namelibis not in scope in the generated library, so it fails to compile with "The name 'lib' is being referenced through the prefix 'prefixNN', but it isn't defined in any of the libraries imported using that prefix". The helper now rebuilds the annotation from its parts (prefix + simple name + type arguments, the latter re-qualified recursively) instead of reusing source text. Seesrc/reflection_generator/constant_extractor.dart. dynamicandvoidused as type arguments (e.g.<String, dynamic>{}) no longer raise a spuriousconstant.type_annotation.unsupportedsevere diagnostic. They belong to no library, take no prefix, and were already emitted correctly — only the diagnostic was wrong.- Test: the 1.3.1 type-literal fix is now covered. A new end-to-end suite
(
test/default_value_prefix_test.dart) runs the real generator over a fixture whose optional parameters put a type literal in every position it can occupy — bare, map key, map value, list element, set element, nested collection, and behind a source import prefix — asserts the generated prefix in each, and resolves the emitted library withdart analyzeso an unqualified name in any other position fails the suite too.
1.3.1 #
- Fix: type-literal annotation arguments are now import-prefixed. A bare
type name used as a constant annotation argument — e.g. the
EmailServicein@TomComponent(EmailService)— is parsed as aTypeLiteral, an expression kind the constant extractor did not handle. It fell through toExpression.toSource()and was emitted UNQUALIFIED (EmailService), which is an undefined name in the generated.reflection.dartlibrary and fails to compile (Error: Undefined name 'EmailService'). The extractor now routesTypeLiteralthrough the type-annotation helper, so it carries the correct import prefix (prefixNN.EmailService) and the owning library is registered for import. Seesrc/reflection_generator/constant_extractor.dart(RCL1).
1.3.0 #
- Deterministic output. Import prefixes (
prefix0,prefix1, …) are now numbered by a stable sort of the import URIs instead of the order libraries happened to be encountered while walking the element model. The same set of imported libraries therefore always yields byte-identical generated code, regardless of analyzer/SDK traversal order — eliminating spurious cross-machine diffs in.reflection.dartoutputs. Seesrc/reflection_generator/prefix_renumber.dart. - Build-runner-style progress.
generateReflectionnow prints a start banner (Generating reflection for N target file(s)...), a per-file[i/N]progress line for multi-file runs, and a timed completion summary (Reflection generation succeeded after Xs — N generated, M skipped.) in non-verbose mode, so a run is observable when nested under buildkit (where this tool's stdout is the only signal the user sees). - Raised the
tom_analyzer_sharedfloor to>=0.6.1for the verbose per-summary cache-usage trace (using {pkg}@{ver}.sum from cache at {path}), which lets a generation run be audited for actual cache reads.
1.2.1 #
- Track our latest published components:
tom_analyzer_sharedfloor raised to>=0.6.0(ToolCacheLocator shared tool-cache root). All in-workspace dependencies now use lower-bound-only constraints (no upper cap) sopub upgraderesolves to our latest versions during active development.
1.2.0 #
- Analyzer 10 migration: widened the
analyzerconstraint from^8.0.0to^10.0.0and bumpedtom_analyzer_sharedto^0.4.0(analyzer-10 build). The generator'spackage:analyzer/src/dart/constant/*and element/type imports resolve unchanged on analyzer 10. - The 20
Element.isSyntheticcall sites (deprecated in analyzer 10 in favour of theisOriginXflag family) are now routed through a single_elementIsSynthetichelper. This preserves exact behaviour — including the localMixinApplicationshim'sisSyntheticoverride (which is relied upon at real call sites and would route throughnoSuchMethodif migrated toisOriginDeclaration) — and confines the deprecation suppression to one documented place.isOriginDeclarationis not a drop-in replacement because it is not declared on the baseElementtype. - No behavioural change; supersedes the out-of-band
1.1.2(identical source).
1.1.1 #
- Bug fix: Fixed incorrect prefix assignment for mixin-variant types
in
NonGenericClassMirrorImplgeneration. When a type is a synthetic mixin application (e.g.TomFormStringField with TomGenericFieldDecorationMixin), the generic type parameter now uses the prefix for the superclass's library rather than the syntheticMixinApplication's library. Previously this caused'SomeType' isn't a typecompile errors after regeneration.
1.1.0 #
- Standalone CLI: Added analyzer summary caching for 26x faster generation (38s vs 1269s on a Flutter project with 75 dependencies)
- Summary cache stored in
.tom/analyzer-cache/with per-package versioned.sumfiles - SDK summary self-generation with Flutter embedder support
- Topological dependency ordering for correct cross-package type resolution
- Fixed default parameter value extraction from summary-backed elements
- Fixed metadata annotation extraction from summary-backed elements
- CLI output now matches build_runner output byte-for-byte
1.0.2 #
- Bug fixes and internal improvements
1.0.1 #
- Repository reorganization: Moved to tom_module_reflection repository
- Changed tom_reflection dependency to pub.dev version
1.0.0 #
- Extracted the reflection builder/CLI from
tom_buildandtom_build_tools. - Added reusable CLI runner (
runReflectionGeneratorCli). - Published documentation and tests within the new package.