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

Function calledFrom

__tests__/java-overload-arguments.test.ts:445–454  ·  view source on GitHub ↗
(method: string, callText: string, only?: string)

Source from the content-addressed store, hash-verified

443
444 /** The parameter lists a method's call on the given line text reaches (of `only`, when there are two on the line). */
445 const calledFrom = (method: string, callText: string, only?: string): string[] => {
446 const from = cg.getNodesByKind('method').find((n: Node) => n.name === method);
447 expect(from, method).toBeDefined();
448 const file = from!.filePath;
449 const line = lines[file]!.findIndex((text, i) => i >= from!.startLine - 1 && text.includes(callText)) + 1;
450 expect(line, callText).toBeGreaterThan(0);
451 return cg.getOutgoingEdges(from!.id).filter((e) => e.kind === 'calls' && e.line === line)
452 .map((e) => cg.getNode(e.target)!).filter((n) => !only || n.name === only)
453 .map((n) => n.signature ?? '').map((s) => s.slice(s.indexOf('('))).sort();
454 };
455
456 beforeAll(async () => {
457 dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-java-overloads-'));

Callers 1

Calls 4

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

Tested by

no test coverage detected