processTemplates function

Future<TemplateCompilerOutputs> processTemplates(
  1. LibraryElement element,
  2. BuildStep buildStep,
  3. CompilerFlags flags
)

Given an input element a.dart, returns output for a.template.dart.

"Output" here is defined in terms of TemplateCompilerOutput, or an abstract collection of elements that need to be emitted into the corresponding .template.dart file. See TemplateCompilerOutput.

Implementation

Future<TemplateCompilerOutputs> processTemplates(
  LibraryElement element,
  BuildStep buildStep,
  CompilerFlags flags,
) async {
  // Collect the elements that will be emitted into `initReflector()`.
  final reflectables = await resolveReflectables(
    buildStep: buildStep,
    from: element,
    flags: flags,
  );

  // Collect the elements to implement `@GeneratedInjector`(s).
  final injectors = InjectorReader.findInjectors(element);

  // Collect the elements to implement views for `@Component`(s).
  final compiler = createTemplateCompiler(buildStep, flags);
  final sourceModule = await compiler.compile(element);

  // Return them to be emitted to disk as generated code in the future.
  return TemplateCompilerOutputs(
    sourceModule,
    reflectables,
    injectors,
  );
}