aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/handlers.rs
diff options
context:
space:
mode:
authorivan770 <[email protected]>2021-03-16 12:37:00 +0000
committerivan770 <[email protected]>2021-03-18 09:22:27 +0000
commit7d604584954660d255ad0929d3be8ce03f879d0c (patch)
tree613fdfdfd7eeb170082800533fb8b669dc35d25b /crates/rust-analyzer/src/handlers.rs
parentd704750ba982153d92ccff90cf236121641b9da3 (diff)
Item up and down movers
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-rw-r--r--crates/rust-analyzer/src/handlers.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index b6f484e51..8daf27867 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1424,6 +1424,25 @@ pub(crate) fn handle_open_cargo_toml(
1424 Ok(Some(res)) 1424 Ok(Some(res))
1425} 1425}
1426 1426
1427pub(crate) fn handle_move_item(
1428 snap: GlobalStateSnapshot,
1429 params: lsp_ext::MoveItemParams,
1430) -> Result<Option<lsp_types::TextDocumentEdit>> {
1431 let _p = profile::span("handle_move_item");
1432 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1433 let range = from_proto::file_range(&snap, params.text_document, params.range)?;
1434
1435 let direction = match params.direction {
1436 lsp_ext::MoveItemDirection::Up => ide::Direction::Up,
1437 lsp_ext::MoveItemDirection::Down => ide::Direction::Down,
1438 };
1439
1440 match snap.analysis.move_item(range, direction)? {
1441 Some(text_edit) => Ok(Some(to_proto::text_document_edit(&snap, file_id, text_edit)?)),
1442 None => Ok(None),
1443 }
1444}
1445
1427fn to_command_link(command: lsp_types::Command, tooltip: String) -> lsp_ext::CommandLink { 1446fn to_command_link(command: lsp_types::Command, tooltip: String) -> lsp_ext::CommandLink {
1428 lsp_ext::CommandLink { tooltip: Some(tooltip), command } 1447 lsp_ext::CommandLink { tooltip: Some(tooltip), command }
1429} 1448}