How many distinct parents render this node as a JSX child. Memoised per request.
(cg: CodeGraph, node: Node, memo: Map<string, number>)
| 1617 | |
| 1618 | /** How many distinct parents render this node as a JSX child. Memoised per request. */ |
| 1619 | function 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. */ |
| 1637 | function isSharedChrome(cg: CodeGraph, component: Node, memo: Map<string, number>): boolean { |
no test coverage detected