diff options
Diffstat (limited to 'crates/ide_db/src/helpers/insert_use')
-rw-r--r-- | crates/ide_db/src/helpers/insert_use/tests.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/crates/ide_db/src/helpers/insert_use/tests.rs b/crates/ide_db/src/helpers/insert_use/tests.rs index 3d151e629..a3464d606 100644 --- a/crates/ide_db/src/helpers/insert_use/tests.rs +++ b/crates/ide_db/src/helpers/insert_use/tests.rs | |||
@@ -51,17 +51,16 @@ use std::bar::G;", | |||
51 | 51 | ||
52 | #[test] | 52 | #[test] |
53 | fn insert_start_indent() { | 53 | fn insert_start_indent() { |
54 | cov_mark::check!(insert_use_indent_after); | ||
55 | check_none( | 54 | check_none( |
56 | "std::bar::AA", | 55 | "std::bar::AA", |
57 | r" | 56 | r" |
58 | use std::bar::B; | 57 | use std::bar::B; |
59 | use std::bar::D;", | 58 | use std::bar::C;", |
60 | r" | 59 | r" |
61 | use std::bar::AA; | 60 | use std::bar::AA; |
62 | use std::bar::B; | 61 | use std::bar::B; |
63 | use std::bar::D;", | 62 | use std::bar::C;", |
64 | ) | 63 | ); |
65 | } | 64 | } |
66 | 65 | ||
67 | #[test] | 66 | #[test] |
@@ -120,7 +119,6 @@ use std::bar::ZZ;", | |||
120 | 119 | ||
121 | #[test] | 120 | #[test] |
122 | fn insert_end_indent() { | 121 | fn insert_end_indent() { |
123 | cov_mark::check!(insert_use_indent_before); | ||
124 | check_none( | 122 | check_none( |
125 | "std::bar::ZZ", | 123 | "std::bar::ZZ", |
126 | r" | 124 | r" |
@@ -255,7 +253,6 @@ fn insert_empty_file() { | |||
255 | 253 | ||
256 | #[test] | 254 | #[test] |
257 | fn insert_empty_module() { | 255 | fn insert_empty_module() { |
258 | cov_mark::check!(insert_use_no_indent_after); | ||
259 | check( | 256 | check( |
260 | "foo::bar", | 257 | "foo::bar", |
261 | "mod x {}", | 258 | "mod x {}", |
@@ -615,7 +612,7 @@ fn check( | |||
615 | if module { | 612 | if module { |
616 | syntax = syntax.descendants().find_map(ast::Module::cast).unwrap().syntax().clone(); | 613 | syntax = syntax.descendants().find_map(ast::Module::cast).unwrap().syntax().clone(); |
617 | } | 614 | } |
618 | let file = super::ImportScope::from(syntax).unwrap(); | 615 | let file = super::ImportScope::from(syntax.clone_for_update()).unwrap(); |
619 | let path = ast::SourceFile::parse(&format!("use {};", path)) | 616 | let path = ast::SourceFile::parse(&format!("use {};", path)) |
620 | .tree() | 617 | .tree() |
621 | .syntax() | 618 | .syntax() |
@@ -623,12 +620,8 @@ fn check( | |||
623 | .find_map(ast::Path::cast) | 620 | .find_map(ast::Path::cast) |
624 | .unwrap(); | 621 | .unwrap(); |
625 | 622 | ||
626 | let rewriter = insert_use( | 623 | insert_use(&file, path, InsertUseConfig { merge: mb, prefix_kind: PrefixKind::Plain, group }); |
627 | &file, | 624 | let result = file.as_syntax_node().to_string(); |
628 | path, | ||
629 | InsertUseConfig { merge: mb, prefix_kind: PrefixKind::Plain, group }, | ||
630 | ); | ||
631 | let result = rewriter.rewrite(file.as_syntax_node()).to_string(); | ||
632 | assert_eq_text!(ra_fixture_after, &result); | 625 | assert_eq_text!(ra_fixture_after, &result); |
633 | } | 626 | } |
634 | 627 | ||