MCPcopy Create free account
hub / github.com/JordanCoin/codemap / buildImportersReportFromGraph

Function buildImportersReportFromGraph

blast_radius.go:1309–1338  ·  view source on GitHub ↗
(root, file string, fg *scanner.FileGraph)

Source from the content-addressed store, hash-verified

1307}
1308
1309func buildImportersReportFromGraph(root, file string, fg *scanner.FileGraph) scanner.ImportersReport {
1310 if filepath.IsAbs(file) {
1311 if rel, err := filepath.Rel(root, file); err == nil {
1312 file = rel
1313 }
1314 }
1315 file = filepath.ToSlash(file)
1316
1317 // Preserve scan order (do not sort): this helper also backs the pre-existing
1318 // `codemap --importers` command, whose output ordering callers depend on.
1319 importers := append([]string(nil), fg.Importers[file]...)
1320 imports := append([]string(nil), fg.Imports[file]...)
1321
1322 report := scanner.ImportersReport{
1323 Root: root,
1324 Mode: "importers",
1325 File: file,
1326 Importers: importers,
1327 Imports: imports,
1328 ImporterCount: len(importers),
1329 IsHub: len(importers) >= 3,
1330 }
1331
1332 for _, imp := range imports {
1333 if fg.IsHub(imp) {
1334 report.HubImports = append(report.HubImports, imp)
1335 }
1336 }
1337 return report
1338}
1339
1340func printAstGrepInstallHint(w io.Writer, err error) {
1341 fmt.Fprintf(w, "Error: %v\n", err)

Calls 1

IsHubMethod · 0.80