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

Function Depgraph

render/depgraph.go:52–366  ·  view source on GitHub ↗

Depgraph renders the dependency flow visualization

(w io.Writer, project scanner.DepsProject)

Source from the content-addressed store, hash-verified

50
51// Depgraph renders the dependency flow visualization
52func Depgraph(w io.Writer, project scanner.DepsProject) {
53 files := project.Files
54 externalDeps := project.ExternalDeps
55 projectName := filepath.Base(project.Root)
56
57 if len(files) == 0 {
58 fmt.Fprintln(w, " No source files found.")
59 return
60 }
61
62 // Build internal names lookup
63 internalNames := make(map[string]bool)
64 extPattern := regexp.MustCompile(`\.[^.]+$`)
65 for _, f := range files {
66 basename := filepath.Base(f.Path)
67 name := strings.ToLower(extPattern.ReplaceAllString(basename, ""))
68 internalNames[name] = true
69 }
70
71 // Use BuildFileGraph for accurate file-level dependency resolution
72 fg, err := scanner.BuildFileGraph(project.Root)
73 var internalDeps map[string][]string
74 var depCounts map[string]int
75 if err == nil && fg != nil {
76 // Build set of files we're displaying (may be filtered by --diff)
77 displayedFiles := make(map[string]bool)
78 for _, f := range files {
79 displayedFiles[f.Path] = true
80 }
81
82 // Filter imports to only include displayed files
83 internalDeps = make(map[string][]string)
84 for file, imports := range fg.Imports {
85 if !displayedFiles[file] {
86 continue
87 }
88 var filtered []string
89 for _, imp := range imports {
90 if displayedFiles[imp] {
91 filtered = append(filtered, imp)
92 }
93 }
94 if len(filtered) > 0 {
95 internalDeps[file] = filtered
96 }
97 }
98
99 // Count importers only among displayed files
100 depCounts = make(map[string]int)
101 for file, importers := range fg.Importers {
102 if !displayedFiles[file] {
103 continue
104 }
105 count := 0
106 for _, imp := range importers {
107 if displayedFiles[imp] {
108 count++
109 }

Callers 6

renderDepsProjectFunction · 0.92
runDepsModeFunction · 0.92
handleGetDependenciesFunction · 0.92

Calls 4

BuildFileGraphFunction · 0.92
titleCaseFunction · 0.85
CenterStringFunction · 0.85
getSystemNameFunction · 0.85