aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/runnables.rs7
-rw-r--r--crates/ide_db/src/search.rs4
-rw-r--r--crates/rust-analyzer/src/handlers.rs4
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs9
4 files changed, 10 insertions, 14 deletions
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 7c92b7625..d8cf66168 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -5,7 +5,10 @@ use cfg::CfgExpr;
5use hir::{AsAssocItem, HasAttrs, HasSource, Semantics}; 5use hir::{AsAssocItem, HasAttrs, HasSource, Semantics};
6use ide_assists::utils::test_related_attribute; 6use ide_assists::utils::test_related_attribute;
7use ide_db::{ 7use ide_db::{
8 base_db::FilePosition, defs::Definition, search::SearchScope, RootDatabase, SymbolKind, 8 base_db::{FilePosition, FileRange},
9 defs::Definition,
10 search::SearchScope,
11 RootDatabase, SymbolKind,
9}; 12};
10use itertools::Itertools; 13use itertools::Itertools;
11use rustc_hash::FxHashSet; 14use rustc_hash::FxHashSet;
@@ -168,7 +171,7 @@ fn find_related_tests_in_module(
168 }; 171 };
169 172
170 let file_id = mod_source.file_id.original_file(sema.db); 173 let file_id = mod_source.file_id.original_file(sema.db);
171 let mod_scope = SearchScope::file_part(file_id, range); 174 let mod_scope = SearchScope::file_range(FileRange { file_id, range });
172 let fn_pos = FilePosition { file_id, offset: fn_name.syntax().text_range().start() }; 175 let fn_pos = FilePosition { file_id, offset: fn_name.syntax().text_range().start() };
173 find_related_tests(sema, fn_pos, Some(mod_scope), tests) 176 find_related_tests(sema, fn_pos, Some(mod_scope), tests)
174 } 177 }
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs
index 8b211256e..fa18703e1 100644
--- a/crates/ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
@@ -86,8 +86,8 @@ impl SearchScope {
86 SearchScope::new(std::iter::once((file, None)).collect()) 86 SearchScope::new(std::iter::once((file, None)).collect())
87 } 87 }
88 88
89 pub fn file_part(file: FileId, range: TextRange) -> SearchScope { 89 pub fn file_range(range: FileRange) -> SearchScope {
90 SearchScope::new(std::iter::once((file, Some(range))).collect()) 90 SearchScope::new(std::iter::once((range.file_id, Some(range.range))).collect())
91 } 91 }
92 92
93 pub fn files(files: &[FileId]) -> SearchScope { 93 pub fn files(files: &[FileId]) -> SearchScope {
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 53b0d3e41..ba8639e30 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -609,10 +609,10 @@ pub(crate) fn handle_runnables(
609 609
610pub(crate) fn handle_related_tests( 610pub(crate) fn handle_related_tests(
611 snap: GlobalStateSnapshot, 611 snap: GlobalStateSnapshot,
612 params: lsp_ext::RelatedTestsParams, 612 params: lsp_types::TextDocumentPositionParams,
613) -> Result<Vec<lsp_ext::TestInfo>> { 613) -> Result<Vec<lsp_ext::TestInfo>> {
614 let _p = profile::span("handle_related_tests"); 614 let _p = profile::span("handle_related_tests");
615 let position = from_proto::file_position(&snap, params.text_document_position)?; 615 let position = from_proto::file_position(&snap, params)?;
616 616
617 let tests = snap.analysis.related_tests(position, None)?; 617 let tests = snap.analysis.related_tests(position, None)?;
618 let mut res = Vec::new(); 618 let mut res = Vec::new();
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index fe11903f9..efcdcd1d9 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -180,18 +180,11 @@ pub struct CargoRunnable {
180pub enum RelatedTests {} 180pub enum RelatedTests {}
181 181
182impl Request for RelatedTests { 182impl Request for RelatedTests {
183 type Params = RelatedTestsParams; 183 type Params = lsp_types::TextDocumentPositionParams;
184 type Result = Vec<TestInfo>; 184 type Result = Vec<TestInfo>;
185 const METHOD: &'static str = "rust-analyzer/relatedTests"; 185 const METHOD: &'static str = "rust-analyzer/relatedTests";
186} 186}
187 187
188#[derive(Serialize, Deserialize, Debug)]
189#[serde(rename_all = "camelCase")]
190pub struct RelatedTestsParams {
191 #[serde(flatten)]
192 pub text_document_position: lsp_types::TextDocumentPositionParams,
193}
194
195#[derive(Debug, Deserialize, Serialize)] 188#[derive(Debug, Deserialize, Serialize)]
196pub struct TestInfo { 189pub struct TestInfo {
197 pub runnable: Runnable, 190 pub runnable: Runnable,