From f8f454ab5c19c6e7d91b3a4e6bb63fb9bf5f2673 Mon Sep 17 00:00:00 2001 From: Mikhail Modin Date: Mon, 10 Feb 2020 22:45:38 +0000 Subject: Init implementation of structural search replace --- crates/ra_lsp_server/src/main_loop.rs | 1 + crates/ra_lsp_server/src/main_loop/handlers.rs | 5 +++++ crates/ra_lsp_server/src/req.rs | 13 +++++++++++++ 3 files changed, 19 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index ceff82fda..061383e28 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -526,6 +526,7 @@ fn on_request( .on::(handlers::handle_call_hierarchy_prepare)? .on::(handlers::handle_call_hierarchy_incoming)? .on::(handlers::handle_call_hierarchy_outgoing)? + .on::(handlers::handle_ssr)? .finish(); Ok(()) } diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 2e598fdcd..72bb48619 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -881,6 +881,11 @@ pub fn handle_document_highlight( )) } +pub fn handle_ssr(world: WorldSnapshot, params: req::SsrParams) -> Result { + let _p = profile("handle_ssr"); + world.analysis().structural_search_replace(¶ms.arg)??.try_conv_with(&world) +} + pub fn publish_diagnostics(world: &WorldSnapshot, file_id: FileId) -> Result { let _p = profile("publish_diagnostics"); let line_index = world.analysis().file_line_index(file_id)?; diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index dc327f53d..7ff7f60b3 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -206,3 +206,16 @@ pub struct InlayHint { pub kind: InlayKind, pub label: String, } + +pub enum Ssr {} + +impl Request for Ssr { + type Params = SsrParams; + type Result = SourceChange; + const METHOD: &'static str = "rust-analyzer/ssr"; +} + +#[derive(Debug, Deserialize, Serialize)] +pub struct SsrParams { + pub arg: String, +} -- cgit v1.2.3