convertMatchedDirective function

MatchedDirective convertMatchedDirective(
  1. DirectiveAst directive,
  2. ProviderSource? providerSource,
  3. CompileElement compileElement,
  4. CompileDirectiveMetadata compileDirectiveMetadata,
)

Converts a single ast.DirectiveAst node into a ir.MatchedDirective instance.

ProviderSource represents the underlying Directive instance that has been matched.

CompileElement represents the element in the template that the directive has matched.

AnalyzedClass represents the Component class that is currently being compiled.

Implementation

ir.MatchedDirective convertMatchedDirective(
  ast.DirectiveAst directive,
  ProviderSource? providerSource,
  CompileElement compileElement,
  CompileDirectiveMetadata compileDirectiveMetadata,
) {
  var inputs = convertAllToBinding(
    directive.inputs,
    directive: directive.directive,
    compileDirectiveMetadata: compileDirectiveMetadata,
    compileElement: compileElement,
  );

  var outputs = convertAllToBinding(
    directive.outputs,
    directive: directive.directive,
    compileDirectiveMetadata: compileDirectiveMetadata,
    compileElement: compileElement,
  );
  outputs = mergeEvents(outputs);

  return ir.MatchedDirective(
    providerSource: providerSource,
    inputs: inputs,
    outputs: outputs,
    hasInputs: directive.directive.inputs.isNotEmpty,
    hasHostProperties: directive.hasHostProperties,
    isComponent: directive.directive.isComponent,
    isOnPush:
        directive.directive.changeDetection == ChangeDetectionStrategy.OnPush,
    lifecycles: _lifecycles(directive.directive),
  );
}