aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/code_actions.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-12 07:52:38 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-12 07:52:38 +0000
commit0156a538089828340a823ed02da8970bf4f1175b (patch)
tree07c4eacaad717ea802ab26972f45223281f2c9c1 /crates/ra_editor/src/code_actions.rs
parentf655f993fe6d9faa81b0e776b9b24308d2ea1c68 (diff)
parent0527e3b283af0153cf13fa64fe73862a5b7655c8 (diff)
Merge #276
276: Extract and rename AtomEdit and Edit into ra_text_edit r=matklad a=vemoo As discused in #105 Co-authored-by: Bernardo <[email protected]>
Diffstat (limited to 'crates/ra_editor/src/code_actions.rs')
-rw-r--r--crates/ra_editor/src/code_actions.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_editor/src/code_actions.rs b/crates/ra_editor/src/code_actions.rs
index 6979251d1..688a89c3d 100644
--- a/crates/ra_editor/src/code_actions.rs
+++ b/crates/ra_editor/src/code_actions.rs
@@ -8,11 +8,11 @@ use ra_syntax::{
8 SyntaxNodeRef, TextRange, TextUnit, 8 SyntaxNodeRef, TextRange, TextUnit,
9}; 9};
10 10
11use crate::{find_node_at_offset, Edit, EditBuilder}; 11use crate::{find_node_at_offset, TextEdit, TextEditBuilder};
12 12
13#[derive(Debug)] 13#[derive(Debug)]
14pub struct LocalEdit { 14pub struct LocalEdit {
15 pub edit: Edit, 15 pub edit: TextEdit,
16 pub cursor_position: Option<TextUnit>, 16 pub cursor_position: Option<TextUnit>,
17} 17}
18 18
@@ -26,7 +26,7 @@ pub fn flip_comma<'a>(
26 let prev = non_trivia_sibling(comma, Direction::Prev)?; 26 let prev = non_trivia_sibling(comma, Direction::Prev)?;
27 let next = non_trivia_sibling(comma, Direction::Next)?; 27 let next = non_trivia_sibling(comma, Direction::Next)?;
28 Some(move || { 28 Some(move || {
29 let mut edit = EditBuilder::new(); 29 let mut edit = TextEditBuilder::new();
30 edit.replace(prev.range(), next.text().to_string()); 30 edit.replace(prev.range(), next.text().to_string());
31 edit.replace(next.range(), prev.text().to_string()); 31 edit.replace(next.range(), prev.text().to_string());
32 LocalEdit { 32 LocalEdit {
@@ -49,7 +49,7 @@ pub fn add_derive<'a>(
49 .filter(|(name, _arg)| name == "derive") 49 .filter(|(name, _arg)| name == "derive")
50 .map(|(_name, arg)| arg) 50 .map(|(_name, arg)| arg)
51 .next(); 51 .next();
52 let mut edit = EditBuilder::new(); 52 let mut edit = TextEditBuilder::new();
53 let offset = match derive_attr { 53 let offset = match derive_attr {
54 None => { 54 None => {
55 edit.insert(node_start, "#[derive()]\n".to_string()); 55 edit.insert(node_start, "#[derive()]\n".to_string());
@@ -82,7 +82,7 @@ pub fn add_impl<'a>(
82 82
83 Some(move || { 83 Some(move || {
84 let type_params = nominal.type_param_list(); 84 let type_params = nominal.type_param_list();
85 let mut edit = EditBuilder::new(); 85 let mut edit = TextEditBuilder::new();
86 let start_offset = nominal.syntax().range().end(); 86 let start_offset = nominal.syntax().range().end();
87 let mut buf = String::new(); 87 let mut buf = String::new();
88 buf.push_str("\n\nimpl"); 88 buf.push_str("\n\nimpl");
@@ -129,7 +129,7 @@ pub fn introduce_variable<'a>(
129 } 129 }
130 return Some(move || { 130 return Some(move || {
131 let mut buf = String::new(); 131 let mut buf = String::new();
132 let mut edit = EditBuilder::new(); 132 let mut edit = TextEditBuilder::new();
133 133
134 buf.push_str("let var_name = "); 134 buf.push_str("let var_name = ");
135 expr.syntax().text().push_to(&mut buf); 135 expr.syntax().text().push_to(&mut buf);