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

Function resolveByNameAndKind

src/resolution/frameworks/rust.ts:283–304  ·  view source on GitHub ↗

* Resolve a symbol by name using indexed queries instead of scanning all files.

(
  name: string,
  kinds: Set<string>,
  preferredDirPatterns: string[],
  context: ResolutionContext,
)

Source from the content-addressed store, hash-verified

281 * Resolve a symbol by name using indexed queries instead of scanning all files.
282 */
283function resolveByNameAndKind(
284 name: string,
285 kinds: Set<string>,
286 preferredDirPatterns: string[],
287 context: ResolutionContext,
288): string | null {
289 const candidates = context.getNodesByName(name);
290 if (candidates.length === 0) return null;
291
292 const kindFiltered = candidates.filter((n) => kinds.has(n.kind));
293 if (kindFiltered.length === 0) return null;
294
295 // Prefer candidates in framework-conventional directories
296 const preferred = kindFiltered.filter((n) =>
297 preferredDirPatterns.some((d) => n.filePath.includes(d))
298 );
299
300 if (preferred.length > 0) return preferred[0]!.id;
301
302 // Fall back to any match
303 return kindFiltered[0]!.id;
304}
305
306interface ModuleResolution {
307 targetId: string;

Callers 1

resolveFunction · 0.70

Calls 2

hasMethod · 0.80
getNodesByNameMethod · 0.65

Tested by

no test coverage detected