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

Method groupDefinitions

src/mcp/tools.ts:1607–1632  ·  view source on GitHub ↗

* Group symbol matches into DISTINCT DEFINITIONS — one group per * (filePath, qualifiedName), so same-file overloads stay together while * unrelated same-named classes across a monorepo's apps (#764: one * `UserService` per NestJS app) are kept apart. Optionally narrowed by a * `file` pa

(
    nodes: Node[],
    fileFilter: string | undefined
  )

Source from the content-addressed store, hash-verified

1605 * `file` path/suffix first.
1606 */
1607 private groupDefinitions(
1608 nodes: Node[],
1609 fileFilter: string | undefined
1610 ): { groups: Node[][]; filteredOut: boolean } {
1611 let pool = nodes;
1612 let filteredOut = false;
1613 if (fileFilter) {
1614 const wanted = fileFilter.replace(/^\.\//, '');
1615 const narrowed = pool.filter(
1616 (n) => n.filePath === wanted || n.filePath.endsWith(wanted) || n.filePath.endsWith(`/${wanted}`)
1617 );
1618 if (narrowed.length > 0) {
1619 pool = narrowed;
1620 } else {
1621 filteredOut = true;
1622 }
1623 }
1624 const byDef = new Map<string, Node[]>();
1625 for (const n of pool) {
1626 const key = `${n.filePath}|${n.qualifiedName}`;
1627 const group = byDef.get(key);
1628 if (group) group.push(n);
1629 else byDef.set(key, [n]);
1630 }
1631 return { groups: [...byDef.values()], filteredOut };
1632 }
1633
1634 /** Section heading for one distinct definition in grouped output. */
1635 private definitionHeading(group: Node[]): string {

Callers 3

handleCallersMethod · 0.95
handleCalleesMethod · 0.95
handleImpactMethod · 0.95

Calls 2

getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected