tom_analyzer_shared 0.1.0
tom_analyzer_shared: ^0.1.0 copied to clipboard
Shared analyzer-summary caching infrastructure reused by Tom code generators (reflection, d4rt bridges, etc).
tom_analyzer_shared #
Shared analyzer-summary caching infrastructure reused by Tom code
generators. It was extracted from tom_reflection_generator so multiple
tools (reflection, d4rt bridges, ...) can share the same summary cache
at <workspace>/.tom/analyzer-cache/ and avoid rescanning stable
dependencies on every run.
What it does #
For a project with a resolved pubspec.lock, this library can:
- Enumerate all dependencies with their exact versions and source
types (
hosted,sdk,path,git). - Decide which of them are cacheable (hosted pub.dev packages and SDK packages — their versions are stable).
- Build a binary summary (
.sum) for the Dart SDK (including Flutterdart:uiviasky_engine/_embedder.yamlwhen Flutter is on the path) and for each cacheable package, in topological order so that a package's summary can reference its dependencies' summaries. - Store all summaries under
<workspace>/.tom/analyzer-cache/using the naming scheme{package}@{version}.sumandsdk@{dart-version}.sum. - Return the list of summary paths so callers can pass them to
AnalysisContextCollectionImpl(..., librarySummaryPaths: summaryPaths, sdkSummaryPath: sdkSummaryPath)and skip re-analysing those packages from sources.
Public API #
Import everything via the top-level library:
import 'package:tom_analyzer_shared/tom_analyzer_shared.dart';
Main types and functions:
PackageDependency,DependencySet— resolved dependency metadata.DependencyResolver— parsespubspec.lock, resolves hosted and SDK package locations.SummaryCacheManager— reads and writes.sumfiles in the shared cache directory.SummaryGenerator— generates the SDK summary and per-package summaries (topological order, progress callback, error aggregation).runSummaryCacheStage()— convenience entry-point used by CLI tools. Resolves dependencies, generates what's missing, and returns aSummaryCacheResult(summaryPaths, sdkSummaryPath).
Typical usage #
final result = await runSummaryCacheStage(
projectRoot,
verbose: true,
);
final collection = AnalysisContextCollectionImpl(
includedPaths: [projectRoot],
sdkSummaryPath: result?.sdkSummaryPath,
librarySummaryPaths: result?.summaryPaths ?? const [],
);
Both tom_reflection_generator and tom_d4rt_generator use this stage
to share a single cache directory across runs.