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

Function methodsOf

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

Source from the content-addressed store, hash-verified

1280 cg = await CodeGraph.init(tempDir, { index: true });
1281
1282 const methodsOf = (typeName: string, file: string): string[] => {
1283 const node = cg
1284 .getNodesByKind('struct')
1285 .find((n) => n.name === typeName && n.filePath.replace(/\\/g, '/') === file);
1286 expect(node, `${typeName} @ ${file}`).toBeDefined();
1287 return cg
1288 .getOutgoingEdges(node!.id)
1289 .filter((e) => e.kind === 'contains')
1290 .map((e) => cg.getNode(e.target))
1291 .filter((n) => !!n && n.kind === 'method')
1292 .map((n) => n!.name)
1293 .sort();
1294 };
1295
1296 // Cross-file (non-generic) methods now attach to their struct.
1297 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