diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 18 | ||||
-rw-r--r-- | crates/rust-analyzer/src/lsp_ext.rs | 20 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index f198b1f25..53b0d3e41 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -607,6 +607,24 @@ pub(crate) fn handle_runnables( | |||
607 | Ok(res) | 607 | Ok(res) |
608 | } | 608 | } |
609 | 609 | ||
610 | pub(crate) fn handle_related_tests( | ||
611 | snap: GlobalStateSnapshot, | ||
612 | params: lsp_ext::RelatedTestsParams, | ||
613 | ) -> Result<Vec<lsp_ext::TestInfo>> { | ||
614 | let _p = profile::span("handle_related_tests"); | ||
615 | let position = from_proto::file_position(&snap, params.text_document_position)?; | ||
616 | |||
617 | let tests = snap.analysis.related_tests(position, None)?; | ||
618 | let mut res = Vec::new(); | ||
619 | for it in tests { | ||
620 | if let Ok(runnable) = to_proto::runnable(&snap, it) { | ||
621 | res.push(lsp_ext::TestInfo { runnable }) | ||
622 | } | ||
623 | } | ||
624 | |||
625 | Ok(res) | ||
626 | } | ||
627 | |||
610 | pub(crate) fn handle_completion( | 628 | pub(crate) fn handle_completion( |
611 | snap: GlobalStateSnapshot, | 629 | snap: GlobalStateSnapshot, |
612 | params: lsp_types::CompletionParams, | 630 | params: lsp_types::CompletionParams, |
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 0d2c8f7ff..fe11903f9 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs | |||
@@ -177,6 +177,26 @@ pub struct CargoRunnable { | |||
177 | pub expect_test: Option<bool>, | 177 | pub expect_test: Option<bool>, |
178 | } | 178 | } |
179 | 179 | ||
180 | pub enum RelatedTests {} | ||
181 | |||
182 | impl Request for RelatedTests { | ||
183 | type Params = RelatedTestsParams; | ||
184 | type Result = Vec<TestInfo>; | ||
185 | const METHOD: &'static str = "rust-analyzer/relatedTests"; | ||
186 | } | ||
187 | |||
188 | #[derive(Serialize, Deserialize, Debug)] | ||
189 | #[serde(rename_all = "camelCase")] | ||
190 | pub struct RelatedTestsParams { | ||
191 | #[serde(flatten)] | ||
192 | pub text_document_position: lsp_types::TextDocumentPositionParams, | ||
193 | } | ||
194 | |||
195 | #[derive(Debug, Deserialize, Serialize)] | ||
196 | pub struct TestInfo { | ||
197 | pub runnable: Runnable, | ||
198 | } | ||
199 | |||
180 | pub enum InlayHints {} | 200 | pub enum InlayHints {} |
181 | 201 | ||
182 | impl Request for InlayHints { | 202 | impl Request for InlayHints { |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 2829d5970..9f86b8c0d 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -500,6 +500,7 @@ impl GlobalState { | |||
500 | .on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro) | 500 | .on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro) |
501 | .on::<lsp_ext::ParentModule>(handlers::handle_parent_module) | 501 | .on::<lsp_ext::ParentModule>(handlers::handle_parent_module) |
502 | .on::<lsp_ext::Runnables>(handlers::handle_runnables) | 502 | .on::<lsp_ext::Runnables>(handlers::handle_runnables) |
503 | .on::<lsp_ext::RelatedTests>(handlers::handle_related_tests) | ||
503 | .on::<lsp_ext::InlayHints>(handlers::handle_inlay_hints) | 504 | .on::<lsp_ext::InlayHints>(handlers::handle_inlay_hints) |
504 | .on::<lsp_ext::CodeActionRequest>(handlers::handle_code_action) | 505 | .on::<lsp_ext::CodeActionRequest>(handlers::handle_code_action) |
505 | .on::<lsp_ext::CodeActionResolveRequest>(handlers::handle_code_action_resolve) | 506 | .on::<lsp_ext::CodeActionResolveRequest>(handlers::handle_code_action_resolve) |