Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions __tests__/graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,19 @@ export { main };
expect(Array.isArray(callers)).toBe(true);
});

it('should get instantiating callers of a class', () => {
const nodes = cg.getNodesByKind('class');
const derivedClass = nodes.find((n) => n.name === 'DerivedClass');

if (!derivedClass) {
return;
}

const callers = cg.getCallers(derivedClass.id);

expect(callers.some((c) => c.node.name === 'main' && c.edge.kind === 'instantiates')).toBe(true);
});

it('should get callees of a function', () => {
const nodes = cg.getNodesByKind('function');
const processValue = nodes.find((n) => n.name === 'processValue');
Expand Down
2 changes: 1 addition & 1 deletion src/graph/traversal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class GraphTraverser {
}
visited.add(nodeId);

const incomingEdges = this.queries.getIncomingEdges(nodeId, ['calls', 'references', 'imports']);
const incomingEdges = this.queries.getIncomingEdges(nodeId, ['calls', 'references', 'imports', 'instantiates']);
if (incomingEdges.length === 0) return;

// Batch-fetch all caller nodes in one round-trip instead of one
Expand Down