-
Notifications
You must be signed in to change notification settings - Fork 649
Watch type refs and instead of watching directly use go routine #1217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors module resolution watching by extracting lookup-glob generation into standalone functions, introduces concurrency-safe watcher updates with sync.RWMutex
, and runs watcher updates and typing-location watches in goroutines.
- Introduced
getModuleResolutionWatchGlobs
and genericextractLookups
inwatch.go
- Added
watchMu sync.RWMutex
to guard watcher updates inproject.go
and madeupdateWatchers
asynchronous - Spawned goroutines for
updateWatchers
andWatchTypingLocations
to decouple from the main update loop
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
internal/project/watch.go | New helper functions to gather module-resolution watch patterns |
internal/project/project.go | Added watchMu , updated updateWatchers signature and concurrency, adjusted locks in WatchTypingLocations and event handler |
internal/project/ata.go | Changed discoverAndInstallTypings to invoke WatchTypingLocations asynchronously |
internal/module/types.go | Added GetLookupLocations methods to resolved-module types |
internal/compiler/program.go | Exposed GetResolvedTypeReferenceDirectives on Program |
internal/compiler/parsetask.go | Added flag for automatic-type parsing in parseTask |
internal/compiler/fileloader.go | Integrated automatic-type-directive tasks into parsing workflow |
Comments suppressed due to low confidence (3)
internal/project/project.go:354
- [nitpick] The parameter name
program
shadowsp.program
; consider renaming it (e.g.,prog
) to reduce confusion.
func (p *Project) updateWatchers(ctx context.Context, program *compiler.Program) {
internal/project/watch.go:368
- These new functions (
getModuleResolutionWatchGlobs
andextractLookups
) introduce nontrivial logic; consider adding unit tests to verify correct extraction of lookup globs.
func getModuleResolutionWatchGlobs(program *compiler.Program) (failedLookups map[tspath.Path]string, affectingLocaions map[tspath.Path]string) {
internal/project/project.go:170
- The code introduces
sync.RWMutex
but there is nosync
import; addimport "sync"
to avoid a compile error.
watchMu sync.RWMutex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file loader code seems correct to me, though I am unsure about the concurrency stuff in the Project given our ongoing logical races.
I assume no tests change with the loader change since the main effect here is to actually keep track of these files for watching?
No description provided.