()
| 211 | } |
| 212 | |
| 213 | func (w *Watcher) DoCycle() { |
| 214 | w.wm.Lock() |
| 215 | defer w.wm.Unlock() |
| 216 | |
| 217 | changedPaths, overflow := w.wm.DrainEvents() |
| 218 | hasEvents := len(changedPaths) > 0 || overflow |
| 219 | |
| 220 | if w.recheckTsConfig() { |
| 221 | return |
| 222 | } |
| 223 | |
| 224 | if hasEvents && !overflow && !w.configModified { |
| 225 | // Filter fswatch events against known dependencies |
| 226 | if w.isRelevantChange(changedPaths) { |
| 227 | w.evictChangedSourceFiles(changedPaths) |
| 228 | } else { |
| 229 | if w.wm.DebugLog != nil { |
| 230 | fmt.Fprintf(w.wm.DebugLog, "[watch] DoCycle: %d event(s) not relevant to compilation, skipping rebuild\n", len(changedPaths)) |
| 231 | } |
| 232 | if w.testing != nil { |
| 233 | w.testing.OnProgram(w.program) |
| 234 | } |
| 235 | return |
| 236 | } |
| 237 | } else if overflow { |
| 238 | // Overflow: evict the entire source file cache to force re-build |
| 239 | w.sourceFileCache = &collections.SyncMap[tspath.Path, *cachedSourceFile]{} |
| 240 | } else if !hasEvents && !w.configModified { |
| 241 | // No events and no config change |
| 242 | if w.wm.DebugLog != nil { |
| 243 | fmt.Fprintf(w.wm.DebugLog, "[watch] DoCycle: no events, skipping\n") |
| 244 | } |
| 245 | if w.testing != nil { |
| 246 | w.testing.OnProgram(w.program) |
| 247 | } |
| 248 | return |
| 249 | } |
| 250 | |
| 251 | w.reportWatchStatus(ast.NewCompilerDiagnostic(diagnostics.File_change_detected_Starting_incremental_compilation)) |
| 252 | if err := w.doBuild(); err != nil { |
| 253 | // Mid-cycle watch failure; force a full rebuild on the next event |
| 254 | w.wm.ForceOverflow() |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | func (w *Watcher) isRelevantChange(changedPaths map[string]fswatch.EventKind) bool { |
| 259 | caseSensitive := w.sys.FS().UseCaseSensitiveFileNames() |
nothing calls this directly
no test coverage detected