-
-
Notifications
You must be signed in to change notification settings - Fork 763
refactor(language_server): Pass ToolBuilder reference to Tool trait methods #17361
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
- Updated Tool trait methods to accept `builder: &dyn ToolBuilder` parameter - Modified ServerFormatter and ServerLinter to use builder reference - Updated WorkspaceWorker to store builders and pass them to tools - Modified Backend to use Arc<Vec<Box<dyn ToolBuilder>>> - Updated all test code to work with new architecture - All tests passing Co-authored-by: Sysix <[email protected]>
Co-authored-by: Sysix <[email protected]>
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 Tool trait architecture to pass ToolBuilder references to handle_configuration_change and handle_watched_file_change methods, enabling builders to hold and reuse state across tool rebuilds.
Key Changes:
- Added
builder: &dyn ToolBuilderparameter toTooltrait methods - Updated all
Toolimplementations to usebuilder.build_boxed()instead of static builder method calls - Modified
WorkspaceWorkerto store builders alongside tools and pass appropriate builder references during tool operations
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_language_server/src/tool.rs |
Added builder parameter to handle_configuration_change and handle_watched_file_change trait methods |
crates/oxc_language_server/src/formatter/server_formatter.rs |
Updated ServerFormatter to use builder.build_boxed() instead of static ServerFormatterBuilder::build() calls |
crates/oxc_language_server/src/linter/server_linter.rs |
Updated ServerLinter to use builder.build_boxed() instead of static ServerLinterBuilder::build() calls |
crates/oxc_language_server/src/worker.rs |
Added builders: Arc<[Box<dyn ToolBuilder>]> field, updated constructor and start_worker() to use stored builders, modified handle_tool_changes() to pass builder references |
crates/oxc_language_server/src/backend.rs |
Wrapped tool_builders in Arc and updated all WorkspaceWorker instantiations to pass cloned Arc references |
crates/oxc_language_server/src/tests.rs |
Updated FakeTool implementation to use builder parameter in trait methods |
crates/oxc_language_server/src/formatter/tester.rs |
Updated test helper to instantiate builder and pass it to handle_configuration_change() |
crates/oxc_language_server/src/linter/tester.rs |
Updated test helper to instantiate builder and pass it to handle_configuration_change() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]> Signed-off-by: Alexander S. <[email protected]>
…om/oxc-project/oxc into copilot/refactor-tool-architecture
The current architecture requires
ServerFormatterandServerLinterto call static builder methods (ServerFormatterBuilder::build()) when rebuilding, preventing builders from holding and reusing state across rebuilds.Changes
Tool trait (
tool.rs)builder: &dyn ToolBuilderparameter tohandle_configuration_changeandhandle_watched_file_changeTool implementations (
server_formatter.rs,server_linter.rs)ServerFormatterBuilder::build()/ServerLinterBuilder::build()calls withbuilder.build_boxed()WorkspaceWorker (
worker.rs)Arc<Vec<Box<dyn ToolBuilder>>>alongside toolsstart_worker()uses stored buildershandle_configuration_changeandhandle_watched_file_changeBackend (
backend.rs)tool_buildersinArcfor shared ownership across workersWorkspaceWorkerinstantiations to pass builder ArcExample
Before:
After:
This enables
ToolBuilderimplementations to hold state without further API changes.Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.