MCPcopy Create free account
hub / github.com/angular/angular / discoverDiGraph

Function discoverDiGraph

packages/core/src/debug/ai/di_graph.ts:70–85  ·  view source on GitHub ↗

* Traverses the Angular internal tree from the root to discover element and environment injectors.

(roots: HTMLElement[])

Source from the content-addressed store, hash-verified

68 * Traverses the Angular internal tree from the root to discover element and environment injectors.
69 */
70function discoverDiGraph(roots: HTMLElement[]): DiGraph {
71 const rootLViews = roots.map((root) => {
72 const lContext = getLContext(root);
73 if (!lContext?.lView) {
74 throw new Error(
75 `Could not find an \`LView\` for root \`<${root.tagName.toLowerCase()}>\`, is it an Angular component?`,
76 );
77 }
78 return lContext.lView;
79 });
80
81 return {
82 elementInjectorRoots: rootLViews.map((rootLView) => walkElementInjectors(rootLView)),
83 environmentInjectorRoot: collectEnvInjectors(rootLViews),
84 };
85}
86
87/**
88 * Traverses all directive-hosting nodes in the `rootLView` hierarchy and builds a tree of

Callers 1

di_graph.tsFile · 0.85

Calls 4

getLContextFunction · 0.90
walkElementInjectorsFunction · 0.85
collectEnvInjectorsFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected