aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assist_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/assist_context.rs')
-rw-r--r--crates/ra_assists/src/assist_context.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs
index 0dcd9df61..005c17776 100644
--- a/crates/ra_assists/src/assist_context.rs
+++ b/crates/ra_assists/src/assist_context.rs
@@ -194,20 +194,30 @@ impl AssistBuilder {
194 pub(crate) fn insert(&mut self, offset: TextSize, text: impl Into<String>) { 194 pub(crate) fn insert(&mut self, offset: TextSize, text: impl Into<String>) {
195 self.edit.insert(offset, text.into()) 195 self.edit.insert(offset, text.into())
196 } 196 }
197 /// Append specified `text` at the given `offset` 197 /// Append specified `snippet` at the given `offset`
198 pub(crate) fn insert_snippet( 198 pub(crate) fn insert_snippet(
199 &mut self, 199 &mut self,
200 _cap: SnippetCap, 200 _cap: SnippetCap,
201 offset: TextSize, 201 offset: TextSize,
202 text: impl Into<String>, 202 snippet: impl Into<String>,
203 ) { 203 ) {
204 self.is_snippet = true; 204 self.is_snippet = true;
205 self.edit.insert(offset, text.into()) 205 self.insert(offset, snippet);
206 } 206 }
207 /// Replaces specified `range` of text with a given string. 207 /// Replaces specified `range` of text with a given string.
208 pub(crate) fn replace(&mut self, range: TextRange, replace_with: impl Into<String>) { 208 pub(crate) fn replace(&mut self, range: TextRange, replace_with: impl Into<String>) {
209 self.edit.replace(range, replace_with.into()) 209 self.edit.replace(range, replace_with.into())
210 } 210 }
211 /// Replaces specified `range` of text with a given `snippet`.
212 pub(crate) fn replace_snippet(
213 &mut self,
214 _cap: SnippetCap,
215 range: TextRange,
216 snippet: impl Into<String>,
217 ) {
218 self.is_snippet = true;
219 self.replace(range, snippet);
220 }
211 pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) { 221 pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) {
212 algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) 222 algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit)
213 } 223 }