Move check_expect and check_expect_clear_loc to inlayhints::chaining
This commit is contained in:
parent
594e0a5de6
commit
61b552124a
@ -593,7 +593,6 @@ mod tests {
|
|||||||
use hir::ClosureStyle;
|
use hir::ClosureStyle;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use test_utils::extract_annotations;
|
use test_utils::extract_annotations;
|
||||||
use text_edit::{TextRange, TextSize};
|
|
||||||
|
|
||||||
use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
|
use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
|
||||||
use crate::DiscriminantHints;
|
use crate::DiscriminantHints;
|
||||||
@ -654,33 +653,6 @@ mod tests {
|
|||||||
assert_eq!(expected, actual, "\nExpected:\n{expected:#?}\n\nActual:\n{actual:#?}");
|
assert_eq!(expected, actual, "\nExpected:\n{expected:#?}\n\nActual:\n{actual:#?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
|
||||||
pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
|
|
||||||
let (analysis, file_id) = fixture::file(ra_fixture);
|
|
||||||
let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
|
|
||||||
let filtered =
|
|
||||||
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
|
|
||||||
expect.assert_debug_eq(&filtered)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[track_caller]
|
|
||||||
pub(super) fn check_expect_clear_loc(
|
|
||||||
config: InlayHintsConfig,
|
|
||||||
ra_fixture: &str,
|
|
||||||
expect: Expect,
|
|
||||||
) {
|
|
||||||
let (analysis, file_id) = fixture::file(ra_fixture);
|
|
||||||
let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
|
|
||||||
inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
|
|
||||||
if let Some(loc) = &mut hint.linked_location {
|
|
||||||
loc.range = TextRange::empty(TextSize::from(0));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let filtered =
|
|
||||||
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
|
|
||||||
expect.assert_debug_eq(&filtered)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
|
/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
|
||||||
/// expect test.
|
/// expect test.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -75,12 +75,12 @@ pub(super) fn hints(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::expect;
|
use expect_test::{expect, Expect};
|
||||||
|
use text_edit::{TextRange, TextSize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
inlay_hints::tests::{
|
fixture,
|
||||||
check_expect, check_expect_clear_loc, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
|
inlay_hints::tests::{check_with_config, DISABLED_CONFIG, TEST_CONFIG},
|
||||||
},
|
|
||||||
InlayHintsConfig,
|
InlayHintsConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,6 +89,33 @@ mod tests {
|
|||||||
check_with_config(InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG }, ra_fixture);
|
check_with_config(InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG }, ra_fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
|
pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
|
||||||
|
let (analysis, file_id) = fixture::file(ra_fixture);
|
||||||
|
let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
|
||||||
|
let filtered =
|
||||||
|
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
|
||||||
|
expect.assert_debug_eq(&filtered)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
|
pub(super) fn check_expect_clear_loc(
|
||||||
|
config: InlayHintsConfig,
|
||||||
|
ra_fixture: &str,
|
||||||
|
expect: Expect,
|
||||||
|
) {
|
||||||
|
let (analysis, file_id) = fixture::file(ra_fixture);
|
||||||
|
let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
|
||||||
|
inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
|
||||||
|
if let Some(loc) = &mut hint.linked_location {
|
||||||
|
loc.range = TextRange::empty(TextSize::from(0));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let filtered =
|
||||||
|
inlay_hints.into_iter().map(|hint| (hint.range, hint.label)).collect::<Vec<_>>();
|
||||||
|
expect.assert_debug_eq(&filtered)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn chaining_hints_ignore_comments() {
|
fn chaining_hints_ignore_comments() {
|
||||||
check_expect(
|
check_expect(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user