* The type each candidate is declared in, for the candidates that are members. * * One batched query for the whole candidate set, then one for the containers * themselves — never a lookup per row. Only type-ish containers are returned: a * function's container is the file, which tells us nothing
(cg: CodeGraph, nodes: readonly Node[])
| 808 | * function's container is the file, which tells us nothing. |
| 809 | */ |
| 810 | function containersOf(cg: CodeGraph, nodes: readonly Node[]): Map<string, Node> { |
| 811 | const memberIds = nodes.filter((node) => OVERRIDABLE_KINDS.has(node.kind)).map((n) => n.id); |
| 812 | const out = new Map<string, Node>(); |
| 813 | if (memberIds.length === 0) return out; |
| 814 | |
| 815 | const edges = cg.getIncomingEdgesTo(memberIds, ['contains']); |
| 816 | const byMember = new Map<string, string>(); |
| 817 | for (const edge of edges) if (!byMember.has(edge.target)) byMember.set(edge.target, edge.source); |
| 818 | |
| 819 | const containerNodes = cg.getNodesByIds([...new Set(byMember.values())]); |
| 820 | for (const [memberId, containerId] of byMember) { |
| 821 | const container = containerNodes.get(containerId); |
| 822 | if (container && CONTAINER_KINDS.has(container.kind)) out.set(memberId, container); |
| 823 | } |
| 824 | return out; |
| 825 | } |
| 826 | |
| 827 | /** |
| 828 | * Which candidates override something — the ids to drop. |
no test coverage detected