ProviderElementContext constructor
ProviderElementContext(
- ProviderViewContext _rootProviderContext,
- ProviderElementContext? _parent,
- bool _isViewRoot,
- List<
DirectiveAst> _directiveAsts, - List<
AttrAst> attrs, - List<
ReferenceAst> refs, - SourceSpan? _sourceSpan,
Implementation
ProviderElementContext(
this._rootProviderContext,
this._parent,
this._isViewRoot,
this._directiveAsts,
List<AttrAst> attrs,
List<ReferenceAst> refs,
this._sourceSpan) {
for (var attrAst in attrs) {
_attrs[attrAst.name] = attrAst.value;
}
final directivesMeta = _directiveMetadataFromAst(_directiveAsts);
// Make a list of all providers required by union of all directives
// including components themselves.
final resolver = _ProviderResolver(directivesMeta, _sourceSpan);
_allProviders = resolver.resolve();
// Get content queries since we need to eagerly create providers to serve
// values for component @ContentChild/@ContentChildren at ngOnInit time.
_contentQueries = _getContentQueries(directivesMeta);
var queriedTokens = CompileTokenMap<bool>();
for (var provider in _allProviders.values) {
_addQueryReadsTo(provider.token, queriedTokens);
}
// For each #ref, add the read type as a token to queries.
for (var refAst in refs) {
_addQueryReadsTo(CompileTokenMetadata(value: refAst.name), queriedTokens);
}
// If any content query asks to read ViewContainerRef, mark
// ProviderElementContext to require view container.
if (queriedTokens.get(identifierToken(Identifiers.viewContainerRef)) !=
null) {
_requiresViewContainer = true;
}
// Create the providers that we know are eager first.
for (var provider in _allProviders.values) {
var eager = provider.eager || queriedTokens.get(provider.token) != null;
if (eager) {
_getOrCreateLocalProvider(provider.providerType, provider.token,
eager: true);
}
}
}