chopperGeneratorFactory function

Builder chopperGeneratorFactory(
  1. BuilderOptions options
)

Creates a PartBuilder used to generate code for ChopperApi annotated classes. The options are provided by Dart's build system and read from the build.yaml file.

Implementation

Builder chopperGeneratorFactory(BuilderOptions options) {
  final String buildExtension = _getBuildExtension(options);

  return PartBuilder(
    [const ChopperGenerator()],
    buildExtension,
    header: options.config['header'],
    formatOutput: PartBuilder(
      [const ChopperGenerator()],
      buildExtension,
    ).formatOutput,
    options: !options.config.containsKey('build_extensions')
        ? options.overrideWith(
            BuilderOptions({
              'build_extensions': {
                '.dart': [buildExtension]
              },
            }),
          )
        : options,
  );
}