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

Function methodsOf

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

Source from the content-addressed store, hash-verified

1541 cg = await CodeGraph.init(tempDir, { index: true });
1542
1543 const methodsOf = (typeName: string, file: string): string[] => {
1544 const node = cg
1545 .getNodesByKind('struct')
1546 .find((n) => n.name === typeName && n.filePath.replace(/\\/g, '/') === file);
1547 expect(node, `${typeName} @ ${file}`).toBeDefined();
1548 return cg
1549 .getOutgoingEdges(node!.id)
1550 .filter((e) => e.kind === 'contains')
1551 .map((e) => cg.getNode(e.target))
1552 .filter((n) => !!n && n.kind === 'method')
1553 .map((n) => n!.name)
1554 .sort();
1555 };
1556
1557 // Cross-file (non-generic) methods now attach to their struct.
1558 expect(methodsOf('Box', 'box.go')).toEqual(['Get', 'Set']);

Callers 1

resolution.test.tsFile · 0.70

Calls 3

getNodeMethod · 0.80
getNodesByKindMethod · 0.65
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected