aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorChristoph Herzog <[email protected]>2020-07-07 11:10:18 +0100
committerChristoph Herzog <[email protected]>2020-07-07 11:10:18 +0100
commit3360118040a84d4f387db1c1d340fcaeeede2976 (patch)
tree4a7fe683a14243244703f83b15b2330832cb1eb5 /crates/ra_assists/src
parentd4bc2f25de6297c75f7b7f029df224b650ef3143 (diff)
Refactor AssistBuilder to manage a SourceChange
`AssistBuilder`` now managaes a full `SourceChange` instead of a Vec<SourceFileEdit>. This prepares AssistBuilder to handle creation of new files.
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/assist_context.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs
index 3640bb4d2..c33525363 100644
--- a/crates/ra_assists/src/assist_context.rs
+++ b/crates/ra_assists/src/assist_context.rs
@@ -176,7 +176,7 @@ pub(crate) struct AssistBuilder {
176 edit: TextEditBuilder, 176 edit: TextEditBuilder,
177 file_id: FileId, 177 file_id: FileId,
178 is_snippet: bool, 178 is_snippet: bool,
179 edits: Vec<SourceFileEdit>, 179 change: SourceChange,
180} 180}
181 181
182impl AssistBuilder { 182impl AssistBuilder {
@@ -185,7 +185,7 @@ impl AssistBuilder {
185 edit: TextEditBuilder::default(), 185 edit: TextEditBuilder::default(),
186 file_id, 186 file_id,
187 is_snippet: false, 187 is_snippet: false,
188 edits: Vec::new(), 188 change: SourceChange::default(),
189 } 189 }
190 } 190 }
191 191
@@ -197,8 +197,8 @@ impl AssistBuilder {
197 let edit = mem::take(&mut self.edit).finish(); 197 let edit = mem::take(&mut self.edit).finish();
198 if !edit.is_empty() { 198 if !edit.is_empty() {
199 let new_edit = SourceFileEdit { file_id: self.file_id, edit }; 199 let new_edit = SourceFileEdit { file_id: self.file_id, edit };
200 assert!(!self.edits.iter().any(|it| it.file_id == new_edit.file_id)); 200 assert!(!self.change.source_file_edits.iter().any(|it| it.file_id == new_edit.file_id));
201 self.edits.push(new_edit); 201 self.change.source_file_edits.push(new_edit);
202 } 202 }
203 } 203 }
204 204
@@ -265,10 +265,10 @@ impl AssistBuilder {
265 265
266 fn finish(mut self) -> SourceChange { 266 fn finish(mut self) -> SourceChange {
267 self.commit(); 267 self.commit();
268 let mut res: SourceChange = mem::take(&mut self.edits).into(); 268 let mut change = mem::take(&mut self.change);
269 if self.is_snippet { 269 if self.is_snippet {
270 res.is_snippet = true; 270 change.is_snippet = true;
271 } 271 }
272 res 272 change
273 } 273 }
274} 274}