createTemplateCompiler function

AngularCompiler createTemplateCompiler(
  1. BuildStep buildStep,
  2. CompilerFlags flags
)

Creates the elements necessary to parse HTML templates and compile them.

Implementation

AngularCompiler createTemplateCompiler(
  BuildStep buildStep,
  CompilerFlags flags,
) {
  // Historically, this function was backed by dependency injection at
  // compile-time. In practice today these elements are rarely overriden or only
  // are during specific unit tests.
  final schemaRegistry = DomElementSchemaRegistry();
  final parser = ng.ExpressionParser();
  return AngularCompiler(
    TemplateCompiler(
      DirectiveCompiler(),
      StyleCompiler(flags),
      ViewCompiler(flags, parser, schemaRegistry),
      DartEmitter(
        emitNullSafeSyntax: CompileContext.current.emitNullSafeCode,
      ),
    ),
    AstDirectiveNormalizer(NgAssetReader.fromBuildStep(buildStep)),
    DirectiveConverter(schemaRegistry),
    AstTemplateParser(schemaRegistry, parser, flags),
    buildStep.resolver,
  );
}