MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / renderParents

Function renderParents

src/ui-server/api/steps.ts:1619–1634  ·  view source on GitHub ↗

How many distinct parents render this node as a JSX child. Memoised per request.

(cg: CodeGraph, node: Node, memo: Map<string, number>)

Source from the content-addressed store, hash-verified

1617
1618/** How many distinct parents render this node as a JSX child. Memoised per request. */
1619function renderParents(cg: CodeGraph, node: Node, memo: Map<string, number>): number {
1620 let parents = memo.get(node.id);
1621 if (parents === undefined) {
1622 const incoming = cg.getIncomingEdgesTo([node.id], ['calls']);
1623 const sources = new Set<string>();
1624 for (const e of incoming) {
1625 // A file renders at module scope — an entry's root, a test's subject
1626 // (#2587) — and is no parent a screen shares chrome with.
1627 if ((e.metadata as Record<string, unknown> | undefined)?.synthesizedBy === 'jsx-render' &&
1628 cg.getNode(e.source)?.kind !== 'file') sources.add(e.source);
1629 }
1630 parents = sources.size;
1631 memo.set(node.id, parents);
1632 }
1633 return parents;
1634}
1635
1636/** A component rendered by several distinct parents is chrome. */
1637function isSharedChrome(cg: CodeGraph, component: Node, memo: Map<string, number>): boolean {

Callers 1

isSharedChromeFunction · 0.85

Calls 5

getNodeMethod · 0.80
getMethod · 0.65
getIncomingEdgesToMethod · 0.45
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected