From fa20a5064be85349d2d05abcd66f5662d3aecb0c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 20 Apr 2021 02:05:22 +0200 Subject: Remove SyntaxRewriter usage in insert_use in favor of ted --- crates/ide_completion/src/item.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs index 16991b688..99edb9499 100644 --- a/crates/ide_completion/src/item.rs +++ b/crates/ide_completion/src/item.rs @@ -377,11 +377,11 @@ impl ImportEdit { pub fn to_text_edit(&self, cfg: InsertUseConfig) -> Option { let _p = profile::span("ImportEdit::to_text_edit"); - let rewriter = - insert_use::insert_use(&self.scope, mod_path_to_ast(&self.import.import_path), cfg); - let old_ast = rewriter.rewrite_root()?; + let new_ast = self.scope.clone_for_update(); + insert_use::insert_use(&new_ast, mod_path_to_ast(&self.import.import_path), cfg); let mut import_insert = TextEdit::builder(); - algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut import_insert); + algo::diff(self.scope.as_syntax_node(), new_ast.as_syntax_node()) + .into_text_edit(&mut import_insert); Some(import_insert.finish()) } -- cgit v1.2.3