aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/handlers/extract_variable.rs
diff options
context:
space:
mode:
authorKevaundray Wedderburn <[email protected]>2021-01-06 20:15:48 +0000
committerKevaundray Wedderburn <[email protected]>2021-01-07 12:09:23 +0000
commit72b9a4fbd3c12f3250b9157a1d44230e04ec8b22 (patch)
treec138363e3592c690d841aeedb9ac97d6b2ff4396 /crates/assists/src/handlers/extract_variable.rs
parent171c3c08fe245938fb25321394233de5fe2abc7c (diff)
Change <|> to $0 - Rebase
Diffstat (limited to 'crates/assists/src/handlers/extract_variable.rs')
-rw-r--r--crates/assists/src/handlers/extract_variable.rs50
1 files changed, 25 insertions, 25 deletions
diff --git a/crates/assists/src/handlers/extract_variable.rs b/crates/assists/src/handlers/extract_variable.rs
index 291809205..98f3dc6ca 100644
--- a/crates/assists/src/handlers/extract_variable.rs
+++ b/crates/assists/src/handlers/extract_variable.rs
@@ -16,7 +16,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
16// 16//
17// ``` 17// ```
18// fn main() { 18// fn main() {
19// <|>(1 + 2)<|> * 4; 19// $0(1 + 2)$0 * 4;
20// } 20// }
21// ``` 21// ```
22// -> 22// ->
@@ -187,7 +187,7 @@ mod tests {
187 extract_variable, 187 extract_variable,
188 r#" 188 r#"
189fn foo() { 189fn foo() {
190 foo(<|>1 + 1<|>); 190 foo($01 + 1$0);
191}"#, 191}"#,
192 r#" 192 r#"
193fn foo() { 193fn foo() {
@@ -200,7 +200,7 @@ fn foo() {
200 #[test] 200 #[test]
201 fn extract_var_in_comment_is_not_applicable() { 201 fn extract_var_in_comment_is_not_applicable() {
202 mark::check!(extract_var_in_comment_is_not_applicable); 202 mark::check!(extract_var_in_comment_is_not_applicable);
203 check_assist_not_applicable(extract_variable, "fn main() { 1 + /* <|>comment<|> */ 1; }"); 203 check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }");
204 } 204 }
205 205
206 #[test] 206 #[test]
@@ -210,7 +210,7 @@ fn foo() {
210 extract_variable, 210 extract_variable,
211 r#" 211 r#"
212fn foo() { 212fn foo() {
213 <|>1 + 1<|>; 213 $01 + 1$0;
214}"#, 214}"#,
215 r#" 215 r#"
216fn foo() { 216fn foo() {
@@ -221,7 +221,7 @@ fn foo() {
221 extract_variable, 221 extract_variable,
222 " 222 "
223fn foo() { 223fn foo() {
224 <|>{ let x = 0; x }<|> 224 $0{ let x = 0; x }$0
225 something_else(); 225 something_else();
226}", 226}",
227 " 227 "
@@ -238,7 +238,7 @@ fn foo() {
238 extract_variable, 238 extract_variable,
239 " 239 "
240fn foo() { 240fn foo() {
241 <|>1<|> + 1; 241 $01$0 + 1;
242}", 242}",
243 " 243 "
244fn foo() { 244fn foo() {
@@ -255,7 +255,7 @@ fn foo() {
255 extract_variable, 255 extract_variable,
256 r#" 256 r#"
257fn foo() { 257fn foo() {
258 bar(<|>1 + 1<|>) 258 bar($01 + 1$0)
259} 259}
260"#, 260"#,
261 r#" 261 r#"
@@ -269,7 +269,7 @@ fn foo() {
269 extract_variable, 269 extract_variable,
270 r#" 270 r#"
271fn foo() { 271fn foo() {
272 <|>bar(1 + 1)<|> 272 $0bar(1 + 1)$0
273} 273}
274"#, 274"#,
275 r#" 275 r#"
@@ -289,7 +289,7 @@ fn foo() {
289fn main() { 289fn main() {
290 let x = true; 290 let x = true;
291 let tuple = match x { 291 let tuple = match x {
292 true => (<|>2 + 2<|>, true) 292 true => ($02 + 2$0, true)
293 _ => (0, false) 293 _ => (0, false)
294 }; 294 };
295} 295}
@@ -316,7 +316,7 @@ fn main() {
316 let tuple = match x { 316 let tuple = match x {
317 true => { 317 true => {
318 let y = 1; 318 let y = 1;
319 (<|>2 + y<|>, true) 319 ($02 + y$0, true)
320 } 320 }
321 _ => (0, false) 321 _ => (0, false)
322 }; 322 };
@@ -344,7 +344,7 @@ fn main() {
344 extract_variable, 344 extract_variable,
345 " 345 "
346fn main() { 346fn main() {
347 let lambda = |x: u32| <|>x * 2<|>; 347 let lambda = |x: u32| $0x * 2$0;
348} 348}
349", 349",
350 " 350 "
@@ -361,7 +361,7 @@ fn main() {
361 extract_variable, 361 extract_variable,
362 " 362 "
363fn main() { 363fn main() {
364 let lambda = |x: u32| { <|>x * 2<|> }; 364 let lambda = |x: u32| { $0x * 2$0 };
365} 365}
366", 366",
367 " 367 "
@@ -378,7 +378,7 @@ fn main() {
378 extract_variable, 378 extract_variable,
379 " 379 "
380fn main() { 380fn main() {
381 let o = <|>Some(true)<|>; 381 let o = $0Some(true)$0;
382} 382}
383", 383",
384 " 384 "
@@ -396,7 +396,7 @@ fn main() {
396 extract_variable, 396 extract_variable,
397 " 397 "
398fn main() { 398fn main() {
399 let v = <|>bar.foo()<|>; 399 let v = $0bar.foo()$0;
400} 400}
401", 401",
402 " 402 "
@@ -414,7 +414,7 @@ fn main() {
414 extract_variable, 414 extract_variable,
415 " 415 "
416fn foo() -> u32 { 416fn foo() -> u32 {
417 <|>return 2 + 2<|>; 417 $0return 2 + 2$0;
418} 418}
419", 419",
420 " 420 "
@@ -434,7 +434,7 @@ fn foo() -> u32 {
434fn foo() -> u32 { 434fn foo() -> u32 {
435 435
436 436
437 <|>return 2 + 2<|>; 437 $0return 2 + 2$0;
438} 438}
439", 439",
440 " 440 "
@@ -452,7 +452,7 @@ fn foo() -> u32 {
452 " 452 "
453fn foo() -> u32 { 453fn foo() -> u32 {
454 454
455 <|>return 2 + 2<|>; 455 $0return 2 + 2$0;
456} 456}
457", 457",
458 " 458 "
@@ -473,7 +473,7 @@ fn foo() -> u32 {
473 // bar 473 // bar
474 474
475 475
476 <|>return 2 + 2<|>; 476 $0return 2 + 2$0;
477} 477}
478", 478",
479 " 479 "
@@ -497,7 +497,7 @@ fn foo() -> u32 {
497 " 497 "
498fn main() { 498fn main() {
499 let result = loop { 499 let result = loop {
500 <|>break 2 + 2<|>; 500 $0break 2 + 2$0;
501 }; 501 };
502} 502}
503", 503",
@@ -518,7 +518,7 @@ fn main() {
518 extract_variable, 518 extract_variable,
519 " 519 "
520fn main() { 520fn main() {
521 let v = <|>0f32 as u32<|>; 521 let v = $00f32 as u32$0;
522} 522}
523", 523",
524 " 524 "
@@ -540,7 +540,7 @@ struct S {
540} 540}
541 541
542fn main() { 542fn main() {
543 S { foo: <|>1 + 1<|> } 543 S { foo: $01 + 1$0 }
544} 544}
545"#, 545"#,
546 r#" 546 r#"
@@ -558,18 +558,18 @@ fn main() {
558 558
559 #[test] 559 #[test]
560 fn test_extract_var_for_return_not_applicable() { 560 fn test_extract_var_for_return_not_applicable() {
561 check_assist_not_applicable(extract_variable, "fn foo() { <|>return<|>; } "); 561 check_assist_not_applicable(extract_variable, "fn foo() { $0return$0; } ");
562 } 562 }
563 563
564 #[test] 564 #[test]
565 fn test_extract_var_for_break_not_applicable() { 565 fn test_extract_var_for_break_not_applicable() {
566 check_assist_not_applicable(extract_variable, "fn main() { loop { <|>break<|>; }; }"); 566 check_assist_not_applicable(extract_variable, "fn main() { loop { $0break$0; }; }");
567 } 567 }
568 568
569 // FIXME: This is not quite correct, but good enough(tm) for the sorting heuristic 569 // FIXME: This is not quite correct, but good enough(tm) for the sorting heuristic
570 #[test] 570 #[test]
571 fn extract_var_target() { 571 fn extract_var_target() {
572 check_assist_target(extract_variable, "fn foo() -> u32 { <|>return 2 + 2<|>; }", "2 + 2"); 572 check_assist_target(extract_variable, "fn foo() -> u32 { $0return 2 + 2$0; }", "2 + 2");
573 573
574 check_assist_target( 574 check_assist_target(
575 extract_variable, 575 extract_variable,
@@ -577,7 +577,7 @@ fn main() {
577fn main() { 577fn main() {
578 let x = true; 578 let x = true;
579 let tuple = match x { 579 let tuple = match x {
580 true => (<|>2 + 2<|>, true) 580 true => ($02 + 2$0, true)
581 _ => (0, false) 581 _ => (0, false)
582 }; 582 };
583} 583}