Skip to content

Commit 61b5521

Browse files
committed
Move check_expect and check_expect_clear_loc to inlayhints::chaining
1 parent 594e0a5 commit 61b5521

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

crates/ide/src/inlay_hints.rs

-28
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ mod tests {
593593
use hir::ClosureStyle;
594594
use itertools::Itertools;
595595
use test_utils::extract_annotations;
596-
use text_edit::{TextRange, TextSize};
597596

598597
use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
599598
use crate::DiscriminantHints;
@@ -654,33 +653,6 @@ mod tests {
654653
assert_eq!(expected, actual, "\nExpected:\n{expected:#?}\n\nActual:\n{actual:#?}");
655654
}
656655

657-
#[track_caller]
658-
pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
659-
let (analysis, file_id) = fixture::file(ra_fixture);
660-
let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
661-
let filtered =
662-
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
663-
expect.assert_debug_eq(&filtered)
664-
}
665-
666-
#[track_caller]
667-
pub(super) fn check_expect_clear_loc(
668-
config: InlayHintsConfig,
669-
ra_fixture: &str,
670-
expect: Expect,
671-
) {
672-
let (analysis, file_id) = fixture::file(ra_fixture);
673-
let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
674-
inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
675-
if let Some(loc) = &mut hint.linked_location {
676-
loc.range = TextRange::empty(TextSize::from(0));
677-
}
678-
});
679-
let filtered =
680-
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
681-
expect.assert_debug_eq(&filtered)
682-
}
683-
684656
/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
685657
/// expect test.
686658
#[track_caller]

crates/ide/src/inlay_hints/chaining.rs

+31-4
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ pub(super) fn hints(
7575

7676
#[cfg(test)]
7777
mod tests {
78-
use expect_test::expect;
78+
use expect_test::{expect, Expect};
79+
use text_edit::{TextRange, TextSize};
7980

8081
use crate::{
81-
inlay_hints::tests::{
82-
check_expect, check_expect_clear_loc, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
83-
},
82+
fixture,
83+
inlay_hints::tests::{check_with_config, DISABLED_CONFIG, TEST_CONFIG},
8484
InlayHintsConfig,
8585
};
8686

@@ -89,6 +89,33 @@ mod tests {
8989
check_with_config(InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG }, ra_fixture);
9090
}
9191

92+
#[track_caller]
93+
pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
94+
let (analysis, file_id) = fixture::file(ra_fixture);
95+
let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
96+
let filtered =
97+
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
98+
expect.assert_debug_eq(&filtered)
99+
}
100+
101+
#[track_caller]
102+
pub(super) fn check_expect_clear_loc(
103+
config: InlayHintsConfig,
104+
ra_fixture: &str,
105+
expect: Expect,
106+
) {
107+
let (analysis, file_id) = fixture::file(ra_fixture);
108+
let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
109+
inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
110+
if let Some(loc) = &mut hint.linked_location {
111+
loc.range = TextRange::empty(TextSize::from(0));
112+
}
113+
});
114+
let filtered =
115+
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
116+
expect.assert_debug_eq(&filtered)
117+
}
118+
92119
#[test]
93120
fn chaining_hints_ignore_comments() {
94121
check_expect(

0 commit comments

Comments
 (0)