aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/diagnostics.rs')
-rw-r--r--crates/ra_ide/src/diagnostics.rs40
1 files changed, 21 insertions, 19 deletions
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 8cb0700b9..8a18bc18c 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -348,8 +348,10 @@ mod tests {
348 ); 348 );
349 } 349 }
350 350
351 fn check_apply_diagnostic_fix(before: &str, after: &str) { 351 fn check_apply_diagnostic_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
352 let (analysis, file_id) = single_file(before); 352 let ra_fixture_after = &trim_indent(ra_fixture_after);
353 let (analysis, file_id) = single_file(ra_fixture_before);
354 let before = analysis.file_text(file_id).unwrap();
353 let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap(); 355 let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap();
354 let mut fix = diagnostic.fix.unwrap(); 356 let mut fix = diagnostic.fix.unwrap();
355 let edit = fix.source_change.source_file_edits.pop().unwrap().edit; 357 let edit = fix.source_change.source_file_edits.pop().unwrap().edit;
@@ -358,7 +360,7 @@ mod tests {
358 edit.apply(&mut actual); 360 edit.apply(&mut actual);
359 actual 361 actual
360 }; 362 };
361 assert_eq_text!(after, &actual); 363 assert_eq_text!(ra_fixture_after, &actual);
362 } 364 }
363 365
364 /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics 366 /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
@@ -709,7 +711,7 @@ mod tests {
709 [ 711 [
710 Diagnostic { 712 Diagnostic {
711 message: "Missing structure fields:\n- b\n", 713 message: "Missing structure fields:\n- b\n",
712 range: 224..233, 714 range: 127..136,
713 severity: Error, 715 severity: Error,
714 fix: Some( 716 fix: Some(
715 Fix { 717 Fix {
@@ -855,22 +857,22 @@ fn main() {
855 fn test_add_field_from_usage() { 857 fn test_add_field_from_usage() {
856 check_apply_diagnostic_fix( 858 check_apply_diagnostic_fix(
857 r" 859 r"
858 fn main() { 860fn main() {
859 Foo { bar: 3, baz: false}; 861 Foo { bar: 3, baz: false};
860 } 862}
861 struct Foo { 863struct Foo {
862 bar: i32 864 bar: i32
863 } 865}
864 ", 866",
865 r" 867 r"
866 fn main() { 868fn main() {
867 Foo { bar: 3, baz: false}; 869 Foo { bar: 3, baz: false};
868 } 870}
869 struct Foo { 871struct Foo {
870 bar: i32, 872 bar: i32,
871 baz: bool 873 baz: bool
872 } 874}
873 ", 875",
874 ) 876 )
875 } 877 }
876} 878}