aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/assists/flip_comma.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-08 19:17:36 +0000
committerAleksey Kladov <[email protected]>2019-01-08 19:17:36 +0000
commit1967884d6836219ee78a754ca5c66ac781351559 (patch)
tree7594f37cd0a5200eb097b9d472c61f0223d01d05 /crates/ra_editor/src/assists/flip_comma.rs
parent4f4f7933b1b7ff34f8633b1686b18b2d1b994c47 (diff)
rename ra_editor -> ra_ide_api_light
Diffstat (limited to 'crates/ra_editor/src/assists/flip_comma.rs')
-rw-r--r--crates/ra_editor/src/assists/flip_comma.rs31
1 files changed, 0 insertions, 31 deletions
diff --git a/crates/ra_editor/src/assists/flip_comma.rs b/crates/ra_editor/src/assists/flip_comma.rs
deleted file mode 100644
index a343413cc..000000000
--- a/crates/ra_editor/src/assists/flip_comma.rs
+++ /dev/null
@@ -1,31 +0,0 @@
1use ra_syntax::{
2 Direction,
3 SyntaxKind::COMMA,
4};
5
6use crate::assists::{non_trivia_sibling, AssistCtx, Assist};
7
8pub fn flip_comma(ctx: AssistCtx) -> Option<Assist> {
9 let comma = ctx.leaf_at_offset().find(|leaf| leaf.kind() == COMMA)?;
10 let prev = non_trivia_sibling(comma, Direction::Prev)?;
11 let next = non_trivia_sibling(comma, Direction::Next)?;
12 ctx.build("flip comma", |edit| {
13 edit.replace(prev.range(), next.text());
14 edit.replace(next.range(), prev.text());
15 })
16}
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21 use crate::assists::check_assist;
22
23 #[test]
24 fn flip_comma_works_for_function_parameters() {
25 check_assist(
26 flip_comma,
27 "fn foo(x: i32,<|> y: Result<(), ()>) {}",
28 "fn foo(y: Result<(), ()>,<|> x: i32) {}",
29 )
30 }
31}