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

Function serializeAncestors

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

* Serialize all the ancestors of the given injector and return * its serialized version. * * @param injector The environment injector to start from. * @returns The serialized form of the input Injector.

(injector: Injector)

Source from the content-addressed store, hash-verified

168 * @returns The serialized form of the input {@link Injector}.
169 */
170 function serializeAncestors(injector: Injector): SerializedInjector {
171 const existing = serializedEnvInjectorMap.get(injector);
172 if (existing) return existing;
173
174 const serialized = serializeInjector(injector);
175 serializedEnvInjectorMap.set(injector, serialized);
176
177 const parentInjector = getParentEnvInjector(injector);
178 if (parentInjector) {
179 // Recursively process the parent and attach ourselves as a child.
180 const parentSerialized = serializeAncestors(parentInjector);
181 parentSerialized.children.push(serialized);
182 } else {
183 // If there is no parent, this is a root environment injector.
184 if (!rootEnvInjector) {
185 rootEnvInjector = serialized;
186 } else if (rootEnvInjector !== serialized) {
187 throw new Error('Expected only one root environment injector, but found multiple.', {
188 cause: {firstRoot: rootEnvInjector, secondRoot: serialized},
189 });
190 }
191 }
192
193 return serialized;
194 }
195
196 // Process all descendant environment injectors.
197 for (const rootLView of rootLViews) {

Callers 1

collectEnvInjectorsFunction · 0.85

Calls 5

serializeInjectorFunction · 0.90
getParentEnvInjectorFunction · 0.85
getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected