Skip to content

Commit daa2637

Browse files
committed
Apply review suggestions
1 parent f234b80 commit daa2637

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

crates/ide/src/runnables.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use cfg::CfgExpr;
55
use hir::{AsAssocItem, HasAttrs, HasSource, Semantics};
66
use ide_assists::utils::test_related_attribute;
77
use 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,
912
};
1013
use itertools::Itertools;
1114
use rustc_hash::FxHashSet;
@@ -168,7 +171,7 @@ fn find_related_tests_in_module(
168171
};
169172

170173
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 });
172175
let fn_pos = FilePosition { file_id, offset: fn_name.syntax().text_range().start() };
173176
find_related_tests(sema, fn_pos, Some(mod_scope), tests)
174177
}

crates/ide_db/src/search.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl SearchScope {
8686
SearchScope::new(std::iter::once((file, None)).collect())
8787
}
8888

89-
pub fn file_part(file: FileId, range: TextRange) -> SearchScope {
90-
SearchScope::new(std::iter::once((file, Some(range))).collect())
89+
pub fn file_range(range: FileRange) -> SearchScope {
90+
SearchScope::new(std::iter::once((range.file_id, Some(range.range))).collect())
9191
}
9292

9393
pub fn files(files: &[FileId]) -> SearchScope {

crates/rust-analyzer/src/handlers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ pub(crate) fn handle_runnables(
609609

610610
pub(crate) fn handle_related_tests(
611611
snap: GlobalStateSnapshot,
612-
params: lsp_ext::RelatedTestsParams,
612+
params: lsp_types::TextDocumentPositionParams,
613613
) -> Result<Vec<lsp_ext::TestInfo>> {
614614
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)?;
616616

617617
let tests = snap.analysis.related_tests(position, None)?;
618618
let mut res = Vec::new();

crates/rust-analyzer/src/lsp_ext.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,11 @@ pub struct CargoRunnable {
180180
pub enum RelatedTests {}
181181

182182
impl Request for RelatedTests {
183-
type Params = RelatedTestsParams;
183+
type Params = lsp_types::TextDocumentPositionParams;
184184
type Result = Vec<TestInfo>;
185185
const METHOD: &'static str = "rust-analyzer/relatedTests";
186186
}
187187

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-
195188
#[derive(Debug, Deserialize, Serialize)]
196189
pub struct TestInfo {
197190
pub runnable: Runnable,

editors/code/src/lsp_ext.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,11 @@ export interface Runnable {
7272
}
7373
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("experimental/runnables");
7474

75-
export interface RelatedTestsParams extends lc.TextDocumentPositionParams {
76-
}
77-
7875
export interface TestInfo {
7976
runnable: Runnable;
8077
}
8178

82-
export const relatedTests = new lc.RequestType<RelatedTestsParams, TestInfo[], void>("rust-analyzer/relatedTests");
79+
export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>("rust-analyzer/relatedTests");
8380

8481
export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;
8582

0 commit comments

Comments
 (0)