diff options
Diffstat (limited to 'crates/ra_assists/src/assist_ctx.rs')
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index c45262efa..5f564be0b 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -2,7 +2,7 @@ use hir::db::HirDatabase; | |||
2 | use ra_db::FileRange; | 2 | use ra_db::FileRange; |
3 | use ra_fmt::{leading_indent, reindent}; | 3 | use ra_fmt::{leading_indent, reindent}; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | algo::{find_covering_element, find_node_at_offset}, | 5 | algo::{self, find_covering_element, find_node_at_offset}, |
6 | AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit, | 6 | AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit, |
7 | TokenAtOffset, | 7 | TokenAtOffset, |
8 | }; | 8 | }; |
@@ -177,6 +177,10 @@ impl AssistBuilder { | |||
177 | &mut self.edit | 177 | &mut self.edit |
178 | } | 178 | } |
179 | 179 | ||
180 | pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) { | ||
181 | algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) | ||
182 | } | ||
183 | |||
180 | fn build(self) -> AssistAction { | 184 | fn build(self) -> AssistAction { |
181 | AssistAction { | 185 | AssistAction { |
182 | edit: self.edit.finish(), | 186 | edit: self.edit.finish(), |