From e5101ae150db5faa7ddf8393e375032ef371f5e5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 24 Jun 2020 00:30:34 +0200 Subject: Centralize fixture parsing for assists --- crates/ra_assists/src/handlers/add_function.rs | 1 + crates/ra_assists/src/handlers/fill_match_arms.rs | 6 +-- .../ra_assists/src/handlers/introduce_variable.rs | 20 +++++---- crates/ra_assists/src/handlers/raw_string.rs | 48 +++++++++++----------- 4 files changed, 40 insertions(+), 35 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs index 19ce81d99..1cfbd75aa 100644 --- a/crates/ra_assists/src/handlers/add_function.rs +++ b/crates/ra_assists/src/handlers/add_function.rs @@ -986,6 +986,7 @@ fn main() { ", r" + pub(crate) fn bar() { ${0:todo!()} }", diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 3c12c1daa..64270c86f 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -763,9 +763,9 @@ mod tests { fn foo(opt: Option) { match opt<|> { } -}"#; - let before = - &format!("//- /main.rs crate:main deps:core\n{}{}", before, FamousDefs::FIXTURE); +} +"#; + let before = &format!("//- /main.rs crate:main deps:core{}{}", before, FamousDefs::FIXTURE); check_assist( fill_match_arms, diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs index 31d6539f7..88b62278f 100644 --- a/crates/ra_assists/src/handlers/introduce_variable.rs +++ b/crates/ra_assists/src/handlers/introduce_variable.rs @@ -226,27 +226,31 @@ fn foo() { mark::check!(test_introduce_var_last_expr); check_assist( introduce_variable, - " + r#" fn foo() { bar(<|>1 + 1<|>) -}", - " +} +"#, + r#" fn foo() { let $0var_name = 1 + 1; bar(var_name) -}", +} +"#, ); check_assist( introduce_variable, - " + r#" fn foo() { <|>bar(1 + 1)<|> -}", - " +} +"#, + r#" fn foo() { let $0var_name = bar(1 + 1); var_name -}", +} +"#, ) } diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/ra_assists/src/handlers/raw_string.rs index 16002d2ac..d22d0aa55 100644 --- a/crates/ra_assists/src/handlers/raw_string.rs +++ b/crates/ra_assists/src/handlers/raw_string.rs @@ -158,16 +158,16 @@ mod test { check_assist( make_raw_string, r#" - fn f() { - let s = <|>"random\nstring"; - } - "#, +fn f() { + let s = <|>"random\nstring"; +} +"#, r##" - fn f() { - let s = r#"random +fn f() { + let s = r#"random string"#; - } - "##, +} +"##, ) } @@ -193,16 +193,16 @@ string"#; check_assist( make_raw_string, r###" - fn f() { - let s = <|>"#random##\nstring"; - } - "###, +fn f() { + let s = <|>"#random##\nstring"; +} +"###, r####" - fn f() { - let s = r#"#random## +fn f() { + let s = r#"#random## string"#; - } - "####, +} +"####, ) } @@ -211,16 +211,16 @@ string"#; check_assist( make_raw_string, r###" - fn f() { - let s = <|>"#random\"##\nstring"; - } - "###, +fn f() { + let s = <|>"#random\"##\nstring"; +} +"###, r####" - fn f() { - let s = r###"#random"## +fn f() { + let s = r###"#random"## string"###; - } - "####, +} +"####, ) } -- cgit v1.2.3