MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / findImportDetail

Function findImportDetail

src/tools/search-codebase.ts:403–422  ·  view source on GitHub ↗
(
    details: ImportDetailsGraph | null,
    importer: string,
    imported: string
  )

Source from the content-addressed store, hash-verified

401 type ImpactCandidate = { file: string; line?: number; hop: 1 | 2 };
402
403 function findImportDetail(
404 details: ImportDetailsGraph | null,
405 importer: string,
406 imported: string
407 ): ImportEdgeDetail | null {
408 if (!details) return null;
409 const edges = details[importer];
410 if (!edges) return null;
411 if (edges[imported]) return edges[imported];
412
413 let bestKey: string | null = null;
414 for (const depKey of Object.keys(edges)) {
415 if (!pathsMatch(depKey, imported)) continue;
416 if (!bestKey || depKey.length > bestKey.length) {
417 bestKey = depKey;
418 }
419 }
420
421 return bestKey ? edges[bestKey] : null;
422 }
423
424 // Impact breadth estimate from the import graph (used for risk assessment).
425 // 2-hop: direct importers (hop 1) + importers of importers (hop 2).

Callers 1

collectImportersFunction · 0.85

Calls 1

pathsMatchFunction · 0.85

Tested by

no test coverage detected