computeDeps builds the file-to-file dependency graph
()
| 173 | |
| 174 | // computeDeps builds the file-to-file dependency graph |
| 175 | func (d *Daemon) computeDeps() { |
| 176 | start := time.Now() |
| 177 | |
| 178 | // Build file graph (internal file-to-file dependencies) |
| 179 | fg, err := scanner.BuildFileGraph(d.root) |
| 180 | if err != nil { |
| 181 | if d.verbose { |
| 182 | fmt.Printf("[watch] File graph unavailable: %v\n", err) |
| 183 | } |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | d.graph.mu.Lock() |
| 188 | defer d.graph.mu.Unlock() |
| 189 | |
| 190 | // Convert FileGraph to DepContext map |
| 191 | d.graph.DepCtx = make(map[string]*DepContext) |
| 192 | d.graph.FileGraph = fg |
| 193 | |
| 194 | for path := range d.graph.Files { |
| 195 | ctx := &DepContext{ |
| 196 | Imports: fg.Imports[path], |
| 197 | Importers: fg.Importers[path], |
| 198 | } |
| 199 | d.graph.DepCtx[path] = ctx |
| 200 | } |
| 201 | |
| 202 | d.graph.HasDeps = true |
| 203 | |
| 204 | hubCount := len(fg.HubFiles()) |
| 205 | if d.verbose { |
| 206 | fmt.Printf("[watch] File graph: %d files, %d hubs in %v\n", len(d.graph.Files), hubCount, time.Since(start)) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | // addWatchDirs recursively adds directories to the watcher |
| 211 | func (d *Daemon) addWatchDirs() error { |
no test coverage detected