diff options
author | Aleksey Kladov <[email protected]> | 2019-02-03 18:26:35 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-06 14:00:00 +0000 |
commit | 0c5fd8f7cbf04eda763e55bc9a38dad5f7ec917d (patch) | |
tree | 4af15c8906b85de01a15c717bc1fac388952cd3d /crates/ra_ide_api_light/src/assists/flip_comma.rs | |
parent | 736a55c97e69f95e6ff4a0c3dafb2018e8ea05f9 (diff) |
move assists to a separate crate
Diffstat (limited to 'crates/ra_ide_api_light/src/assists/flip_comma.rs')
-rw-r--r-- | crates/ra_ide_api_light/src/assists/flip_comma.rs | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/crates/ra_ide_api_light/src/assists/flip_comma.rs b/crates/ra_ide_api_light/src/assists/flip_comma.rs deleted file mode 100644 index a343413cc..000000000 --- a/crates/ra_ide_api_light/src/assists/flip_comma.rs +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | use ra_syntax::{ | ||
2 | Direction, | ||
3 | SyntaxKind::COMMA, | ||
4 | }; | ||
5 | |||
6 | use crate::assists::{non_trivia_sibling, AssistCtx, Assist}; | ||
7 | |||
8 | pub 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)] | ||
19 | mod 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 | } | ||