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

Function filesDefiningSymbol

src/mcp/tools.ts:254–264  ·  view source on GitHub ↗

* Which indexed files define a symbol spelled like this query token? * * The `symbolFiles` lookup `extractQueryPaths` takes, split out for the same * reason as `pathIsProjectFile`: that module stays DB-free. Exact names only — * and the shared matcher for a qualified token (`SQLCompiler.as_sql`)

(cg: CodeGraph, symbol: string)

Source from the content-addressed store, hash-verified

252 * answer "none", which leaves the span's pins as they were.
253 */
254function filesDefiningSymbol(cg: CodeGraph, symbol: string): string[] {
255 try {
256 const goPackageOf = goPackageReaderFor(cg);
257 const nodes = isQualifiedSymbol(symbol)
258 ? cg.getNodesByName(lastQualifierPart(symbol)).filter((n) => matchesSymbol(n, symbol, goPackageOf))
259 : cg.getNodesByName(symbol);
260 return nodes.filter((n) => !NOT_A_DEFINITION.has(n.kind)).map((n) => n.filePath);
261 } catch {
262 return [];
263 }
264}
265
266/**
267 * Calculate the recommended number of codegraph_explore calls based on project size.

Callers 1

handleExploreMethod · 0.85

Calls 7

goPackageReaderForFunction · 0.90
isQualifiedSymbolFunction · 0.90
lastQualifierPartFunction · 0.90
matchesSymbolFunction · 0.90
mapMethod · 0.80
hasMethod · 0.80
getNodesByNameMethod · 0.65

Tested by

no test coverage detected