Skip to content

Commit 1e30cc0

Browse files
committed
minor: Reduce friction for updating minicore
1 parent 8d1d5cd commit 1e30cc0

File tree

1 file changed

+58
-27
lines changed

1 file changed

+58
-27
lines changed

crates/ide/src/hover/tests.rs

Lines changed: 58 additions & 27 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,13 @@ fn main() {
483509
file_id: FileId(
484510
1,
485511
),
512+
<<<<<<< HEAD
486513
full_range: 633..868,
487514
focus_range: 694..700,
515+
=======
516+
full_range: 4294967295..4294967295,
517+
focus_range: 4294967295..4294967295,
518+
>>>>>>> 33e4a08d5b (minor: Reduce friction for updating minicore)
488519
name: "FnOnce",
489520
kind: Trait,
490521
container_name: "function",
@@ -3104,26 +3135,26 @@ struct S{ f1: u32 }
31043135
fn main() { let s$0t = S{ f1:0 }; }
31053136
"#,
31063137
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-
},
3138+
[
3139+
GoToType(
3140+
[
3141+
HoverGotoTypeData {
3142+
mod_path: "test::S",
3143+
nav: NavigationTarget {
3144+
file_id: FileId(
3145+
0,
3146+
),
3147+
full_range: 0..19,
3148+
focus_range: 7..8,
3149+
name: "S",
3150+
kind: Struct,
3151+
description: "struct S",
31223152
},
3123-
],
3124-
),
3125-
]
3126-
"#]],
3153+
},
3154+
],
3155+
),
3156+
]
3157+
"#]],
31273158
);
31283159
}
31293160

@@ -3616,8 +3647,8 @@ pub mod future {
36163647
file_id: FileId(
36173648
1,
36183649
),
3619-
full_range: 21..69,
3620-
focus_range: 60..66,
3650+
full_range: 4294967295..4294967295,
3651+
focus_range: 4294967295..4294967295,
36213652
name: "Future",
36223653
kind: Trait,
36233654
container_name: "future",
@@ -8479,8 +8510,8 @@ impl Iterator for S {
84798510
file_id: FileId(
84808511
1,
84818512
),
8482-
full_range: 7802..8044,
8483-
focus_range: 7867..7873,
8513+
full_range: 4294967295..4294967295,
8514+
focus_range: 4294967295..4294967295,
84848515
name: "Future",
84858516
kind: Trait,
84868517
container_name: "future",
@@ -8493,8 +8524,8 @@ impl Iterator for S {
84938524
file_id: FileId(
84948525
1,
84958526
),
8496-
full_range: 8674..9173,
8497-
focus_range: 8751..8759,
8527+
full_range: 4294967295..4294967295,
8528+
focus_range: 4294967295..4294967295,
84988529
name: "Iterator",
84998530
kind: Trait,
85008531
container_name: "iterator",

0 commit comments

Comments
 (0)