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

Method isPolymorphicSibling

src/mcp/tools.ts:5608–5622  ·  view source on GitHub ↗
(nodes: Node[])

Source from the content-addressed store, hash-verified

5606 const MIN_SIBLINGS = 3;
5607 const siblingSuper = new Map<string, boolean>();
5608 const isPolymorphicSibling = (nodes: Node[]): boolean => {
5609 for (const n of nodes) {
5610 for (const e of cg.getOutgoingEdges(n.id)) {
5611 if (e.kind !== 'implements' && e.kind !== 'extends') continue;
5612 let many = siblingSuper.get(e.target);
5613 if (many === undefined) {
5614 many = cg.getIncomingEdges(e.target)
5615 .filter((x) => x.kind === 'implements' || x.kind === 'extends').length >= MIN_SIBLINGS;
5616 siblingSuper.set(e.target, many);
5617 }
5618 if (many) return true;
5619 }
5620 }
5621 return false;
5622 };
5623
5624 // A file that DEFINES a polymorphic supertype (a class/interface with ≥
5625 // MIN_SIBLINGS implementers) AND co-locates its subclasses is a redundant

Callers

nothing calls this directly

Calls 4

getMethod · 0.65
getIncomingEdgesMethod · 0.65
getOutgoingEdgesMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected