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

Function containersOf

src/graph/dead-code.ts:810–825  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

808 * function's container is the file, which tells us nothing.
809 */
810function 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.

Callers 2

buildDeadCodeReportFunction · 0.85
byNameHookCandidatesFunction · 0.85

Calls 6

mapMethod · 0.80
hasMethod · 0.80
getMethod · 0.65
getIncomingEdgesToMethod · 0.45
setMethod · 0.45
getNodesByIdsMethod · 0.45

Tested by

no test coverage detected