diff options
Diffstat (limited to 'crates/ide_db/src/helpers/insert_use.rs')
-rw-r--r-- | crates/ide_db/src/helpers/insert_use.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index 040843990..9be36d59b 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -93,7 +93,7 @@ fn is_inner_comment(token: SyntaxToken) -> bool { | |||
93 | pub fn insert_use<'a>( | 93 | pub fn insert_use<'a>( |
94 | scope: &ImportScope, | 94 | scope: &ImportScope, |
95 | path: ast::Path, | 95 | path: ast::Path, |
96 | merge: Option<MergeBehaviour>, | 96 | merge: Option<MergeBehavior>, |
97 | ) -> SyntaxRewriter<'a> { | 97 | ) -> SyntaxRewriter<'a> { |
98 | let _p = profile::span("insert_use"); | 98 | let _p = profile::span("insert_use"); |
99 | let mut rewriter = SyntaxRewriter::default(); | 99 | let mut rewriter = SyntaxRewriter::default(); |
@@ -183,7 +183,7 @@ fn eq_visibility(vis0: Option<ast::Visibility>, vis1: Option<ast::Visibility>) - | |||
183 | pub fn try_merge_imports( | 183 | pub fn try_merge_imports( |
184 | lhs: &ast::Use, | 184 | lhs: &ast::Use, |
185 | rhs: &ast::Use, | 185 | rhs: &ast::Use, |
186 | merge_behaviour: MergeBehaviour, | 186 | merge_behavior: MergeBehavior, |
187 | ) -> Option<ast::Use> { | 187 | ) -> Option<ast::Use> { |
188 | // don't merge imports with different visibilities | 188 | // don't merge imports with different visibilities |
189 | if !eq_visibility(lhs.visibility(), rhs.visibility()) { | 189 | if !eq_visibility(lhs.visibility(), rhs.visibility()) { |
@@ -191,14 +191,14 @@ pub fn try_merge_imports( | |||
191 | } | 191 | } |
192 | let lhs_tree = lhs.use_tree()?; | 192 | let lhs_tree = lhs.use_tree()?; |
193 | let rhs_tree = rhs.use_tree()?; | 193 | let rhs_tree = rhs.use_tree()?; |
194 | let merged = try_merge_trees(&lhs_tree, &rhs_tree, merge_behaviour)?; | 194 | let merged = try_merge_trees(&lhs_tree, &rhs_tree, merge_behavior)?; |
195 | Some(lhs.with_use_tree(merged)) | 195 | Some(lhs.with_use_tree(merged)) |
196 | } | 196 | } |
197 | 197 | ||
198 | pub fn try_merge_trees( | 198 | pub fn try_merge_trees( |
199 | lhs: &ast::UseTree, | 199 | lhs: &ast::UseTree, |
200 | rhs: &ast::UseTree, | 200 | rhs: &ast::UseTree, |
201 | merge: MergeBehaviour, | 201 | merge: MergeBehavior, |
202 | ) -> Option<ast::UseTree> { | 202 | ) -> Option<ast::UseTree> { |
203 | let lhs_path = lhs.path()?; | 203 | let lhs_path = lhs.path()?; |
204 | let rhs_path = rhs.path()?; | 204 | let rhs_path = rhs.path()?; |
@@ -220,7 +220,7 @@ pub fn try_merge_trees( | |||
220 | fn recursive_merge( | 220 | fn recursive_merge( |
221 | lhs: &ast::UseTree, | 221 | lhs: &ast::UseTree, |
222 | rhs: &ast::UseTree, | 222 | rhs: &ast::UseTree, |
223 | merge: MergeBehaviour, | 223 | merge: MergeBehavior, |
224 | ) -> Option<ast::UseTree> { | 224 | ) -> Option<ast::UseTree> { |
225 | let mut use_trees = lhs | 225 | let mut use_trees = lhs |
226 | .use_tree_list() | 226 | .use_tree_list() |
@@ -301,7 +301,7 @@ fn recursive_merge( | |||
301 | } | 301 | } |
302 | } | 302 | } |
303 | Err(_) | 303 | Err(_) |
304 | if merge == MergeBehaviour::Last | 304 | if merge == MergeBehavior::Last |
305 | && use_trees.len() > 0 | 305 | && use_trees.len() > 0 |
306 | && rhs_t.use_tree_list().is_some() => | 306 | && rhs_t.use_tree_list().is_some() => |
307 | { | 307 | { |
@@ -438,20 +438,20 @@ fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { | |||
438 | 438 | ||
439 | /// What type of merges are allowed. | 439 | /// What type of merges are allowed. |
440 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | 440 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
441 | pub enum MergeBehaviour { | 441 | pub enum MergeBehavior { |
442 | /// Merge everything together creating deeply nested imports. | 442 | /// Merge everything together creating deeply nested imports. |
443 | Full, | 443 | Full, |
444 | /// Only merge the last import level, doesn't allow import nesting. | 444 | /// Only merge the last import level, doesn't allow import nesting. |
445 | Last, | 445 | Last, |
446 | } | 446 | } |
447 | 447 | ||
448 | impl MergeBehaviour { | 448 | impl MergeBehavior { |
449 | #[inline] | 449 | #[inline] |
450 | fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool { | 450 | fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool { |
451 | match self { | 451 | match self { |
452 | MergeBehaviour::Full => true, | 452 | MergeBehavior::Full => true, |
453 | // only simple single segment paths are allowed | 453 | // only simple single segment paths are allowed |
454 | MergeBehaviour::Last => { | 454 | MergeBehavior::Last => { |
455 | tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) | 455 | tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) |
456 | } | 456 | } |
457 | } | 457 | } |