Skip to content

Comments

refactor(language_server): move restart to Tool::handle_watched_file_change trait method#15491

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-08-feat_language_server_handle_new_watch_patterns_when_watched_file_is_changed
Nov 9, 2025
Merged

refactor(language_server): move restart to Tool::handle_watched_file_change trait method#15491
graphite-app[bot] merged 1 commit intomainfrom
11-08-feat_language_server_handle_new_watch_patterns_when_watched_file_is_changed

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Nov 8, 2025

Returning ToolRestartChanges like handle_configuration_change does.
The logic in WorkspaceWorker/Backend can be shared later for simplified usage.

@github-actions github-actions bot added the A-editor Area - Editor and Language Server label Nov 8, 2025
Copy link
Member Author

Sysix commented Nov 8, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Nov 8, 2025
@Sysix Sysix changed the base branch from 11-08-refactor_language_server_move_get_code_actions_or_commands_to_tool_trait to graphite-base/15491 November 8, 2025 15:30
@Sysix Sysix force-pushed the 11-08-feat_language_server_handle_new_watch_patterns_when_watched_file_is_changed branch from 5e56e20 to 753e9df Compare November 8, 2025 15:41
@Sysix Sysix force-pushed the graphite-base/15491 branch from 7f95bba to 79e6842 Compare November 8, 2025 15:41
@Sysix Sysix changed the base branch from graphite-base/15491 to main November 8, 2025 15:41
@Sysix Sysix force-pushed the 11-08-feat_language_server_handle_new_watch_patterns_when_watched_file_is_changed branch from 753e9df to cc637a8 Compare November 8, 2025 16:39
@Sysix Sysix changed the title feat(language_server): handle new watch patterns when watched file is changed refactor(language_server): move restart to Tool::handle_watched_file_change trait method Nov 8, 2025
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Nov 8, 2025
@Sysix Sysix requested a review from Copilot November 8, 2025 16:43
@Sysix Sysix removed the C-enhancement Category - New feature or request label Nov 8, 2025
Copy link
Contributor

Copilot AI left a 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 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_change method to the Tool trait, allowing tools to handle file change events and return necessary updates
  • Removed three helper methods from WorkspaceWorker (refresh_server_linter, refresh_server_formatter, and revalidate_diagnostics) by delegating this logic to the tools themselves
  • Updated did_change_watched_files to return registration/unregistration information alongside diagnostics, matching the pattern used in did_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.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Nov 9, 2025
Copy link
Contributor

camc314 commented Nov 9, 2025

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.
@graphite-app graphite-app bot force-pushed the 11-08-feat_language_server_handle_new_watch_patterns_when_watched_file_is_changed branch from b39159b to a2f2805 Compare November 9, 2025 00:21
@graphite-app graphite-app bot merged commit a2f2805 into main Nov 9, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 11-08-feat_language_server_handle_new_watch_patterns_when_watched_file_is_changed branch November 9, 2025 00:26
Copilot AI pushed a commit that referenced this pull request Nov 9, 2025
…_change` trait method (#15491)

Returning `ToolRestartChanges` like `handle_configuration_change` does.
The logic in `WorkspaceWorker/Backend` can be shared later for simplified usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-editor Area - Editor and Language Server C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants