From fa2e5299c3332b99fcd09fd54e8d812a6c34b0cc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 17 May 2020 14:21:24 +0200 Subject: Add snippet support for some assists --- crates/ra_assists/src/tests/generated.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 972dbd251..9487c9239 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -15,7 +15,7 @@ struct S; struct S; impl Debug for S { - + $0 } "#####, ) @@ -32,7 +32,7 @@ struct Point { } "#####, r#####" -#[derive()] +#[derive($0)] struct Point { x: u32, y: u32, @@ -108,16 +108,16 @@ fn doctest_add_impl() { "add_impl", r#####" struct Ctx { - data: T,<|> + data: T,<|> } "#####, r#####" struct Ctx { - data: T, + data: T, } impl Ctx { - + $0 } "#####, ) -- cgit v1.2.3 From 80545e5d3a72ef05a77ff9584234f030c69bfe9f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 00:07:00 +0200 Subject: New assist: add turbo fish --- crates/ra_assists/src/tests/generated.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 9487c9239..32fbcdef4 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -211,6 +211,25 @@ impl Ctx { ) } +#[test] +fn doctest_add_turbo_fish() { + check_doc_test( + "add_turbo_fish", + r#####" +fn make() -> T { todo!() } +fn main() { + let x = make<|>(); +} +"#####, + r#####" +fn make() -> T { todo!() } +fn main() { + let x = make::<${0:_}>(); +} +"#####, + ) +} + #[test] fn doctest_apply_demorgan() { check_doc_test( -- cgit v1.2.3 From 8eb3272ad6f774bccb967ee640b72a9a17273e7b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 19 May 2020 22:25:07 +0200 Subject: Use snippets in add function --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 32fbcdef4..1d82c245d 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -78,7 +78,7 @@ fn foo() { } fn bar(arg: &str, baz: Baz) { - todo!() + ${0:todo!()} } "#####, -- cgit v1.2.3 From a04cababaa144d7a6db7b1dd114494b33d281ab9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 01:53:21 +0200 Subject: Use snippets in add_missing_members --- crates/ra_assists/src/tests/generated.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 1d82c245d..2522ec5df 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -150,7 +150,7 @@ trait Trait { impl Trait for () { Type X = (); fn foo(&self) {} - fn bar(&self) {} + $0fn bar(&self) {} } "#####, @@ -180,7 +180,7 @@ trait Trait { } impl Trait for () { - fn foo(&self) -> u32 { + $0fn foo(&self) -> u32 { todo!() } -- cgit v1.2.3 From 767d169a2ae543f28544e85e15bac1b6aa1cab23 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 02:07:21 +0200 Subject: Better cursor placement when adding impl members --- crates/ra_assists/src/tests/generated.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 2522ec5df..3808aded1 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -180,8 +180,8 @@ trait Trait { } impl Trait for () { - $0fn foo(&self) -> u32 { - todo!() + fn foo(&self) -> u32 { + ${0:todo!()} } } -- cgit v1.2.3 From 9b2bd022dc6fbe13356622ada5b6499f012cb5ae Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 10:17:46 +0200 Subject: Snippetify add_new --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 3808aded1..d860cfefc 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -204,7 +204,7 @@ struct Ctx { } impl Ctx { - fn new(data: T) -> Self { Self { data } } + fn $0new(data: T) -> Self { Self { data } } } "#####, -- cgit v1.2.3 From 33e111483fbc80c017037e0b158ee652ed41b3e8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 11:10:15 +0200 Subject: Use snippets in change_return_type_to_result --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index d860cfefc..cd6129dc5 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -276,7 +276,7 @@ fn doctest_change_return_type_to_result() { fn foo() -> i32<|> { 42i32 } "#####, r#####" -fn foo() -> Result { Ok(42i32) } +fn foo() -> Result { Ok(42i32) } "#####, ) } -- cgit v1.2.3 From cec773926f08e2d46b05d923165f8e73c420aa8c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 13:33:13 +0200 Subject: Split change_ and fix_ visibility assists --- crates/ra_assists/src/tests/generated.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index cd6129dc5..417ee89a8 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -344,6 +344,29 @@ fn handle(action: Action) { ) } +#[test] +fn doctest_fix_visibility() { + check_doc_test( + "fix_visibility", + r#####" +mod m { + fn frobnicate() {} +} +fn main() { + m::frobnicate<|>() {} +} +"#####, + r#####" +mod m { + pub(crate) fn frobnicate() {} +} +fn main() { + m::frobnicate() {} +} +"#####, + ) +} + #[test] fn doctest_flip_binexpr() { check_doc_test( -- cgit v1.2.3 From c446fd76a2a6191adce87b20707a37bd46cb85a9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 14:00:37 +0200 Subject: Snippetify fill_match_arms --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 417ee89a8..d841b6f56 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -336,7 +336,7 @@ enum Action { Move { distance: u32 }, Stop } fn handle(action: Action) { match action { - Action::Move { distance } => {} + $0Action::Move { distance } => {} Action::Stop => {} } } -- cgit v1.2.3 From ba3a58d1b2d76bae2ac84923d12918a32ad680f6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 14:13:17 +0200 Subject: Snippetify fix_visibility --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index d841b6f56..3e6654c17 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -358,7 +358,7 @@ fn main() { "#####, r#####" mod m { - pub(crate) fn frobnicate() {} + $0pub(crate) fn frobnicate() {} } fn main() { m::frobnicate() {} -- cgit v1.2.3 From fd771707187a505c826096fc62ced6ba9b65460e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 23:07:17 +0200 Subject: Snippetify introduce/inline var --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 3e6654c17..0eeb5c199 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -443,7 +443,7 @@ fn main() { "#####, r#####" fn main() { - let var_name = (1 + 2); + let $0var_name = (1 + 2); var_name * 4; } "#####, -- cgit v1.2.3 From 4ac0abd2960acf1b3a357c681e64b3cddba6fc8e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 21 May 2020 00:01:08 +0200 Subject: Snippetify unwrap -> match --- crates/ra_assists/src/tests/generated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/tests') diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 0eeb5c199..250e56a69 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -764,7 +764,7 @@ fn main() { let x: Result = Result::Ok(92); let y = match x { Ok(a) => a, - _ => unreachable!(), + $0_ => unreachable!(), }; } "#####, -- cgit v1.2.3