Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/merge_imports.rs')
-rw-r--r--crates/ide-assists/src/handlers/merge_imports.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/crates/ide-assists/src/handlers/merge_imports.rs b/crates/ide-assists/src/handlers/merge_imports.rs
index 7f751c93e4..4171230836 100644
--- a/crates/ide-assists/src/handlers/merge_imports.rs
+++ b/crates/ide-assists/src/handlers/merge_imports.rs
@@ -164,6 +164,7 @@ impl Merge for ast::UseTree {
}
}
+#[derive(Debug)]
enum Edit {
Remove(Either<ast::Use, ast::UseTree>),
Replace(SyntaxNode, SyntaxNode),
@@ -733,4 +734,72 @@ use std::{
r"use std::fmt::{Debug, Display};",
);
}
+
+ #[test]
+ fn test_merge_with_synonymous_imports_1() {
+ check_assist(
+ merge_imports,
+ r"
+mod top {
+ pub(crate) mod a {
+ pub(crate) struct A;
+ }
+ pub(crate) mod b {
+ pub(crate) struct B;
+ pub(crate) struct D;
+ }
+}
+
+use top::a::A;
+use $0top::b::{B, B as C};
+",
+ r"
+mod top {
+ pub(crate) mod a {
+ pub(crate) struct A;
+ }
+ pub(crate) mod b {
+ pub(crate) struct B;
+ pub(crate) struct D;
+ }
+}
+
+use top::{a::A, b::{B, B as C}};
+",
+ );
+ }
+
+ #[test]
+ fn test_merge_with_synonymous_imports_2() {
+ check_assist(
+ merge_imports,
+ r"
+mod top {
+ pub(crate) mod a {
+ pub(crate) struct A;
+ }
+ pub(crate) mod b {
+ pub(crate) struct B;
+ pub(crate) struct D;
+ }
+}
+
+use top::a::A;
+use $0top::b::{B as D, B as C};
+",
+ r"
+mod top {
+ pub(crate) mod a {
+ pub(crate) struct A;
+ }
+ pub(crate) mod b {
+ pub(crate) struct B;
+ pub(crate) struct D;
+ }
+}
+
+use top::{a::A, b::{B as D, B as C}};
+",
+ );
+ }
}