aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-08 18:54:50 +0100
committerAleksey Kladov <[email protected]>2020-07-08 19:35:54 +0100
commit7238acab787328e5c1bf9beada140173f34efae0 (patch)
tree5529f61c548bbe4f85dc949cac88f7619a76b61c /crates/ra_ide
parent86aac4303f26281f72fbbacc0aaa8969a13ce7eb (diff)
Dead code
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/hover.rs50
1 files changed, 19 insertions, 31 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 0e9aa44de..96b564a96 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -85,14 +85,6 @@ impl HoverResult {
85 self.results.len() 85 self.results.len()
86 } 86 }
87 87
88 pub fn first(&self) -> Option<&str> {
89 self.results.first().map(String::as_str)
90 }
91
92 pub fn results(&self) -> &[String] {
93 &self.results
94 }
95
96 pub fn actions(&self) -> &[HoverAction] { 88 pub fn actions(&self) -> &[HoverAction] {
97 &self.actions 89 &self.actions
98 } 90 }
@@ -403,10 +395,6 @@ mod tests {
403 s.trim_start_matches("```rust\n").trim_end_matches("\n```") 395 s.trim_start_matches("```rust\n").trim_end_matches("\n```")
404 } 396 }
405 397
406 fn trim_markup_opt(s: Option<&str>) -> Option<&str> {
407 s.map(trim_markup)
408 }
409
410 fn assert_impl_action(action: &HoverAction, position: u32) { 398 fn assert_impl_action(action: &HoverAction, position: u32) {
411 let offset = match action { 399 let offset = match action {
412 HoverAction::Implementaion(pos) => pos.offset, 400 HoverAction::Implementaion(pos) => pos.offset,
@@ -418,7 +406,7 @@ mod tests {
418 fn check_hover_result(ra_fixture: &str, expected: &[&str]) -> (String, Vec<HoverAction>) { 406 fn check_hover_result(ra_fixture: &str, expected: &[&str]) -> (String, Vec<HoverAction>) {
419 let (analysis, position) = analysis_and_position(ra_fixture); 407 let (analysis, position) = analysis_and_position(ra_fixture);
420 let hover = analysis.hover(position).unwrap().unwrap(); 408 let hover = analysis.hover(position).unwrap().unwrap();
421 let mut results = Vec::from(hover.info.results()); 409 let mut results = hover.info.results.clone();
422 results.sort(); 410 results.sort();
423 411
424 for (markup, expected) in 412 for (markup, expected) in
@@ -451,7 +439,7 @@ fn main() {
451 ); 439 );
452 let hover = analysis.hover(position).unwrap().unwrap(); 440 let hover = analysis.hover(position).unwrap().unwrap();
453 assert_eq!(hover.range, TextRange::new(58.into(), 63.into())); 441 assert_eq!(hover.range, TextRange::new(58.into(), 63.into()));
454 assert_eq!(trim_markup_opt(hover.info.first()), Some("u32")); 442 assert_eq!(trim_markup(&hover.info.results[0]), ("u32"));
455 } 443 }
456 444
457 #[test] 445 #[test]
@@ -650,7 +638,7 @@ fn main() {
650 ", 638 ",
651 ); 639 );
652 let hover = analysis.hover(position).unwrap().unwrap(); 640 let hover = analysis.hover(position).unwrap().unwrap();
653 assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n```\n\n```rust\nSome")); 641 assert_eq!(trim_markup(&hover.info.results[0]), ("Option\n```\n\n```rust\nSome"));
654 642
655 let (analysis, position) = analysis_and_position( 643 let (analysis, position) = analysis_and_position(
656 " 644 "
@@ -663,7 +651,7 @@ fn main() {
663 ", 651 ",
664 ); 652 );
665 let hover = analysis.hover(position).unwrap().unwrap(); 653 let hover = analysis.hover(position).unwrap().unwrap();
666 assert_eq!(trim_markup_opt(hover.info.first()), Some("Option<i32>")); 654 assert_eq!(trim_markup(&hover.info.results[0]), ("Option<i32>"));
667 } 655 }
668 656
669 #[test] 657 #[test]
@@ -720,14 +708,14 @@ The Some variant
720 fn hover_for_local_variable() { 708 fn hover_for_local_variable() {
721 let (analysis, position) = analysis_and_position("fn func(foo: i32) { fo<|>o; }"); 709 let (analysis, position) = analysis_and_position("fn func(foo: i32) { fo<|>o; }");
722 let hover = analysis.hover(position).unwrap().unwrap(); 710 let hover = analysis.hover(position).unwrap().unwrap();
723 assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); 711 assert_eq!(trim_markup(&hover.info.results[0]), "i32");
724 } 712 }
725 713
726 #[test] 714 #[test]
727 fn hover_for_local_variable_pat() { 715 fn hover_for_local_variable_pat() {
728 let (analysis, position) = analysis_and_position("fn func(fo<|>o: i32) {}"); 716 let (analysis, position) = analysis_and_position("fn func(fo<|>o: i32) {}");
729 let hover = analysis.hover(position).unwrap().unwrap(); 717 let hover = analysis.hover(position).unwrap().unwrap();
730 assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); 718 assert_eq!(trim_markup(&hover.info.results[0]), "i32");
731 } 719 }
732 720
733 #[test] 721 #[test]
@@ -738,14 +726,14 @@ fn func(foo: i32) { if true { <|>foo; }; }
738", 726",
739 ); 727 );
740 let hover = analysis.hover(position).unwrap().unwrap(); 728 let hover = analysis.hover(position).unwrap().unwrap();
741 assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); 729 assert_eq!(trim_markup(&hover.info.results[0]), "i32");
742 } 730 }
743 731
744 #[test] 732 #[test]
745 fn hover_for_param_edge() { 733 fn hover_for_param_edge() {
746 let (analysis, position) = analysis_and_position("fn func(<|>foo: i32) {}"); 734 let (analysis, position) = analysis_and_position("fn func(<|>foo: i32) {}");
747 let hover = analysis.hover(position).unwrap().unwrap(); 735 let hover = analysis.hover(position).unwrap().unwrap();
748 assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); 736 assert_eq!(trim_markup(&hover.info.results[0]), "i32");
749 } 737 }
750 738
751 #[test] 739 #[test]
@@ -766,7 +754,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
766 ", 754 ",
767 ); 755 );
768 let hover = analysis.hover(position).unwrap().unwrap(); 756 let hover = analysis.hover(position).unwrap().unwrap();
769 assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); 757 assert_eq!(trim_markup(&hover.info.results[0]), ("Thing"));
770 } 758 }
771 759
772 #[test] 760 #[test]
@@ -790,8 +778,8 @@ fn func(foo: i32) { if true { <|>foo; }; }
790 ); 778 );
791 let hover = analysis.hover(position).unwrap().unwrap(); 779 let hover = analysis.hover(position).unwrap().unwrap();
792 assert_eq!( 780 assert_eq!(
793 trim_markup_opt(hover.info.first()), 781 trim_markup(&hover.info.results[0]),
794 Some("wrapper::Thing\n```\n\n```rust\nfn new() -> Thing") 782 ("wrapper::Thing\n```\n\n```rust\nfn new() -> Thing")
795 ); 783 );
796 } 784 }
797 785
@@ -814,7 +802,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
814 ", 802 ",
815 ); 803 );
816 let hover = analysis.hover(position).unwrap().unwrap(); 804 let hover = analysis.hover(position).unwrap().unwrap();
817 assert_eq!(trim_markup_opt(hover.info.first()), Some("const C: u32")); 805 assert_eq!(trim_markup(&hover.info.results[0]), ("const C: u32"));
818 } 806 }
819 807
820 #[test] 808 #[test]
@@ -830,7 +818,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
830 ", 818 ",
831 ); 819 );
832 let hover = analysis.hover(position).unwrap().unwrap(); 820 let hover = analysis.hover(position).unwrap().unwrap();
833 assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); 821 assert_eq!(trim_markup(&hover.info.results[0]), ("Thing"));
834 822
835 /* FIXME: revive these tests 823 /* FIXME: revive these tests
836 let (analysis, position) = analysis_and_position( 824 let (analysis, position) = analysis_and_position(
@@ -845,7 +833,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
845 ); 833 );
846 834
847 let hover = analysis.hover(position).unwrap().unwrap(); 835 let hover = analysis.hover(position).unwrap().unwrap();
848 assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); 836 assert_eq!(trim_markup(&hover.info.results[0]), ("Thing"));
849 837
850 let (analysis, position) = analysis_and_position( 838 let (analysis, position) = analysis_and_position(
851 " 839 "
@@ -858,7 +846,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
858 ", 846 ",
859 ); 847 );
860 let hover = analysis.hover(position).unwrap().unwrap(); 848 let hover = analysis.hover(position).unwrap().unwrap();
861 assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing")); 849 assert_eq!(trim_markup(&hover.info.results[0]), ("enum Thing"));
862 850
863 let (analysis, position) = analysis_and_position( 851 let (analysis, position) = analysis_and_position(
864 " 852 "
@@ -870,7 +858,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
870 ", 858 ",
871 ); 859 );
872 let hover = analysis.hover(position).unwrap().unwrap(); 860 let hover = analysis.hover(position).unwrap().unwrap();
873 assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing")); 861 assert_eq!(trim_markup(&hover.info.results[0]), ("enum Thing"));
874 */ 862 */
875 } 863 }
876 864
@@ -887,7 +875,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
887 ", 875 ",
888 ); 876 );
889 let hover = analysis.hover(position).unwrap().unwrap(); 877 let hover = analysis.hover(position).unwrap().unwrap();
890 assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); 878 assert_eq!(trim_markup(&hover.info.results[0]), "i32");
891 } 879 }
892 880
893 #[test] 881 #[test]
@@ -904,7 +892,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
904 ", 892 ",
905 ); 893 );
906 let hover = analysis.hover(position).unwrap().unwrap(); 894 let hover = analysis.hover(position).unwrap().unwrap();
907 assert_eq!(trim_markup_opt(hover.info.first()), Some("macro_rules! foo")); 895 assert_eq!(trim_markup(&hover.info.results[0]), ("macro_rules! foo"));
908 } 896 }
909 897
910 #[test] 898 #[test]
@@ -915,7 +903,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
915 ", 903 ",
916 ); 904 );
917 let hover = analysis.hover(position).unwrap().unwrap(); 905 let hover = analysis.hover(position).unwrap().unwrap();
918 assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); 906 assert_eq!(trim_markup(&hover.info.results[0]), "i32");
919 } 907 }
920 908
921 #[test] 909 #[test]