Skip to content

Commit 59b9453

Browse files
committed
update insert_use to use editor variant of merge_import methods
1 parent 465dcf4 commit 59b9453

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

crates/ide-db/src/imports/insert_use.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
RootDatabase,
1818
imports::merge_imports::{
1919
MergeBehavior, NormalizationStyle, common_prefix, eq_attrs, eq_visibility,
20-
try_merge_imports, use_tree_cmp,
20+
try_merge_imports, use_tree_cmp, wrap_in_tree_list,
2121
},
2222
};
2323

@@ -251,7 +251,7 @@ fn insert_use_with_alias_option_with_editor(
251251
let mut use_tree = make.use_tree(path, None, alias, false);
252252
if mb == Some(MergeBehavior::One)
253253
&& use_tree.path().is_some()
254-
&& let Some(wrapped) = use_tree.wrap_in_tree_list_with_editor()
254+
&& let Some(wrapped) = wrap_in_tree_list(&use_tree, make)
255255
{
256256
use_tree = wrapped;
257257
}
@@ -263,7 +263,7 @@ fn insert_use_with_alias_option_with_editor(
263263
for existing_use in
264264
scope.as_syntax_node().children().filter_map(ast::Use::cast).filter(filter)
265265
{
266-
if let Some(merged) = try_merge_imports(&existing_use, &use_item, mb) {
266+
if let Some(merged) = try_merge_imports(syntax_editor, &existing_use, &use_item, mb) {
267267
syntax_editor.replace(existing_use.syntax(), merged.syntax());
268268
return;
269269
}

crates/ide-db/src/imports/insert_use/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ fn check_merge_only_fail(ra_fixture0: &str, ra_fixture1: &str, mb: MergeBehavior
14301430
.find_map(ast::Use::cast)
14311431
.unwrap();
14321432

1433-
let editor = SyntaxEditor::new(use0.syntax().ancestors().last().unwrap()).0;
1433+
let (editor, _) = SyntaxEditor::new(use0.syntax().ancestors().last().unwrap());
14341434
let result = try_merge_imports(&editor, &use0, &use1, mb);
14351435
assert_eq!(result.map(|u| u.to_string()), None);
14361436
}
@@ -1496,7 +1496,7 @@ fn check_merge(ra_fixture0: &str, ra_fixture1: &str, last: &str, mb: MergeBehavi
14961496
.find_map(ast::Use::cast)
14971497
.unwrap();
14981498

1499-
let editor = SyntaxEditor::new(use0.syntax().ancestors().last().unwrap()).0;
1499+
let (editor, _) = SyntaxEditor::new(use0.syntax().ancestors().last().unwrap());
15001500
let result = try_merge_imports(&editor, &use0, &use1, mb);
15011501
assert_eq!(result.map(|u| u.to_string().trim().to_owned()), Some(last.trim().to_owned()));
15021502
}
@@ -1527,7 +1527,7 @@ fn merge_gated_imports_with_different_values() {
15271527
.find_map(ast::Use::cast)
15281528
.unwrap();
15291529

1530-
let editor = SyntaxEditor::new(use0.syntax().ancestors().last().unwrap()).0;
1530+
let (editor, _) = SyntaxEditor::new(use0.syntax().ancestors().last().unwrap());
15311531
let result = try_merge_imports(&editor, &use0, &use1, MergeBehavior::Crate);
15321532
assert_eq!(result, None);
15331533
}

0 commit comments

Comments
 (0)