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

Function sharedPrefix

src/resolution/import-resolver.ts:2815–2823  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

2813function pickClosestJvmCandidate(candidates: Node[], fromPath: string): Node {
2814 const fromDirs = fromPath.split('/').slice(0, -1);
2815 const sharedPrefix = (p: string): number => {
2816 const d = p.split('/').slice(0, -1);
2817 let shared = 0;
2818 for (let i = 0; i < Math.min(fromDirs.length, d.length); i++) {
2819 if (fromDirs[i] === d[i]) shared++;
2820 else break;
2821 }
2822 return shared;
2823 };
2824 const isExpect = (n: Node): boolean => Array.isArray(n.decorators) && n.decorators.includes('expect');
2825 let best = candidates[0]!;
2826 let bestProx = sharedPrefix(best.filePath);

Callers 1

pickClosestJvmCandidateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected