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

Method groupDefinitions

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

2200 * `file` path/suffix first.
2201 */
2202 private groupDefinitions(
2203 nodes: Node[],
2204 fileFilter: string | undefined
2205 ): { groups: Node[][]; filteredOut: boolean } {
2206 let pool = nodes;
2207 let filteredOut = false;
2208 if (fileFilter) {
2209 const wanted = fileFilter.replace(/^\.\//, '');
2210 const narrowed = pool.filter(
2211 (n) => n.filePath === wanted || n.filePath.endsWith(wanted) || n.filePath.endsWith(`/${wanted}`)
2212 );
2213 if (narrowed.length > 0) {
2214 pool = narrowed;
2215 } else {
2216 filteredOut = true;
2217 }
2218 }
2219 const byDef = new Map<string, Node[]>();
2220 for (const n of pool) {
2221 const key = `${n.filePath}|${n.qualifiedName}`;
2222 const group = byDef.get(key);
2223 if (group) group.push(n);
2224 else byDef.set(key, [n]);
2225 }
2226 return { groups: [...byDef.values()], filteredOut };
2227 }
2228
2229 /** Section heading for one distinct definition in grouped output. */
2230 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