plan method

IncrementalGenerationPlan plan({
  1. required List<File> specs,
  2. required List<String> outputPathsForSpec(
    1. File spec
    ),
})

Implementation

IncrementalGenerationPlan plan({
  required List<File> specs,
  required List<String> Function(File spec) outputPathsForSpec,
}) {
  final manifest = _readManifest();
  final generator = _generatorStamp();
  final changed = <File>[];
  for (final spec in specs) {
    final rel = p.relative(spec.path, from: projectRoot);
    final upToDate = outputPathsForSpec(spec).every((path) => File(path).existsSync());
    // An entry that does not destructure — absent, or written by a CLI old
    // enough to omit 'generator' — falls through to a regenerate.
    if (manifest[rel] case {'hash': final String cached, 'generator': final String stamp}
        when cached == contentHash(spec) && stamp == generator && upToDate) {
      continue;
    }
    changed.add(spec);
  }
  return IncrementalGenerationPlan(List.unmodifiable(changed));
}