Skip to content

Commit 29ed2e0

Browse files
committed
Simplify
1 parent 581419f commit 29ed2e0

File tree

1 file changed

+7
-35
lines changed

1 file changed

+7
-35
lines changed

crates/ide/src/diagnostics.rs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -248,35 +248,7 @@ mod tests {
248248
/// * a diagnostic is produced
249249
/// * this diagnostic fix trigger range touches the input cursor position
250250
/// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied
251-
pub(super) fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
252-
let after = trim_indent(ra_fixture_after);
253-
254-
let (analysis, file_position) = fixture::position(ra_fixture_before);
255-
let diagnostic = analysis
256-
.diagnostics(&DiagnosticsConfig::default(), file_position.file_id)
257-
.unwrap()
258-
.pop()
259-
.unwrap();
260-
let mut fix = diagnostic.fix.unwrap();
261-
let edit = fix.source_change.source_file_edits.pop().unwrap().edit;
262-
let target_file_contents = analysis.file_text(file_position.file_id).unwrap();
263-
let actual = {
264-
let mut actual = target_file_contents.to_string();
265-
edit.apply(&mut actual);
266-
actual
267-
};
268-
269-
assert_eq_text!(&after, &actual);
270-
assert!(
271-
fix.fix_trigger_range.contains_inclusive(file_position.offset),
272-
"diagnostic fix range {:?} does not touch cursor position {:?}",
273-
fix.fix_trigger_range,
274-
file_position.offset
275-
);
276-
}
277-
278-
/// Similar to `check_fix`, but applies all the available fixes.
279-
fn check_fixes(ra_fixture_before: &str, ra_fixture_after: &str) {
251+
pub(crate) fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
280252
let after = trim_indent(ra_fixture_after);
281253

282254
let (analysis, file_position) = fixture::position(ra_fixture_before);
@@ -802,7 +774,7 @@ struct Foo {
802774

803775
#[test]
804776
fn test_rename_incorrect_case() {
805-
check_fixes(
777+
check_fix(
806778
r#"
807779
pub struct test_struct<|> { one: i32 }
808780
@@ -819,7 +791,7 @@ pub fn some_fn(val: TestStruct) -> TestStruct {
819791
"#,
820792
);
821793

822-
check_fixes(
794+
check_fix(
823795
r#"
824796
pub fn some_fn(NonSnakeCase<|>: u8) -> u8 {
825797
NonSnakeCase
@@ -832,7 +804,7 @@ pub fn some_fn(non_snake_case: u8) -> u8 {
832804
"#,
833805
);
834806

835-
check_fixes(
807+
check_fix(
836808
r#"
837809
pub fn SomeFn<|>(val: u8) -> u8 {
838810
if val != 0 { SomeFn(val - 1) } else { val }
@@ -845,7 +817,7 @@ pub fn some_fn(val: u8) -> u8 {
845817
"#,
846818
);
847819

848-
check_fixes(
820+
check_fix(
849821
r#"
850822
fn some_fn() {
851823
let whatAWeird_Formatting<|> = 10;
@@ -874,7 +846,7 @@ fn foo() {
874846

875847
#[test]
876848
fn test_rename_incorrect_case_struct_method() {
877-
check_fixes(
849+
check_fix(
878850
r#"
879851
pub struct TestStruct;
880852
@@ -906,6 +878,6 @@ impl TestStruct {
906878
analysis.diagnostics(&DiagnosticsConfig::default(), file_position.file_id).unwrap();
907879
assert_eq!(diagnostics.len(), 1);
908880

909-
check_fixes(input, expected);
881+
check_fix(input, expected);
910882
}
911883
}

0 commit comments

Comments
 (0)