mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Remove SyntaxRewriter usage in insert_use in favor of ted
This commit is contained in:
parent
e8744ed9bb
commit
fa20a5064b
8 changed files with 185 additions and 243 deletions
|
@ -377,11 +377,11 @@ impl ImportEdit {
|
|||
pub fn to_text_edit(&self, cfg: InsertUseConfig) -> Option<TextEdit> {
|
||||
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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue