Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the
server.rs
module in the language server. (FuelLabs#4673)
## Description This PR refactors most of the code that was in `server.rs`. Specifically, the call backs have been moved to `handlers/notification.rs` and `handlers/request.rs`. This was inspired by `rust-analyzer`s approach. the `server.rs` module now looks like: ```rust #[tower_lsp::async_trait] impl LanguageServer for ServerState { async fn initialize(&self, params: InitializeParams) -> Result<InitializeResult> { request::handle_initialize(self, params) } async fn shutdown(&self) -> Result<()> { self.shutdown_server() } async fn did_open(&self, params: DidOpenTextDocumentParams) { notification::handle_did_open_text_document(self, params).await; } async fn did_change(&self, params: DidChangeTextDocumentParams) { notification::handle_did_change_text_document(self, params).await; } async fn did_save(&self, params: DidSaveTextDocumentParams) { notification::handle_did_save_text_document(self, params).await; } async fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) { notification::handle_did_change_watched_files(self, params).await; } async fn hover(&self, params: HoverParams) -> Result<Option<Hover>> { request::handle_hover(self, params) } async fn code_action(&self, params: CodeActionParams) -> Result<Option<CodeActionResponse>> { request::handle_code_action(self, params) } async fn code_lens(&self, params: CodeLensParams) -> Result<Option<Vec<CodeLens>>> { request::handle_code_lens(self, params) } etc ... } ``` A new type called `ServerState` now holds the config, keyword docs, client and the map of sessions. No new functionality has been added apart from refactoring the code. This is needed for the new event loop, I decided to separate that into a follow up PR to make things a bit more manageable. closes FuelLabs#4672
- Loading branch information