diff options
author | Aleksey Kladov <[email protected]> | 2020-05-22 17:03:08 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-22 17:04:26 +0100 |
commit | 2c04aad2d2a52ce52d6ea6452faf8d1788f0c83f (patch) | |
tree | 281b8320f78424383e0f45f2bfd678c07a5360ae /crates/ra_assists/src/assist_context.rs | |
parent | 2075e77ee5784e72396c64c9ca059763508219ff (diff) |
KISS SourceChange
The idea behind requiring the label is a noble one, but we are not
really using it consistently anyway, and it should be easy to retrofit
later, should we need it.
Diffstat (limited to 'crates/ra_assists/src/assist_context.rs')
-rw-r--r-- | crates/ra_assists/src/assist_context.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index f3af70a3e..5b1a4680b 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs | |||
@@ -5,7 +5,7 @@ use hir::Semantics; | |||
5 | use ra_db::{FileId, FileRange}; | 5 | use ra_db::{FileId, FileRange}; |
6 | use ra_fmt::{leading_indent, reindent}; | 6 | use ra_fmt::{leading_indent, reindent}; |
7 | use ra_ide_db::{ | 7 | use ra_ide_db::{ |
8 | source_change::{SingleFileChange, SourceChange}, | 8 | source_change::{SourceChange, SourceFileEdit}, |
9 | RootDatabase, | 9 | RootDatabase, |
10 | }; | 10 | }; |
11 | use ra_syntax::{ | 11 | use ra_syntax::{ |
@@ -150,11 +150,10 @@ impl Assists { | |||
150 | self.add_impl(label, f) | 150 | self.add_impl(label, f) |
151 | } | 151 | } |
152 | fn add_impl(&mut self, label: Assist, f: impl FnOnce(&mut AssistBuilder)) -> Option<()> { | 152 | fn add_impl(&mut self, label: Assist, f: impl FnOnce(&mut AssistBuilder)) -> Option<()> { |
153 | let change_label = label.label.clone(); | ||
154 | let source_change = if self.resolve { | 153 | let source_change = if self.resolve { |
155 | let mut builder = AssistBuilder::new(self.file); | 154 | let mut builder = AssistBuilder::new(self.file); |
156 | f(&mut builder); | 155 | f(&mut builder); |
157 | Some(builder.finish(change_label)) | 156 | Some(builder.finish()) |
158 | } else { | 157 | } else { |
159 | None | 158 | None |
160 | }; | 159 | }; |
@@ -246,9 +245,10 @@ impl AssistBuilder { | |||
246 | &mut self.edit | 245 | &mut self.edit |
247 | } | 246 | } |
248 | 247 | ||
249 | fn finish(self, change_label: String) -> SourceChange { | 248 | fn finish(self) -> SourceChange { |
250 | let edit = self.edit.finish(); | 249 | let edit = self.edit.finish(); |
251 | let mut res = SingleFileChange { label: change_label, edit }.into_source_change(self.file); | 250 | let source_file_edit = SourceFileEdit { file_id: self.file, edit }; |
251 | let mut res: SourceChange = source_file_edit.into(); | ||
252 | if self.is_snippet { | 252 | if self.is_snippet { |
253 | res.is_snippet = true; | 253 | res.is_snippet = true; |
254 | } | 254 | } |