refactor(language_server): move restart to Tool::handle_watched_file_change trait method#15491
Conversation
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. |
5e56e20 to
753e9df
Compare
7f95bba to
79e6842
Compare
753e9df to
cc637a8
Compare
Tool::handle_watched_file_change trait method
There was a problem hiding this comment.
Pull Request Overview
This PR refactors file watching change handling to improve the architecture by introducing a new handle_watched_file_change method on the Tool trait. The refactoring allows tools (linter and formatter) to handle watched file changes directly and report back what needs to be updated.
Key Changes:
- Added
handle_watched_file_changemethod to theTooltrait, allowing tools to handle file change events and return necessary updates - Removed three helper methods from
WorkspaceWorker(refresh_server_linter,refresh_server_formatter, andrevalidate_diagnostics) by delegating this logic to the tools themselves - Updated
did_change_watched_filesto return registration/unregistration information alongside diagnostics, matching the pattern used indid_change_configuration
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_language_server/src/worker.rs | Removed helper methods and refactored did_change_watched_files to delegate to tools and handle dynamic watcher registration/unregistration |
| crates/oxc_language_server/src/tool.rs | Added handle_watched_file_change trait method for tools to process file change events |
| crates/oxc_language_server/src/linter/server_linter.rs | Implemented handle_watched_file_change for ServerLinter and changed revalidate_diagnostics visibility to private |
| crates/oxc_language_server/src/formatter/server_formatter.rs | Implemented handle_watched_file_change for ServerFormatter and moved early return check before options parsing |
| crates/oxc_language_server/src/backend.rs | Updated to handle registration/unregistration responses from did_change_watched_files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cc637a8 to
b39159b
Compare
Merge activity
|
…_change` trait method (#15491) Returning `ToolRestartChanges` like `handle_configuration_change` does. The logic in `WorkspaceWorker/Backend` can be shared later for simplified usage.
b39159b to
a2f2805
Compare
…_change` trait method (#15491) Returning `ToolRestartChanges` like `handle_configuration_change` does. The logic in `WorkspaceWorker/Backend` can be shared later for simplified usage.

Returning
ToolRestartChangeslikehandle_configuration_changedoes.The logic in
WorkspaceWorker/Backendcan be shared later for simplified usage.