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

Method findAllSymbols

src/mcp/tools.ts:4369–4405  ·  view source on GitHub ↗

* Find ALL symbols matching a name. Used by callers/callees/impact to aggregate * results across all matching symbols (e.g., multiple classes with an `execute` method).

(cg: CodeGraph, symbol: string)

Source from the content-addressed store, hash-verified

4367 * results across all matching symbols (e.g., multiple classes with an `execute` method).
4368 */
4369 private findAllSymbols(cg: CodeGraph, symbol: string): { nodes: Node[]; note: string } {
4370 let results = cg.searchNodes(symbol, { limit: 50 });
4371
4372 // Mirror the fallback in `findSymbol` for qualified queries — FTS
4373 // strips colons, so a module-qualified lookup needs a second pass
4374 // by the bare last part.
4375 if (results.length === 0 && /[.\/]|::/.test(symbol)) {
4376 const tail = lastQualifierPart(symbol);
4377 if (tail && tail !== symbol) results = cg.searchNodes(tail, { limit: 50 });
4378 }
4379
4380 if (results.length === 0) {
4381 return { nodes: [], note: '' };
4382 }
4383
4384 const exactMatches = results.filter(r => this.matchesSymbol(r.node, symbol));
4385
4386 if (exactMatches.length <= 1) {
4387 const node = exactMatches[0]?.node ?? results[0]!.node;
4388 return { nodes: [node], note: '' };
4389 }
4390
4391 // Same generated-file down-rank as findSymbol — keeps callers/callees
4392 // /impact aggregation aligned (a query against "Send" returns the
4393 // hand-written implementations before the protobuf scaffold).
4394 const ranked = [...exactMatches].sort((a, b) => {
4395 const aGen = isGeneratedFile(a.node.filePath) ? 1 : 0;
4396 const bGen = isGeneratedFile(b.node.filePath) ? 1 : 0;
4397 return aGen - bGen;
4398 });
4399
4400 const locations = ranked.map(r =>
4401 `${r.node.kind} at ${r.node.filePath}:${r.node.startLine}`
4402 );
4403 const note = `\n\n> **Note:** Aggregated results across ${ranked.length} symbols named "${symbol}": ${locations.join(', ')}`;
4404 return { nodes: ranked.map(r => r.node), note };
4405 }
4406
4407 /**
4408 * Truncate output if it exceeds the maximum length

Callers 5

handleCallersMethod · 0.95
handleCalleesMethod · 0.95
handleImpactMethod · 0.95
handleExploreMethod · 0.95

Calls 5

matchesSymbolMethod · 0.95
isGeneratedFileFunction · 0.90
lastQualifierPartFunction · 0.85
joinMethod · 0.80
searchNodesMethod · 0.45

Tested by

no test coverage detected