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

Function resolveByNameAndKind

src/resolution/frameworks/java.ts:530–551  ·  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

528 * Resolve a symbol by name using indexed queries instead of scanning all files.
529 */
530function resolveByNameAndKind(
531 name: string,
532 kinds: Set<string>,
533 preferredDirPatterns: string[],
534 context: ResolutionContext,
535): string | null {
536 const candidates = context.getNodesByName(name);
537 if (candidates.length === 0) return null;
538
539 const kindFiltered = candidates.filter((n) => kinds.has(n.kind));
540 if (kindFiltered.length === 0) return null;
541
542 // Prefer candidates in framework-conventional directories
543 const preferred = kindFiltered.filter((n) =>
544 preferredDirPatterns.some((d) => n.filePath.includes(d))
545 );
546
547 if (preferred.length > 0) return preferred[0]!.id;
548
549 // Fall back to any match
550 return kindFiltered[0]!.id;
551}

Callers 1

resolveFunction · 0.70

Calls 2

hasMethod · 0.80
getNodesByNameMethod · 0.65

Tested by

no test coverage detected