CompileView constructor
CompileView(
- CompileDirectiveMetadata component,
- CompilerFlags genConfig,
- List<
CompileTypedMetadata> directiveTypes, - List<
CompilePipeMetadata?> pipeMetas, - Expression styles,
- int viewIndex,
- CompileElement declarationElement,
- List<
VariableAst> templateVariables, - bool enableDataDebugSource,
Implementation
CompileView(
this.component,
this.genConfig,
this.directiveTypes,
this.pipeMetas,
this.styles,
this.viewIndex,
this.declarationElement,
this.templateVariables,
this.enableDataDebugSource,
) {
nameResolver = ViewNameResolver(this);
storage = CompileViewStorage();
viewType = _getViewType(component, viewIndex);
className = '${viewIndex == 0 && viewType != ViewType.host ? '' : '_'}'
'View${component.type.name}$viewIndex';
classType = o.importType(CompileIdentifierMetadata(name: className))!;
viewFactoryName = getViewFactoryName(component, viewIndex);
viewFactory = getViewFactory(component, viewFactoryName);
switch (viewType) {
case ViewType.host:
case ViewType.component:
componentView = this;
break;
default:
// An embedded template uses it's declaration element's componentView.
componentView = declarationElement.view!.componentView;
break;
}
viewQueries = CompileTokenMap<List<CompileQuery>>();
if (viewType == ViewType.component) {
var directiveInstance = BuiltInSource(
identifierToken(component.type), DetectChangesVars.cachedCtx);
var queryIndex = -1;
for (var metadata in component.viewQueries) {
queryIndex++;
final query = CompileQuery.viewQuery(
metadata: metadata,
storage: storage,
queryRoot: this,
boundDirective: directiveInstance,
queryIndex: queryIndex,
);
addQueryToTokenMap(viewQueries, query);
}
}
for (var variable in templateVariables) {
nameResolver.addLocal(
variable.name,
o.ReadClassMemberExpr('locals').key(o.literal(variable.value)),
variable.type, // NgFor locals are augmented with type information.
);
}
if (declarationElement.parent != null) {
declarationElement.setEmbeddedView(this);
}
}