diff options
Diffstat (limited to 'crates/ra_ide/src/hover.rs')
-rw-r--r-- | crates/ra_ide/src/hover.rs | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a898f2e4a..c3e36a387 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -399,7 +399,7 @@ mod tests { | |||
399 | use ra_db::FileLoader; | 399 | use ra_db::FileLoader; |
400 | use ra_syntax::TextRange; | 400 | use ra_syntax::TextRange; |
401 | 401 | ||
402 | use crate::mock_analysis::{analysis_and_position, single_file_with_position}; | 402 | use crate::mock_analysis::analysis_and_position; |
403 | 403 | ||
404 | fn trim_markup(s: &str) -> &str { | 404 | fn trim_markup(s: &str) -> &str { |
405 | s.trim_start_matches("```rust\n").trim_end_matches("\n```") | 405 | s.trim_start_matches("```rust\n").trim_end_matches("\n```") |
@@ -442,17 +442,17 @@ mod tests { | |||
442 | 442 | ||
443 | #[test] | 443 | #[test] |
444 | fn hover_shows_type_of_an_expression() { | 444 | fn hover_shows_type_of_an_expression() { |
445 | let (analysis, position) = single_file_with_position( | 445 | let (analysis, position) = analysis_and_position( |
446 | " | 446 | r#" |
447 | pub fn foo() -> u32 { 1 } | 447 | pub fn foo() -> u32 { 1 } |
448 | 448 | ||
449 | fn main() { | 449 | fn main() { |
450 | let foo_test = foo()<|>; | 450 | let foo_test = foo()<|>; |
451 | } | 451 | } |
452 | ", | 452 | "#, |
453 | ); | 453 | ); |
454 | let hover = analysis.hover(position).unwrap().unwrap(); | 454 | let hover = analysis.hover(position).unwrap().unwrap(); |
455 | assert_eq!(hover.range, TextRange::new(95.into(), 100.into())); | 455 | assert_eq!(hover.range, TextRange::new(58.into(), 63.into())); |
456 | assert_eq!(trim_markup_opt(hover.info.first()), Some("u32")); | 456 | assert_eq!(trim_markup_opt(hover.info.first()), Some("u32")); |
457 | } | 457 | } |
458 | 458 | ||
@@ -641,7 +641,7 @@ fn main() { | |||
641 | 641 | ||
642 | #[test] | 642 | #[test] |
643 | fn hover_some() { | 643 | fn hover_some() { |
644 | let (analysis, position) = single_file_with_position( | 644 | let (analysis, position) = analysis_and_position( |
645 | " | 645 | " |
646 | enum Option<T> { Some(T) } | 646 | enum Option<T> { Some(T) } |
647 | use Option::Some; | 647 | use Option::Some; |
@@ -654,7 +654,7 @@ fn main() { | |||
654 | let hover = analysis.hover(position).unwrap().unwrap(); | 654 | let hover = analysis.hover(position).unwrap().unwrap(); |
655 | assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n```\n\n```rust\nSome")); | 655 | assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n```\n\n```rust\nSome")); |
656 | 656 | ||
657 | let (analysis, position) = single_file_with_position( | 657 | let (analysis, position) = analysis_and_position( |
658 | " | 658 | " |
659 | enum Option<T> { Some(T) } | 659 | enum Option<T> { Some(T) } |
660 | use Option::Some; | 660 | use Option::Some; |
@@ -720,21 +720,21 @@ The Some variant | |||
720 | 720 | ||
721 | #[test] | 721 | #[test] |
722 | fn hover_for_local_variable() { | 722 | fn hover_for_local_variable() { |
723 | let (analysis, position) = single_file_with_position("fn func(foo: i32) { fo<|>o; }"); | 723 | let (analysis, position) = analysis_and_position("fn func(foo: i32) { fo<|>o; }"); |
724 | let hover = analysis.hover(position).unwrap().unwrap(); | 724 | let hover = analysis.hover(position).unwrap().unwrap(); |
725 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); | 725 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); |
726 | } | 726 | } |
727 | 727 | ||
728 | #[test] | 728 | #[test] |
729 | fn hover_for_local_variable_pat() { | 729 | fn hover_for_local_variable_pat() { |
730 | let (analysis, position) = single_file_with_position("fn func(fo<|>o: i32) {}"); | 730 | let (analysis, position) = analysis_and_position("fn func(fo<|>o: i32) {}"); |
731 | let hover = analysis.hover(position).unwrap().unwrap(); | 731 | let hover = analysis.hover(position).unwrap().unwrap(); |
732 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); | 732 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); |
733 | } | 733 | } |
734 | 734 | ||
735 | #[test] | 735 | #[test] |
736 | fn hover_local_var_edge() { | 736 | fn hover_local_var_edge() { |
737 | let (analysis, position) = single_file_with_position( | 737 | let (analysis, position) = analysis_and_position( |
738 | " | 738 | " |
739 | fn func(foo: i32) { if true { <|>foo; }; } | 739 | fn func(foo: i32) { if true { <|>foo; }; } |
740 | ", | 740 | ", |
@@ -745,14 +745,14 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
745 | 745 | ||
746 | #[test] | 746 | #[test] |
747 | fn hover_for_param_edge() { | 747 | fn hover_for_param_edge() { |
748 | let (analysis, position) = single_file_with_position("fn func(<|>foo: i32) {}"); | 748 | let (analysis, position) = analysis_and_position("fn func(<|>foo: i32) {}"); |
749 | let hover = analysis.hover(position).unwrap().unwrap(); | 749 | let hover = analysis.hover(position).unwrap().unwrap(); |
750 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); | 750 | assert_eq!(trim_markup_opt(hover.info.first()), Some("i32")); |
751 | } | 751 | } |
752 | 752 | ||
753 | #[test] | 753 | #[test] |
754 | fn test_hover_infer_associated_method_result() { | 754 | fn test_hover_infer_associated_method_result() { |
755 | let (analysis, position) = single_file_with_position( | 755 | let (analysis, position) = analysis_and_position( |
756 | " | 756 | " |
757 | struct Thing { x: u32 } | 757 | struct Thing { x: u32 } |
758 | 758 | ||
@@ -773,7 +773,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
773 | 773 | ||
774 | #[test] | 774 | #[test] |
775 | fn test_hover_infer_associated_method_exact() { | 775 | fn test_hover_infer_associated_method_exact() { |
776 | let (analysis, position) = single_file_with_position( | 776 | let (analysis, position) = analysis_and_position( |
777 | " | 777 | " |
778 | mod wrapper { | 778 | mod wrapper { |
779 | struct Thing { x: u32 } | 779 | struct Thing { x: u32 } |
@@ -799,7 +799,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
799 | 799 | ||
800 | #[test] | 800 | #[test] |
801 | fn test_hover_infer_associated_const_in_pattern() { | 801 | fn test_hover_infer_associated_const_in_pattern() { |
802 | let (analysis, position) = single_file_with_position( | 802 | let (analysis, position) = analysis_and_position( |
803 | " | 803 | " |
804 | struct X; | 804 | struct X; |
805 | impl X { | 805 | impl X { |
@@ -821,7 +821,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
821 | 821 | ||
822 | #[test] | 822 | #[test] |
823 | fn test_hover_self() { | 823 | fn test_hover_self() { |
824 | let (analysis, position) = single_file_with_position( | 824 | let (analysis, position) = analysis_and_position( |
825 | " | 825 | " |
826 | struct Thing { x: u32 } | 826 | struct Thing { x: u32 } |
827 | impl Thing { | 827 | impl Thing { |
@@ -835,7 +835,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
835 | assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); | 835 | assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); |
836 | 836 | ||
837 | /* FIXME: revive these tests | 837 | /* FIXME: revive these tests |
838 | let (analysis, position) = single_file_with_position( | 838 | let (analysis, position) = analysis_and_position( |
839 | " | 839 | " |
840 | struct Thing { x: u32 } | 840 | struct Thing { x: u32 } |
841 | impl Thing { | 841 | impl Thing { |
@@ -849,7 +849,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
849 | let hover = analysis.hover(position).unwrap().unwrap(); | 849 | let hover = analysis.hover(position).unwrap().unwrap(); |
850 | assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); | 850 | assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing")); |
851 | 851 | ||
852 | let (analysis, position) = single_file_with_position( | 852 | let (analysis, position) = analysis_and_position( |
853 | " | 853 | " |
854 | enum Thing { A } | 854 | enum Thing { A } |
855 | impl Thing { | 855 | impl Thing { |
@@ -862,7 +862,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
862 | let hover = analysis.hover(position).unwrap().unwrap(); | 862 | let hover = analysis.hover(position).unwrap().unwrap(); |
863 | assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing")); | 863 | assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing")); |
864 | 864 | ||
865 | let (analysis, position) = single_file_with_position( | 865 | let (analysis, position) = analysis_and_position( |
866 | " | 866 | " |
867 | enum Thing { A } | 867 | enum Thing { A } |
868 | impl Thing { | 868 | impl Thing { |
@@ -878,7 +878,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
878 | 878 | ||
879 | #[test] | 879 | #[test] |
880 | fn test_hover_shadowing_pat() { | 880 | fn test_hover_shadowing_pat() { |
881 | let (analysis, position) = single_file_with_position( | 881 | let (analysis, position) = analysis_and_position( |
882 | " | 882 | " |
883 | fn x() {} | 883 | fn x() {} |
884 | 884 | ||
@@ -894,7 +894,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
894 | 894 | ||
895 | #[test] | 895 | #[test] |
896 | fn test_hover_macro_invocation() { | 896 | fn test_hover_macro_invocation() { |
897 | let (analysis, position) = single_file_with_position( | 897 | let (analysis, position) = analysis_and_position( |
898 | " | 898 | " |
899 | macro_rules! foo { | 899 | macro_rules! foo { |
900 | () => {} | 900 | () => {} |
@@ -911,7 +911,7 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
911 | 911 | ||
912 | #[test] | 912 | #[test] |
913 | fn test_hover_tuple_field() { | 913 | fn test_hover_tuple_field() { |
914 | let (analysis, position) = single_file_with_position( | 914 | let (analysis, position) = analysis_and_position( |
915 | " | 915 | " |
916 | struct TS(String, i32<|>); | 916 | struct TS(String, i32<|>); |
917 | ", | 917 | ", |