()
| 280 | } |
| 281 | |
| 282 | func (w *Watcher) doBuild() error { |
| 283 | if w.configModified { |
| 284 | w.sourceFileCache = &collections.SyncMap[tspath.Path, *cachedSourceFile]{} |
| 285 | } |
| 286 | |
| 287 | cached := cachedvfs.From(w.sys.FS()) |
| 288 | tfs := &trackingvfs.FS{Inner: cached} |
| 289 | innerHost := compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), tfs, w.sys.DefaultLibraryPath(), w.extendedConfigCache, getTraceFromSys(w.sys, w.config.Locale(), w.testing)) |
| 290 | host := &watchCompilerHost{CompilerHost: innerHost, cache: w.sourceFileCache} |
| 291 | |
| 292 | var wildcardDirs map[string]bool |
| 293 | if w.config.ConfigFile != nil { |
| 294 | wildcardDirs = w.config.WildcardDirectories() |
| 295 | for dir := range wildcardDirs { |
| 296 | tfs.SeenFiles.Add(dir) |
| 297 | } |
| 298 | if len(wildcardDirs) > 0 { |
| 299 | w.config = w.config.ReloadFileNamesOfParsedCommandLine(w.sys.FS()) |
| 300 | } |
| 301 | } |
| 302 | for _, path := range w.configFilePaths { |
| 303 | tfs.SeenFiles.Add(path) |
| 304 | } |
| 305 | |
| 306 | w.program = incremental.NewProgram(compiler.NewProgram(compiler.ProgramOptions{ |
| 307 | Config: w.config, |
| 308 | Host: host, |
| 309 | }), w.program, nil, w.testing != nil) |
| 310 | |
| 311 | result := w.compileAndEmit() |
| 312 | cached.DisableAndClearCache() |
| 313 | |
| 314 | caseSensitive := w.sys.FS().UseCaseSensitiveFileNames() |
| 315 | cwd := w.sys.GetCurrentDirectory() |
| 316 | seenSlice := tfs.SeenFiles.ToSlice() |
| 317 | w.seenFiles = collections.NewSetWithSizeHint[tspath.Path](len(seenSlice)) |
| 318 | for _, p := range seenSlice { |
| 319 | w.seenFiles.Add(tspath.ToPath(p, cwd, caseSensitive)) |
| 320 | } |
| 321 | |
| 322 | w.configMtimes = make(map[string]time.Time, len(w.configFilePaths)) |
| 323 | for _, cfgPath := range w.configFilePaths { |
| 324 | if s := w.sys.FS().Stat(cfgPath); s != nil { |
| 325 | w.configMtimes[cfgPath] = s.ModTime() |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | if err := w.reconcileWatches(seenSlice); err != nil { |
| 330 | fmt.Fprintf(w.sys.Writer(), "%v\n", err) |
| 331 | return err |
| 332 | } |
| 333 | w.configModified = false |
| 334 | |
| 335 | programFiles := w.program.GetProgram().FilesByPath() |
| 336 | w.sourceFileCache.Range(func(path tspath.Path, _ *cachedSourceFile) bool { |
| 337 | if _, ok := programFiles[path]; !ok { |
| 338 | w.sourceFileCache.Delete(path) |
| 339 | } |
no test coverage detected