diff options
author | Mikhail Rakhmanov <[email protected]> | 2020-05-22 21:43:52 +0100 |
---|---|---|
committer | Mikhail Rakhmanov <[email protected]> | 2020-05-22 21:43:52 +0100 |
commit | 04a35784df4cf267a8bbce6d5542869ed1a52fcb (patch) | |
tree | 82a79f605994d9573b15b12f3561a6744045afae /crates/ra_assists/src/assist_context.rs | |
parent | 5cd4eb6dd6d8c733077a6aeea5d2cc0812ded096 (diff) |
Formatting and remove unused imports
Diffstat (limited to 'crates/ra_assists/src/assist_context.rs')
-rw-r--r-- | crates/ra_assists/src/assist_context.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 6291c68de..52bc7820e 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use algo::find_covering_element; | 3 | use algo::find_covering_element; |
4 | use hir::Semantics; | 4 | use hir::Semantics; |
5 | use ra_db::{FileId, FileRange, FilePosition}; | 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::{SourceChange, SourceFileEdit}, | 8 | source_change::{SourceChange, SourceFileEdit}, |
@@ -173,16 +173,20 @@ impl Assists { | |||
173 | Some(()) | 173 | Some(()) |
174 | } | 174 | } |
175 | 175 | ||
176 | fn add_impl_multiple_files(&mut self, label: Assist, f: impl FnOnce(&mut AssistDirector)) -> Option<()> { | 176 | fn add_impl_multiple_files( |
177 | &mut self, | ||
178 | label: Assist, | ||
179 | f: impl FnOnce(&mut AssistDirector), | ||
180 | ) -> Option<()> { | ||
177 | let change_label = label.label.clone(); | 181 | let change_label = label.label.clone(); |
178 | if !self.resolve { | 182 | if !self.resolve { |
179 | return None | 183 | return None; |
180 | } | 184 | } |
181 | let mut director = AssistDirector::new(change_label.clone()); | 185 | let mut director = AssistDirector::new(change_label.clone()); |
182 | f(&mut director); | 186 | f(&mut director); |
183 | let changes = director.finish(); | 187 | let changes = director.finish(); |
184 | let file_edits: Vec<SourceFileEdit> = changes.into_iter() | 188 | let file_edits: Vec<SourceFileEdit> = |
185 | .map(|mut change| change.source_file_edits.pop().unwrap()).collect(); | 189 | changes.into_iter().map(|mut change| change.source_file_edits.pop().unwrap()).collect(); |
186 | 190 | ||
187 | let source_change = SourceChange { | 191 | let source_change = SourceChange { |
188 | source_file_edits: file_edits, | 192 | source_file_edits: file_edits, |
@@ -291,16 +295,12 @@ impl AssistBuilder { | |||
291 | pub(crate) struct AssistDirector { | 295 | pub(crate) struct AssistDirector { |
292 | source_changes: Vec<SourceChange>, | 296 | source_changes: Vec<SourceChange>, |
293 | builders: FxHashMap<FileId, AssistBuilder>, | 297 | builders: FxHashMap<FileId, AssistBuilder>, |
294 | change_label: String | 298 | change_label: String, |
295 | } | 299 | } |
296 | 300 | ||
297 | impl AssistDirector { | 301 | impl AssistDirector { |
298 | fn new(change_label: String) -> AssistDirector { | 302 | fn new(change_label: String) -> AssistDirector { |
299 | AssistDirector { | 303 | AssistDirector { source_changes: vec![], builders: FxHashMap::default(), change_label } |
300 | source_changes: vec![], | ||
301 | builders: FxHashMap::default(), | ||
302 | change_label | ||
303 | } | ||
304 | } | 304 | } |
305 | 305 | ||
306 | pub(crate) fn perform(&mut self, file_id: FileId, f: impl FnOnce(&mut AssistBuilder)) { | 306 | pub(crate) fn perform(&mut self, file_id: FileId, f: impl FnOnce(&mut AssistBuilder)) { |
@@ -309,8 +309,10 @@ impl AssistDirector { | |||
309 | } | 309 | } |
310 | 310 | ||
311 | fn finish(mut self) -> Vec<SourceChange> { | 311 | fn finish(mut self) -> Vec<SourceChange> { |
312 | for (file_id, builder) in self.builders.into_iter().collect::<Vec<(FileId, AssistBuilder)>>() { | 312 | for (file_id, builder) in |
313 | self.source_changes.push(builder.finish()); | 313 | self.builders.into_iter().collect::<Vec<(FileId, AssistBuilder)>>() |
314 | { | ||
315 | self.source_changes.push(builder.finish()); | ||
314 | } | 316 | } |
315 | self.source_changes | 317 | self.source_changes |
316 | } | 318 | } |