aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-03 16:08:52 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-03 16:08:52 +0000
commit33924c0939bb64cdb6fc4644582411a7be1f135d (patch)
treeea555719a2ec8574f5399de896b9c4e2586c7270 /crates/ra_analysis
parent5443205fdd9f4886cc88ad15c3a6061ffa90ca19 (diff)
parent6be39ba758eade2a20ab6384127a2b1ca48ca9ce (diff)
Merge #416
416: assist-builder r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/imp.rs16
-rw-r--r--crates/ra_analysis/tests/tests.rs2
2 files changed, 4 insertions, 14 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 136e7f7dc..771dad475 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -333,19 +333,9 @@ impl db::RootDatabase {
333 333
334 pub(crate) fn assists(&self, frange: FileRange) -> Vec<SourceChange> { 334 pub(crate) fn assists(&self, frange: FileRange) -> Vec<SourceChange> {
335 let file = self.source_file(frange.file_id); 335 let file = self.source_file(frange.file_id);
336 let offset = frange.range.start(); 336 assists::assists(&file, frange.range)
337 let actions = vec![
338 assists::flip_comma(&file, offset).map(|f| f()),
339 assists::add_derive(&file, offset).map(|f| f()),
340 assists::add_impl(&file, offset).map(|f| f()),
341 assists::change_visibility(&file, offset).map(|f| f()),
342 assists::introduce_variable(&file, frange.range).map(|f| f()),
343 ];
344 actions
345 .into_iter() 337 .into_iter()
346 .filter_map(|local_edit| { 338 .map(|local_edit| SourceChange::from_local_edit(frange.file_id, local_edit))
347 Some(SourceChange::from_local_edit(frange.file_id, local_edit?))
348 })
349 .collect() 339 .collect()
350 } 340 }
351 341
@@ -440,7 +430,7 @@ impl db::RootDatabase {
440 .map(|(file_id, text_range)| SourceFileEdit { 430 .map(|(file_id, text_range)| SourceFileEdit {
441 file_id: *file_id, 431 file_id: *file_id,
442 edit: { 432 edit: {
443 let mut builder = ra_text_edit::TextEditBuilder::new(); 433 let mut builder = ra_text_edit::TextEditBuilder::default();
444 builder.replace(*text_range, new_name.into()); 434 builder.replace(*text_range, new_name.into());
445 builder.finish() 435 builder.finish()
446 }, 436 },
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index bcf29d29c..c2ef87b54 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -531,7 +531,7 @@ fn test_rename_for_mut_param() {
531fn test_rename(text: &str, new_name: &str, expected: &str) { 531fn test_rename(text: &str, new_name: &str, expected: &str) {
532 let (analysis, position) = single_file_with_position(text); 532 let (analysis, position) = single_file_with_position(text);
533 let edits = analysis.rename(position, new_name).unwrap(); 533 let edits = analysis.rename(position, new_name).unwrap();
534 let mut text_edit_bulder = ra_text_edit::TextEditBuilder::new(); 534 let mut text_edit_bulder = ra_text_edit::TextEditBuilder::default();
535 let mut file_id: Option<FileId> = None; 535 let mut file_id: Option<FileId> = None;
536 for edit in edits { 536 for edit in edits {
537 file_id = Some(edit.file_id); 537 file_id = Some(edit.file_id);