diff options
author | Aleksey Kladov <[email protected]> | 2020-06-23 23:30:34 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-06-23 23:30:34 +0100 |
commit | e5101ae150db5faa7ddf8393e375032ef371f5e5 (patch) | |
tree | 89f9a2cc1c4113222bbb3e1241e68c712c2a21fb /crates/ra_assists/src/handlers | |
parent | 44cf263edf1c7e3b189ef5f1cfdf207dd28a0054 (diff) |
Centralize fixture parsing for assists
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r-- | crates/ra_assists/src/handlers/add_function.rs | 1 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/fill_match_arms.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/introduce_variable.rs | 20 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/raw_string.rs | 48 |
4 files changed, 40 insertions, 35 deletions
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() { | |||
986 | ", | 986 | ", |
987 | r" | 987 | r" |
988 | 988 | ||
989 | |||
989 | pub(crate) fn bar() { | 990 | pub(crate) fn bar() { |
990 | ${0:todo!()} | 991 | ${0:todo!()} |
991 | }", | 992 | }", |
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 { | |||
763 | fn foo(opt: Option<i32>) { | 763 | fn foo(opt: Option<i32>) { |
764 | match opt<|> { | 764 | match opt<|> { |
765 | } | 765 | } |
766 | }"#; | 766 | } |
767 | let before = | 767 | "#; |
768 | &format!("//- /main.rs crate:main deps:core\n{}{}", before, FamousDefs::FIXTURE); | 768 | let before = &format!("//- /main.rs crate:main deps:core{}{}", before, FamousDefs::FIXTURE); |
769 | 769 | ||
770 | check_assist( | 770 | check_assist( |
771 | fill_match_arms, | 771 | 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() { | |||
226 | mark::check!(test_introduce_var_last_expr); | 226 | mark::check!(test_introduce_var_last_expr); |
227 | check_assist( | 227 | check_assist( |
228 | introduce_variable, | 228 | introduce_variable, |
229 | " | 229 | r#" |
230 | fn foo() { | 230 | fn foo() { |
231 | bar(<|>1 + 1<|>) | 231 | bar(<|>1 + 1<|>) |
232 | }", | 232 | } |
233 | " | 233 | "#, |
234 | r#" | ||
234 | fn foo() { | 235 | fn foo() { |
235 | let $0var_name = 1 + 1; | 236 | let $0var_name = 1 + 1; |
236 | bar(var_name) | 237 | bar(var_name) |
237 | }", | 238 | } |
239 | "#, | ||
238 | ); | 240 | ); |
239 | check_assist( | 241 | check_assist( |
240 | introduce_variable, | 242 | introduce_variable, |
241 | " | 243 | r#" |
242 | fn foo() { | 244 | fn foo() { |
243 | <|>bar(1 + 1)<|> | 245 | <|>bar(1 + 1)<|> |
244 | }", | 246 | } |
245 | " | 247 | "#, |
248 | r#" | ||
246 | fn foo() { | 249 | fn foo() { |
247 | let $0var_name = bar(1 + 1); | 250 | let $0var_name = bar(1 + 1); |
248 | var_name | 251 | var_name |
249 | }", | 252 | } |
253 | "#, | ||
250 | ) | 254 | ) |
251 | } | 255 | } |
252 | 256 | ||
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 { | |||
158 | check_assist( | 158 | check_assist( |
159 | make_raw_string, | 159 | make_raw_string, |
160 | r#" | 160 | r#" |
161 | fn f() { | 161 | fn f() { |
162 | let s = <|>"random\nstring"; | 162 | let s = <|>"random\nstring"; |
163 | } | 163 | } |
164 | "#, | 164 | "#, |
165 | r##" | 165 | r##" |
166 | fn f() { | 166 | fn f() { |
167 | let s = r#"random | 167 | let s = r#"random |
168 | string"#; | 168 | string"#; |
169 | } | 169 | } |
170 | "##, | 170 | "##, |
171 | ) | 171 | ) |
172 | } | 172 | } |
173 | 173 | ||
@@ -193,16 +193,16 @@ string"#; | |||
193 | check_assist( | 193 | check_assist( |
194 | make_raw_string, | 194 | make_raw_string, |
195 | r###" | 195 | r###" |
196 | fn f() { | 196 | fn f() { |
197 | let s = <|>"#random##\nstring"; | 197 | let s = <|>"#random##\nstring"; |
198 | } | 198 | } |
199 | "###, | 199 | "###, |
200 | r####" | 200 | r####" |
201 | fn f() { | 201 | fn f() { |
202 | let s = r#"#random## | 202 | let s = r#"#random## |
203 | string"#; | 203 | string"#; |
204 | } | 204 | } |
205 | "####, | 205 | "####, |
206 | ) | 206 | ) |
207 | } | 207 | } |
208 | 208 | ||
@@ -211,16 +211,16 @@ string"#; | |||
211 | check_assist( | 211 | check_assist( |
212 | make_raw_string, | 212 | make_raw_string, |
213 | r###" | 213 | r###" |
214 | fn f() { | 214 | fn f() { |
215 | let s = <|>"#random\"##\nstring"; | 215 | let s = <|>"#random\"##\nstring"; |
216 | } | 216 | } |
217 | "###, | 217 | "###, |
218 | r####" | 218 | r####" |
219 | fn f() { | 219 | fn f() { |
220 | let s = r###"#random"## | 220 | let s = r###"#random"## |
221 | string"###; | 221 | string"###; |
222 | } | 222 | } |
223 | "####, | 223 | "####, |
224 | ) | 224 | ) |
225 | } | 225 | } |
226 | 226 | ||