aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/helpers/insert_use/tests.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-04-20 01:05:22 +0100
committerLukas Wirth <[email protected]>2021-04-20 01:09:12 +0100
commitfa20a5064be85349d2d05abcd66f5662d3aecb0c (patch)
tree578e0f5f9208d607969b084921e174a1cebe1f44 /crates/ide_db/src/helpers/insert_use/tests.rs
parente8744ed9bb3e139e5d427db1f4f219f1fdeee13e (diff)
Remove SyntaxRewriter usage in insert_use in favor of ted
Diffstat (limited to 'crates/ide_db/src/helpers/insert_use/tests.rs')
-rw-r--r--crates/ide_db/src/helpers/insert_use/tests.rs19
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]
53fn insert_start_indent() { 53fn 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]
122fn insert_end_indent() { 121fn 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]
257fn insert_empty_module() { 255fn 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