MCPcopy Create free account
hub / github.com/microsoft/typescript-go / DoCycle

Method DoCycle

internal/execute/watcher.go:213–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

211}
212
213func (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
258func (w *Watcher) isRelevantChange(changedPaths map[string]fswatch.EventKind) bool {
259 caseSensitive := w.sys.FS().UseCaseSensitiveFileNames()

Callers

nothing calls this directly

Calls 11

recheckTsConfigMethod · 0.95
isRelevantChangeMethod · 0.95
doBuildMethod · 0.95
NewCompilerDiagnosticFunction · 0.92
lenFunction · 0.85
DrainEventsMethod · 0.80
ForceOverflowMethod · 0.80
OnProgramMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected