aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-22 17:02:37 +0100
committerAleksey Kladov <[email protected]>2018-08-22 17:06:30 +0100
commit8d82d1551ee09faa5d46a58c17c40c2515d3f3b9 (patch)
treebdff5ca6dc2d4be1ef0aca616ba920d8ff2933e0 /crates/server/src
parent147578f0fe28dee9ba3bfe3ed8805ffe3a525611 (diff)
Extend add impl
Diffstat (limited to 'crates/server/src')
-rw-r--r--crates/server/src/main_loop/handlers.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/server/src/main_loop/handlers.rs b/crates/server/src/main_loop/handlers.rs
index 9ff821a8b..b47cbc0fc 100644
--- a/crates/server/src/main_loop/handlers.rs
+++ b/crates/server/src/main_loop/handlers.rs
@@ -110,6 +110,7 @@ pub fn handle_code_action(
110 let actions = &[ 110 let actions = &[
111 (ActionId::FlipComma, libeditor::flip_comma(&file, offset).is_some()), 111 (ActionId::FlipComma, libeditor::flip_comma(&file, offset).is_some()),
112 (ActionId::AddDerive, libeditor::add_derive(&file, offset).is_some()), 112 (ActionId::AddDerive, libeditor::add_derive(&file, offset).is_some()),
113 (ActionId::AddImpl, libeditor::add_impl(&file, offset).is_some()),
113 ]; 114 ];
114 115
115 for (id, edit) in actions { 116 for (id, edit) in actions {
@@ -218,6 +219,7 @@ pub fn handle_execute_command(
218 let action_result = match arg.id { 219 let action_result = match arg.id {
219 ActionId::FlipComma => libeditor::flip_comma(&file, arg.offset).map(|f| f()), 220 ActionId::FlipComma => libeditor::flip_comma(&file, arg.offset).map(|f| f()),
220 ActionId::AddDerive => libeditor::add_derive(&file, arg.offset).map(|f| f()), 221 ActionId::AddDerive => libeditor::add_derive(&file, arg.offset).map(|f| f()),
222 ActionId::AddImpl => libeditor::add_impl(&file, arg.offset).map(|f| f()),
221 }.ok_or_else(|| format_err!("command not applicable"))?; 223 }.ok_or_else(|| format_err!("command not applicable"))?;
222 let line_index = world.analysis().file_line_index(file_id)?; 224 let line_index = world.analysis().file_line_index(file_id)?;
223 let mut changes = HashMap::new(); 225 let mut changes = HashMap::new();
@@ -259,6 +261,7 @@ fn apply_code_action_cmd(id: ActionId, doc: TextDocumentIdentifier, offset: Text
259enum ActionId { 261enum ActionId {
260 FlipComma, 262 FlipComma,
261 AddDerive, 263 AddDerive,
264 AddImpl,
262} 265}
263 266
264impl ActionId { 267impl ActionId {
@@ -266,6 +269,7 @@ impl ActionId {
266 match *self { 269 match *self {
267 ActionId::FlipComma => "Flip `,`", 270 ActionId::FlipComma => "Flip `,`",
268 ActionId::AddDerive => "Add `#[derive]`", 271 ActionId::AddDerive => "Add `#[derive]`",
272 ActionId::AddImpl => "Add impl",
269 } 273 }
270 } 274 }
271} 275}