Skip to content

Commit 7d57d9a

Browse files
committed
minor: Reduce friction for updating minicore
1 parent 2025b43 commit 7d57d9a

File tree

1 file changed

+55
-29
lines changed

1 file changed

+55
-29
lines changed

crates/ide/src/hover/tests.rs

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,26 @@ fn check_hover_no_markdown(ra_fixture: &str, expect: Expect) {
182182

183183
fn check_actions(ra_fixture: &str, expect: Expect) {
184184
let (analysis, file_id, position) = fixture::range_or_position(ra_fixture);
185-
let hover = analysis
185+
let mut hover = analysis
186186
.hover(
187187
&HoverConfig { links_in_hover: true, ..HOVER_BASE_CONFIG },
188188
FileRange { file_id, range: position.range_or_empty() },
189189
)
190190
.unwrap()
191191
.unwrap();
192+
// stub out ranges into minicore as they can change every now and then
193+
hover.info.actions.iter_mut().for_each(|action| match action {
194+
super::HoverAction::GoToType(act) => act.iter_mut().for_each(|data| {
195+
if data.nav.file_id == file_id {
196+
return;
197+
}
198+
data.nav.full_range = TextRange::empty(span::TextSize::new(!0));
199+
if let Some(range) = &mut data.nav.focus_range {
200+
*range = TextRange::empty(span::TextSize::new(!0));
201+
}
202+
}),
203+
_ => (),
204+
});
192205
expect.assert_debug_eq(&hover.info.actions)
193206
}
194207

@@ -200,10 +213,23 @@ fn check_hover_range(ra_fixture: &str, expect: Expect) {
200213

201214
fn check_hover_range_actions(ra_fixture: &str, expect: Expect) {
202215
let (analysis, range) = fixture::range(ra_fixture);
203-
let hover = analysis
216+
let mut hover = analysis
204217
.hover(&HoverConfig { links_in_hover: true, ..HOVER_BASE_CONFIG }, range)
205218
.unwrap()
206219
.unwrap();
220+
// stub out ranges into minicore as they can change every now and then
221+
hover.info.actions.iter_mut().for_each(|action| match action {
222+
super::HoverAction::GoToType(act) => act.iter_mut().for_each(|data| {
223+
if data.nav.file_id == range.file_id {
224+
return;
225+
}
226+
data.nav.full_range = TextRange::empty(span::TextSize::new(!0));
227+
if let Some(range) = &mut data.nav.focus_range {
228+
*range = TextRange::empty(span::TextSize::new(!0));
229+
}
230+
}),
231+
_ => (),
232+
});
207233
expect.assert_debug_eq(&hover.info.actions);
208234
}
209235

@@ -483,8 +509,8 @@ fn main() {
483509
file_id: FileId(
484510
1,
485511
),
486-
full_range: 632..867,
487-
focus_range: 693..699,
512+
full_range: 4294967295..4294967295,
513+
focus_range: 4294967295..4294967295,
488514
name: "FnOnce",
489515
kind: Trait,
490516
container_name: "function",
@@ -3104,26 +3130,26 @@ struct S{ f1: u32 }
31043130
fn main() { let s$0t = S{ f1:0 }; }
31053131
"#,
31063132
expect![[r#"
3107-
[
3108-
GoToType(
3109-
[
3110-
HoverGotoTypeData {
3111-
mod_path: "test::S",
3112-
nav: NavigationTarget {
3113-
file_id: FileId(
3114-
0,
3115-
),
3116-
full_range: 0..19,
3117-
focus_range: 7..8,
3118-
name: "S",
3119-
kind: Struct,
3120-
description: "struct S",
3121-
},
3133+
[
3134+
GoToType(
3135+
[
3136+
HoverGotoTypeData {
3137+
mod_path: "test::S",
3138+
nav: NavigationTarget {
3139+
file_id: FileId(
3140+
0,
3141+
),
3142+
full_range: 0..19,
3143+
focus_range: 7..8,
3144+
name: "S",
3145+
kind: Struct,
3146+
description: "struct S",
31223147
},
3123-
],
3124-
),
3125-
]
3126-
"#]],
3148+
},
3149+
],
3150+
),
3151+
]
3152+
"#]],
31273153
);
31283154
}
31293155

@@ -3616,8 +3642,8 @@ pub mod future {
36163642
file_id: FileId(
36173643
1,
36183644
),
3619-
full_range: 21..69,
3620-
focus_range: 60..66,
3645+
full_range: 4294967295..4294967295,
3646+
focus_range: 4294967295..4294967295,
36213647
name: "Future",
36223648
kind: Trait,
36233649
container_name: "future",
@@ -8465,8 +8491,8 @@ impl Iterator for S {
84658491
file_id: FileId(
84668492
1,
84678493
),
8468-
full_range: 7800..8008,
8469-
focus_range: 7865..7871,
8494+
full_range: 4294967295..4294967295,
8495+
focus_range: 4294967295..4294967295,
84708496
name: "Future",
84718497
kind: Trait,
84728498
container_name: "future",
@@ -8479,8 +8505,8 @@ impl Iterator for S {
84798505
file_id: FileId(
84808506
1,
84818507
),
8482-
full_range: 8638..9104,
8483-
focus_range: 8682..8690,
8508+
full_range: 4294967295..4294967295,
8509+
focus_range: 4294967295..4294967295,
84848510
name: "Iterator",
84858511
kind: Trait,
84868512
container_name: "iterator",

0 commit comments

Comments
 (0)