Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/imports/insert_use.rs')
| -rw-r--r-- | crates/ide-db/src/imports/insert_use.rs | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/crates/ide-db/src/imports/insert_use.rs b/crates/ide-db/src/imports/insert_use.rs index 4c4a01a157..7402ec8f5a 100644 --- a/crates/ide-db/src/imports/insert_use.rs +++ b/crates/ide-db/src/imports/insert_use.rs @@ -7,10 +7,7 @@ use std::cmp::Ordering; use hir::Semantics; use syntax::{ Direction, NodeOrToken, SyntaxKind, SyntaxNode, algo, - ast::{ - self, AstNode, HasAttrs, HasModuleItem, HasVisibility, PathSegmentKind, - edit_in_place::Removable, make, - }, + ast::{self, AstNode, HasAttrs, HasModuleItem, HasVisibility, PathSegmentKind, make}, syntax_editor::{Position, SyntaxEditor}, ted, }; @@ -326,28 +323,7 @@ fn insert_use_with_alias_option_with_editor( insert_use_with_editor_(scope, use_item, cfg.group, syntax_editor); } -pub fn ast_to_remove_for_path_in_use_stmt(path: &ast::Path) -> Option<Box<dyn Removable>> { - // FIXME: improve this - if path.parent_path().is_some() { - return None; - } - let use_tree = path.syntax().parent().and_then(ast::UseTree::cast)?; - if use_tree.use_tree_list().is_some() || use_tree.star_token().is_some() { - return None; - } - if let Some(use_) = use_tree.syntax().parent().and_then(ast::Use::cast) { - return Some(Box::new(use_)); - } - Some(Box::new(use_tree)) -} - -pub fn remove_path_if_in_use_stmt(path: &ast::Path) { - if let Some(node) = ast_to_remove_for_path_in_use_stmt(path) { - node.remove(); - } -} - -pub fn remove_use_tree_if_simple(use_tree: &ast::UseTree, editor: &mut SyntaxEditor) { +pub fn remove_use_tree_if_simple(use_tree: &ast::UseTree, editor: &SyntaxEditor) { if use_tree.use_tree_list().is_some() || use_tree.star_token().is_some() { return; } |