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

Function methodsOf

__tests__/resolution.test.ts:1772–1784  ·  view source on GitHub ↗
(typeName: string, file: string)

Source from the content-addressed store, hash-verified

1770 cg = await CodeGraph.init(tempDir, { index: true });
1771
1772 const methodsOf = (typeName: string, file: string): string[] => {
1773 const node = cg
1774 .getNodesByKind('struct')
1775 .find((n) => n.name === typeName && n.filePath.replace(/\\/g, '/') === file);
1776 expect(node, `${typeName} @ ${file}`).toBeDefined();
1777 return cg
1778 .getOutgoingEdges(node!.id)
1779 .filter((e) => e.kind === 'contains')
1780 .map((e) => cg.getNode(e.target))
1781 .filter((n) => !!n && n.kind === 'method')
1782 .map((n) => n!.name)
1783 .sort();
1784 };
1785
1786 // Cross-file (non-generic) methods now attach to their struct.
1787 expect(methodsOf('Box', 'box.go')).toEqual(['Get', 'Set']);

Callers 1

resolution.test.tsFile · 0.70

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesByKindMethod · 0.65
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected