diff options
Diffstat (limited to 'crates/ra_ide/src/completion/complete_dot.rs')
-rw-r--r-- | crates/ra_ide/src/completion/complete_dot.rs | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index 9145aa183..da2c4c1ab 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs | |||
@@ -584,4 +584,102 @@ mod tests { | |||
584 | "### | 584 | "### |
585 | ); | 585 | ); |
586 | } | 586 | } |
587 | |||
588 | #[test] | ||
589 | fn works_in_simple_macro_1() { | ||
590 | assert_debug_snapshot!( | ||
591 | do_ref_completion( | ||
592 | r" | ||
593 | macro_rules! m { ($e:expr) => { $e } } | ||
594 | struct A { the_field: u32 } | ||
595 | fn foo(a: A) { | ||
596 | m!(a.x<|>) | ||
597 | } | ||
598 | ", | ||
599 | ), | ||
600 | @r###" | ||
601 | [ | ||
602 | CompletionItem { | ||
603 | label: "the_field", | ||
604 | source_range: [156; 157), | ||
605 | delete: [156; 157), | ||
606 | insert: "the_field", | ||
607 | kind: Field, | ||
608 | detail: "u32", | ||
609 | }, | ||
610 | ] | ||
611 | "### | ||
612 | ); | ||
613 | } | ||
614 | |||
615 | #[test] | ||
616 | fn works_in_simple_macro_recursive() { | ||
617 | assert_debug_snapshot!( | ||
618 | do_ref_completion( | ||
619 | r" | ||
620 | macro_rules! m { ($e:expr) => { $e } } | ||
621 | struct A { the_field: u32 } | ||
622 | fn foo(a: A) { | ||
623 | m!(a.x<|>) | ||
624 | } | ||
625 | ", | ||
626 | ), | ||
627 | @r###" | ||
628 | [ | ||
629 | CompletionItem { | ||
630 | label: "the_field", | ||
631 | source_range: [156; 157), | ||
632 | delete: [156; 157), | ||
633 | insert: "the_field", | ||
634 | kind: Field, | ||
635 | detail: "u32", | ||
636 | }, | ||
637 | ] | ||
638 | "### | ||
639 | ); | ||
640 | } | ||
641 | |||
642 | #[test] | ||
643 | fn works_in_simple_macro_2() { | ||
644 | // this doesn't work yet because the macro doesn't expand without the token -- maybe it can be fixed with better recovery | ||
645 | assert_debug_snapshot!( | ||
646 | do_ref_completion( | ||
647 | r" | ||
648 | macro_rules! m { ($e:expr) => { $e } } | ||
649 | struct A { the_field: u32 } | ||
650 | fn foo(a: A) { | ||
651 | m!(a.<|>) | ||
652 | } | ||
653 | ", | ||
654 | ), | ||
655 | @r###"[]"### | ||
656 | ); | ||
657 | } | ||
658 | |||
659 | #[test] | ||
660 | fn works_in_simple_macro_recursive_1() { | ||
661 | assert_debug_snapshot!( | ||
662 | do_ref_completion( | ||
663 | r" | ||
664 | macro_rules! m { ($e:expr) => { $e } } | ||
665 | struct A { the_field: u32 } | ||
666 | fn foo(a: A) { | ||
667 | m!(m!(m!(a.x<|>))) | ||
668 | } | ||
669 | ", | ||
670 | ), | ||
671 | @r###" | ||
672 | [ | ||
673 | CompletionItem { | ||
674 | label: "the_field", | ||
675 | source_range: [162; 163), | ||
676 | delete: [162; 163), | ||
677 | insert: "the_field", | ||
678 | kind: Field, | ||
679 | detail: "u32", | ||
680 | }, | ||
681 | ] | ||
682 | "### | ||
683 | ); | ||
684 | } | ||
587 | } | 685 | } |