Skip to main content

tom_ast_generator 0.1.17 copy "tom_ast_generator: ^0.1.17" to clipboard
tom_ast_generator: ^0.1.17 copied to clipboard

AST converter from Dart analyzer AST to serializable AST model.

0.1.17 #

Changed — resolves tom_d4rt_ast 0.210.0 and tom_d4rt_exec 1.50.0 (dfin9) #

tom_d4rt_ast ^0.210.0 and dev tom_d4rt_exec ^1.50.0, carrying the web int fix.

0.1.16 #

Changed — resolves tom_d4rt_ast 0.209.0 and tom_d4rt_exec 1.48.0 (dfin7) #

tom_d4rt_ast ^0.209.0 and dev tom_d4rt_exec ^1.48.0, the correctness release.

0.1.15 #

Changed — resolves tom_d4rt_ast 0.207.0 and tom_d4rt_exec 1.45.0 (dfin4) #

tom_d4rt_ast ^0.207.0 and dev tom_d4rt_exec ^1.45.0, the security release.

0.1.14 #

Changed — resolves tom_d4rt_ast 0.206.0 and tom_d4rt_exec 1.42.0 (sci2) #

tom_d4rt_ast ^0.206.0 and dev tom_d4rt_exec ^1.42.0. The generator tests read generated code through test/generator_tests/support/generated_code.dart, the helper tom_d4rt_generator's own suite uses, because tom_d4rt_generator 1.51.0 formats what it writes.

0.1.13 #

Fixed — a failed project fails the run whether or not --verbose is set (scf33) #

A conversion whose output could not be resolved (a project: name not in the workspace) printed an error and counted it, but only a --verbose run turned the count into a failure: the same configuration exited 0 without the flag — including under --dry-run, the way a new configuration is checked. The project's verdict is now the error count, whatever was printed.

Docs — the astgen reference describes the shipped tool (scf33) #

doc/astgen_build_yaml.md is rewritten from lib/src/v2/: the astgen: section of buildkit.yaml is the only configuration, every convert key with its default, the three output forms and the project lookup, the output naming (hello.runner.dart → hello.runner.ast.yaml), what fails a project, and the command-line options. doc/tom_build_configuration_and_cli.md is removed: it described tom_build.yaml / build.yaml configuration and a registration-code generator, none of which the package has. test/v2/scf33_astgen_doc_examples_test.dart runs every astgen: example in the doc through the executor.

0.1.12 #

Changed — conditional imports are resolved for the bundle's target (scf16) #

AstBundler followed only a directive's default URI, so import 'stub.dart' if (dart.library.io) 'io.dart'; bundled the stub on every platform although the tree carried both branches (since sce49). The bundler now resolves configurations when it builds: AstBundlerConfig.target, a BundleTarget naming the platform's dart: libraries and environment declarations, selects the first branch whose condition holds (else the default), only that module is bundled, and the import or export is rewritten to it with its configurations dropped.

The default target is BundleTarget.vm, so a VM bundle of a source tree with conditional imports now carries the dart.library.io branch where it used to carry the default. Build with BundleTarget.web for a bundle a web app loads. A bundle is therefore specific to its target.

Numbered 0.1.12 rather than 0.2.0 for the reason sce241 gave: tom_d4rt_exec, a dev dependency here, constrains this package to ^0.1.x, so a 0.2.0 could not resolve its own dev dependencies.

0.1.11 #

Changed — resolves the current interpreter (sce237) #

Requires tom_d4rt_ast ^0.184.0 (published 2026-09-29). Dev dependencies follow: tom_d4rt_exec ^1.35.0 and tom_d4rt_generator ^1.46.0.

Added — every bundle names the astgen that wrote it (scf3, sce15) #

AstBundler now sets AstBundle.generator to tom_ast_generator <version> on every bundle it builds, from createFromSource and createFromFile alike. The version is the versioner stamp, the same value astgen --version prints, so a bundle cannot disagree with the tool's banner. It reaches the plain JSON, the gzip bytes and the ZIP manifest. A bundle that misbehaves on a device can now say which tool produced it. Older bundles still load, with generator null. This uses the field tom_d4rt_ast published in the 0.115.0 line, which every release this package accepts carries.

0.1.10 #

Added — AstBundlerConfig.includeSources (sce236) #

(This release was first numbered 0.2.0 in the working tree and never published as that. A patch release on purpose. The option is additive and off by default, and a 0.2.0 would fall outside the ^0.1.x that every published tom_d4rt_exec declares. tom_d4rt_exec is this package's own dev dependency, so 0.2.0 could not resolve at all (sce241).)

The bundler can now fill AstBundle.sources with every bundled module's source text. The analyzer-free interpreter uses it to quote the script in a diagnostic. The option is off by default: it costs bundle size, and a release bundle may not want to ship its own source.

Measured 2026-09-29 on a 26 KB corpus script (material/animated_theme_test.dart):

Without sources With sources Change
JSON 308 KB 335 KB +9%
Gzipped 26.7 KB 30.9 KB +16%

0.1.9 #

Changed — resolves the current interpreter (sce212) #

tom_d4rt_ast ^0.177.0 (was ^0.65.0). Every published 0.1.6-0.1.8 pinned 0.65.0, so a consumer on a current interpreter could not resolve any of them and pub fell back to 0.1.5 — the copier from before sce62's library directive fix — without saying so. Dev dependencies follow: tom_d4rt_exec ^1.33.0, tom_d4rt_generator >=1.44.0, and the examples' exec floors.

0.1.8 #

Fixed — library directives crashed the copier (sce62) #

_convertLibraryDirective cast node.name to SIdentifier?, but the LibraryIdentifier that holds it had no dispatch arm in convert(). So it became the _SUnknownNode placeholder and the cast failed:

type '_SUnknownNode' is not a subtype of type 'SIdentifier?' in type cast

library foo; main() => 42; is valid Dart that the reference interpreter runs and returns 42 for — a library directive has no runtime effect. exec could not interpret it at all, which is a conformance break rather than a missing feature.

The name is flattened to one SSimpleIdentifier carrying the dotted text. SPrefixedIdentifier could have carried two components but not three, so it would have worked until somebody wrote library a.b.c. Nothing reads the component structure; the flattening is recorded at the conversion site rather than left to be rediscovered.

Changed — an unhandled node now says what it is #

An unhandled node type reaches _SUnknownNode, and the two paths that consume converted nodes both failed badly:

  • _as<T> cast, producing type '_SUnknownNode' is not a subtype of type 'SIdentifier?' in type cast — naming neither the construct nor its position.
  • _nodesAs<T> filtered on a type pattern, so an unhandled node in a statement, member or collection list was silently dropped and the script ran without it.

Both now raise UnsupportedError naming the analyzer node type, the offset and the source text, the way the reference interpreter's Unsupported AST node 'X' at offset N does. The two constructs this currently affects — class B = A with M; and dot shorthands — are unsupported by the reference interpreter too, so this changes the diagnosis rather than the capability.

No construct reaches the _nodesAs drop today: every statement, class-member and collection-element type the analyzer parses is dispatched, and Configuration, the one list element that WAS dropped (0.1.7), has had an arm since. That path is closed for the next unhandled type rather than for a present defect.

Added — tool/census_copier.dart #

Which of the copier's 154 _convert* methods a test suite has never executed, and which node types reach the placeholder. See the file header for what the census can and cannot see — notably that it cannot see a handled node whose FIELD is silently not copied, which is what 0.1.7 fixed.

0.1.7 #

Fixed — conditional import/export branches are no longer dropped (sce49) #

_convertImportDirective read uri, prefix, combinators and deferredKeyword, and never node.configurations — because the mirror AST had no field to put them in. _convertExportDirective was the same. So

import 'stub.dart' if (dart.library.io) 'io.dart';

reached every consumer as import 'stub.dart';: a well-formed import of the default URI with nothing anywhere recording that a branch had been discarded. Conditional imports are the standard Dart mechanism for VM-vs-web divergence, so the symptom surfaces on one platform, far from the cause.

Both converters now populate configurations, and analyzer.Configuration and analyzer.DottedName are in the convert() dispatch chain — a node type that is not in it falls through to the opaque unknown-node placeholder and is then filtered out of the typed list, which is how DGUB8 lost every record-type field.

The conditions are COPIED, not evaluated: which branch applies depends on the target platform, which this converter does not know.

Requires tom_ast_model 0.2.2, which adds SConfiguration and SDottedName.

Added — a 1:1 fidelity ratchet over the directive nodes #

test/directive_mirror_fidelity_test.dart enumerates, by reflection, every getter the analyzer's ImportDirective, ExportDirective, Configuration and DottedName declare, and requires each to be classified exactly once: mirrored (naming the field on the mirror node, which must exist) or deliberately absent (with the reason). A field the analyzer adds later is in neither set and fails the test by name, instead of disappearing the way configurations did.

0.1.6 #

Released — so the corrected stamp reaches the package people install (sce9) #

The tree's stamp has read 0.1.6 for some time; published 0.1.5 still ships one saying 0.1.4, so astgen --version from pub.dev names the wrong release. This release carries the corrected stamp.

Changed — formatted the tree once (scd82) #

Every package in this repo already declares an SDK floor above the 3.7 tall-style boundary, so the formatter can no longer produce two layouts here. What was not true is that the trees were formatted: until this commit, running dart format on any single file rewrote it wholesale and buried whatever real edit came with it.

Proven layout-only rather than assumed. git diff -w cannot establish it, because the tall style splits lines and a whitespace-insensitive diff still counts a moved boundary as a change. What was checked is the token stream, per file, twice: whitespace stripped, then whitespace and commas stripped. All 44 changed files are identical to HEAD under that normalisation — no braces were needed, so this commit is pure layout.

dart analyze is clean, the suite passes (566 tests), and the formatter is now idempotent here.

0.1.5 #

Fixed — record type annotation fields are converted, not dropped (DGUB8) #

_convertRecordTypeAnnotation called the generic convert() on each analyzer.RecordTypeAnnotationField. That class was never in the dispatch chain, so every field fell through to the opaque unknown-node placeholder: the mirror annotation reached the interpreter carrying only its ARITY — no field types, and no named-field keys. Downstream that made (42, label: 'answer') is (int, {String label}) unanswerable, and let (1, 'a') is (String, int) answer true.

Fields now convert into SRecordTypeField (tom_ast_model 0.2.0), keeping the declared type — recursively, so a record inside a record survives — and the named-field key. RecordTypeAnnotationField is also wired into the generic dispatch, so no future caller can silently produce a placeholder again.

Requires tom_ast_model >=0.2.0.

0.1.4 #

  • Publish the analyzer-10 migration. The 0.1.3 release on pub.dev still carried analyzer: ^8.0.0 / tom_d4rt_ast: ^0.1.5; the source had already moved to analyzer: ^10.0.0 / tom_d4rt_ast >=0.1.11 without a version bump, so the hosted package was stale. This bump ships the analyzer-10 constraints.
  • In-workspace dependencies now use lower-bound-only constraints (no upper cap) so pub upgrade tracks our latest published components during active development.

0.1.3 #

  • Housekeeping: test artifacts now live in a gitignored testlog/ folder; doc/ no longer ships machine-generated baselines or last_testrun.json. No code changes.

0.1.2 #

  • Documentation: build.yaml/CLI guide, limitations, and user guide updated; README aligned with the source-primary documentation reframe across the D4rt ecosystem.

0.1.1 #

  • Consume tom_ast_model ^0.1.1 / tom_d4rt_ast ^0.1.5: the converter now populates the StaticResolver slot-resolution members (resolvedSlot / declSlot) on the mirror AST it emits.

0.1.0 #

  • First public release on pub.dev.
  • 1:1 converter from the Dart analyzer AST to the serializable mirror AST (SAstNode from tom_ast_model), node-for-node and field-for-field.
  • AST bundling machinery: parse once with the analyzer, copy to the mirror AST, serialize to JSON, interpret later without the analyzer.
0
likes
150
points
771
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

AST converter from Dart analyzer AST to serializable AST model.

Homepage
Repository (GitHub)
View/report issues

Topics

#ast #analyzer #interpreter #d4rt

License

BSD-3-Clause (license)

Dependencies

analyzer, args, glob, path, tom_ast_model, tom_build_base, tom_d4rt_ast, yaml

More

Packages that depend on tom_ast_generator