MCPcopy
hub / github.com/angular/angular / discoverDiGraph

Function discoverDiGraph

packages/core/src/debug/ai/di_graph.ts:68–83  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…