-
-
Notifications
You must be signed in to change notification settings - Fork 722
refactor(language_server): move Diagnostics-map to WorkspaceWorker
#14830
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
refactor(language_server): move Diagnostics-map to WorkspaceWorker
#14830
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
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 the diagnostic management in the language server by moving the Diagnostics map from ServerLinter to WorkspaceWorker. This change centralizes diagnostic storage at the workspace level and removes async requirements from several diagnostic-related methods.
Key Changes:
- Introduced
WorkerDiagnosticsstruct to manage diagnostic maps at the workspace level - Removed
ServerLinterDiagnosticsfromServerLinterand associated diagnostic management methods - Converted async diagnostic methods to synchronous ones where possible
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_language_server/src/worker.rs | Added WorkerDiagnostics struct and integrated it into WorkspaceWorker; moved diagnostic management methods from ServerLinter; converted several async methods to sync |
| crates/oxc_language_server/src/linter/server_linter.rs | Removed ServerLinterDiagnostics struct and its methods; updated run_single and revalidate_diagnostics to accept WorkerDiagnostics parameter; moved test case to worker.rs |
| crates/oxc_language_server/src/backend.rs | Updated method calls to use synchronous versions of get_clear_diagnostics and remove_diagnostics |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| let mut files = Vec::with_capacity(isolated_files.len() + tsgo_files.len()); | ||
| files.extend(isolated_files); | ||
| files.extend(tsgo_files); |
Copilot
AI
Oct 20, 2025
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 dedup() method only removes consecutive duplicates from a sorted vector. If a file exists in both isolated_files and tsgo_files but they are not adjacent after extending, duplicates will remain. Consider sorting before calling dedup(), or use a HashSet to ensure all duplicates are removed: files.sort(); files.dedup();
| files.extend(tsgo_files); | |
| files.extend(tsgo_files); | |
| files.sort(); |
| if let Some(linter_files) = linter_files { | ||
| diagnostics = Some(self.revalidate_diagnostics(linter_files).await); | ||
| } | ||
| diagnostics = Some(self.revalidate_diagnostics(linter_files).await); |
Copilot
AI
Oct 20, 2025
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 conditional check if let Some(linter_files) = linter_files was removed, but linter_files is now a Vec<Uri> that is always returned (never Option). This changes the behavior: when the linter was previously None, no revalidation occurred. Now get_cached_files_of_diagnostics() returns an empty vector, and revalidate_diagnostics is called with that empty vector. While functionally similar, this adds an unnecessary function call. Consider adding back a check: if !linter_files.is_empty() { diagnostics = Some(self.revalidate_diagnostics(linter_files).await); }
| diagnostics = Some(self.revalidate_diagnostics(linter_files).await); | |
| if !linter_files.is_empty() { | |
| diagnostics = Some(self.revalidate_diagnostics(linter_files).await); | |
| } |
|
This is the wrong approach, you can open files while no new diagnostics are added/removed. |

No description provided.