MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / methodsOf

Function methodsOf

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

Source from the content-addressed store, hash-verified

1190 cg = await CodeGraph.init(tempDir, { index: true });
1191
1192 const methodsOf = (typeName: string, file: string): string[] => {
1193 const node = cg
1194 .getNodesByKind('struct')
1195 .find((n) => n.name === typeName && n.filePath.replace(/\\/g, '/') === file);
1196 expect(node, `${typeName} @ ${file}`).toBeDefined();
1197 return cg
1198 .getOutgoingEdges(node!.id)
1199 .filter((e) => e.kind === 'contains')
1200 .map((e) => cg.getNode(e.target))
1201 .filter((n) => !!n && n.kind === 'method')
1202 .map((n) => n!.name)
1203 .sort();
1204 };
1205
1206 // Cross-file (non-generic) methods now attach to their struct.
1207 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