MCPcopy
hub / github.com/colbymchenry/codegraph / groupDefinitions

Method groupDefinitions

src/mcp/tools.ts:1500–1525  ·  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

1498 * `file` path/suffix first.
1499 */
1500 private groupDefinitions(
1501 nodes: Node[],
1502 fileFilter: string | undefined
1503 ): { groups: Node[][]; filteredOut: boolean } {
1504 let pool = nodes;
1505 let filteredOut = false;
1506 if (fileFilter) {
1507 const wanted = fileFilter.replace(/^\.\//, '');
1508 const narrowed = pool.filter(
1509 (n) => n.filePath === wanted || n.filePath.endsWith(wanted) || n.filePath.endsWith(`/${wanted}`)
1510 );
1511 if (narrowed.length > 0) {
1512 pool = narrowed;
1513 } else {
1514 filteredOut = true;
1515 }
1516 }
1517 const byDef = new Map<string, Node[]>();
1518 for (const n of pool) {
1519 const key = `${n.filePath}|${n.qualifiedName}`;
1520 const group = byDef.get(key);
1521 if (group) group.push(n);
1522 else byDef.set(key, [n]);
1523 }
1524 return { groups: [...byDef.values()], filteredOut };
1525 }
1526
1527 /** Section heading for one distinct definition in grouped output. */
1528 private definitionHeading(group: Node[]): string {

Callers 3

handleCallersMethod · 0.95
handleCalleesMethod · 0.95
handleImpactMethod · 0.95

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected