aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/helpers/merge_imports.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db/src/helpers/merge_imports.rs')
-rw-r--r--crates/ide_db/src/helpers/merge_imports.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ide_db/src/helpers/merge_imports.rs b/crates/ide_db/src/helpers/merge_imports.rs
index 148297279..af2a51a4d 100644
--- a/crates/ide_db/src/helpers/merge_imports.rs
+++ b/crates/ide_db/src/helpers/merge_imports.rs
@@ -9,19 +9,19 @@ use syntax::ast::{
9/// What type of merges are allowed. 9/// What type of merges are allowed.
10#[derive(Copy, Clone, Debug, PartialEq, Eq)] 10#[derive(Copy, Clone, Debug, PartialEq, Eq)]
11pub enum MergeBehavior { 11pub enum MergeBehavior {
12 /// Merge everything together creating deeply nested imports. 12 /// Merge imports from the same crate into a single use statement.
13 Full, 13 Crate,
14 /// Only merge the last import level, doesn't allow import nesting. 14 /// Merge imports from the same module into a single use statement.
15 Last, 15 Module,
16} 16}
17 17
18impl MergeBehavior { 18impl MergeBehavior {
19 #[inline] 19 #[inline]
20 fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool { 20 fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool {
21 match self { 21 match self {
22 MergeBehavior::Full => true, 22 MergeBehavior::Crate => true,
23 // only simple single segment paths are allowed 23 // only simple single segment paths are allowed
24 MergeBehavior::Last => { 24 MergeBehavior::Module => {
25 tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) 25 tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1)
26 } 26 }
27 } 27 }
@@ -153,7 +153,7 @@ fn recursive_merge(
153 } 153 }
154 } 154 }
155 Err(_) 155 Err(_)
156 if merge == MergeBehavior::Last 156 if merge == MergeBehavior::Module
157 && use_trees.len() > 0 157 && use_trees.len() > 0
158 && rhs_t.use_tree_list().is_some() => 158 && rhs_t.use_tree_list().is_some() =>
159 { 159 {