sway/sway-lsp/tests/integration
Joshua Batty fd2b56d320
Refactor the server.rs module in the language server. (#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 #4672
2023-06-20 08:37:17 +10:00
..
code_actions.rs Refactor the server.rs module in the language server. (#4673) 2023-06-20 08:37:17 +10:00
lsp.rs Refactor the server.rs module in the language server. (#4673) 2023-06-20 08:37:17 +10:00
mod.rs Add code actions for struct and refactor (#4032) 2023-02-14 16:10:55 +11:00