MCPcopy Index your code
hub / github.com/angular/angular / getOrCreateNodeInjectorForNode

Function getOrCreateNodeInjectorForNode

packages/core/src/render3/di.ts:193–228  ·  view source on GitHub ↗
(
  tNode: TElementNode | TContainerNode | TElementContainerNode,
  lView: LView,
)

Source from the content-addressed store, hash-verified

191 * @returns Node injector
192 */
193export function getOrCreateNodeInjectorForNode(
194 tNode: TElementNode | TContainerNode | TElementContainerNode,
195 lView: LView,
196): number {
197 const existingInjectorIndex = getInjectorIndex(tNode, lView);
198 if (existingInjectorIndex !== -1) {
199 return existingInjectorIndex;
200 }
201
202 const tView = lView[TVIEW];
203 if (tView.firstCreatePass) {
204 tNode.injectorIndex = lView.length;
205 insertBloom(tView.data, tNode); // foundation for node bloom
206 insertBloom(lView, null); // foundation for cumulative bloom
207 insertBloom(tView.blueprint, null);
208 }
209
210 const parentLoc = getParentInjectorLocation(tNode, lView);
211 const injectorIndex = tNode.injectorIndex;
212
213 // If a parent injector can't be found, its location is set to -1.
214 // In that case, we don't need to set up a cumulative bloom
215 if (hasParentInjector(parentLoc)) {
216 const parentIndex = getParentInjectorIndex(parentLoc);
217 const parentLView = getParentInjectorView(parentLoc, lView);
218 const parentData = parentLView[TVIEW].data as any;
219 // Creates a cumulative bloom filter that merges the parent's bloom filter
220 // and its own cumulative bloom (which contains tokens for all ancestors)
221 for (let i = 0; i < NodeInjectorOffset.BLOOM_SIZE; i++) {
222 lView[injectorIndex + i] = parentLView[parentIndex + i] | parentData[parentIndex + i];
223 }
224 }
225
226 lView[injectorIndex + NodeInjectorOffset.PARENT] = parentLoc;
227 return injectorIndex;
228}
229
230function insertBloom(arr: any[], footer: TNode | null): void {
231 arr.push(0, 0, 0, 0, 0, 0, 0, 0, footer);

Callers 4

di_spec.tsFile · 0.90
resolveProviderFunction · 0.90
initializeDirectivesFunction · 0.90
instantiateAllDirectivesFunction · 0.90

Calls 6

hasParentInjectorFunction · 0.90
getParentInjectorIndexFunction · 0.90
getParentInjectorViewFunction · 0.90
getInjectorIndexFunction · 0.85
insertBloomFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…