aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs180
1 files changed, 0 insertions, 180 deletions
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 78c6195d7..ad3476310 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -715,183 +715,3 @@ pub fn foo(_input: TokenStream) -> TokenStream {
715 let value = res.get("contents").unwrap().get("value").unwrap().to_string(); 715 let value = res.get("contents").unwrap().get("value").unwrap().to_string();
716 assert_eq!(value, r#""```rust\nfoo::Bar\n```\n\n```rust\nfn bar()\n```""#) 716 assert_eq!(value, r#""```rust\nfoo::Bar\n```\n\n```rust\nfn bar()\n```""#)
717} 717}
718
719#[test]
720fn test_client_support_hover_actions() {
721 if skip_slow_tests() {
722 return;
723 }
724
725 let server = Project::with_fixture(
726 r#"
727//- Cargo.toml
728[package]
729name = "foo"
730version = "0.0.0"
731
732//- src/lib.rs
733struct Foo(u32);
734
735struct NoImpl(u32);
736
737impl Foo {
738 fn new() -> Self {
739 Self(1)
740 }
741}
742"#,
743 )
744 .with_config(|config| {
745 config.client_caps.hover_actions = true;
746 })
747 .server();
748
749 server.wait_until_workspace_is_loaded();
750
751 // has 1 implementation
752 server.request::<HoverRequest>(
753 HoverParams {
754 text_document_position_params: TextDocumentPositionParams::new(
755 server.doc_id("src/lib.rs"),
756 Position::new(0, 9),
757 ),
758 work_done_progress_params: Default::default(),
759 },
760 json!({
761 "actions": [{
762 "commands": [{
763 "arguments": [
764 "file:///[..]src/lib.rs",
765 {
766 "character": 7,
767 "line": 0
768 },
769 [{
770 "range": { "end": { "character": 1, "line": 8 }, "start": { "character": 0, "line": 4 } },
771 "uri": "file:///[..]src/lib.rs"
772 }]
773 ],
774 "command": "rust-analyzer.showReferences",
775 "title": "1 implementation",
776 "tooltip": "Go to implementations"
777 }]
778 }],
779 "contents": { "kind": "markdown", "value": "```rust\nfoo\n```\n\n```rust\nstruct Foo\n```" },
780 "range": { "end": { "character": 10, "line": 0 }, "start": { "character": 7, "line": 0 } }
781 })
782 );
783
784 // no hover
785 server.request::<HoverRequest>(
786 HoverParams {
787 text_document_position_params: TextDocumentPositionParams::new(
788 server.doc_id("src/lib.rs"),
789 Position::new(1, 0),
790 ),
791 work_done_progress_params: Default::default(),
792 },
793 json!(null),
794 );
795
796 // no implementations
797 server.request::<HoverRequest>(
798 HoverParams {
799 text_document_position_params: TextDocumentPositionParams::new(
800 server.doc_id("src/lib.rs"),
801 Position::new(2, 12),
802 ),
803 work_done_progress_params: Default::default(),
804 },
805 json!({
806 "actions": [{
807 "commands": [{
808 "arguments": [
809 "file:///[..]src/lib.rs",
810 { "character": 7, "line": 2 },
811 []
812 ],
813 "command": "rust-analyzer.showReferences",
814 "title": "0 implementations",
815 "tooltip": "Go to implementations"
816 }]
817 }],
818 "contents": { "kind": "markdown", "value": "```rust\nfoo\n```\n\n```rust\nstruct NoImpl\n```" },
819 "range": { "end": { "character": 13, "line": 2 }, "start": { "character": 7, "line": 2 } }
820 })
821 );
822}
823
824#[test]
825fn test_client_does_not_support_hover_actions() {
826 if skip_slow_tests() {
827 return;
828 }
829
830 let server = Project::with_fixture(
831 r#"
832//- Cargo.toml
833[package]
834name = "foo"
835version = "0.0.0"
836
837//- src/lib.rs
838struct Foo(u32);
839
840struct NoImpl(u32);
841
842impl Foo {
843 fn new() -> Self {
844 Self(1)
845 }
846}
847"#,
848 )
849 .with_config(|config| {
850 config.client_caps.hover_actions = false;
851 })
852 .server();
853
854 server.wait_until_workspace_is_loaded();
855
856 // has 1 implementation
857 server.request::<HoverRequest>(
858 HoverParams {
859 text_document_position_params: TextDocumentPositionParams::new(
860 server.doc_id("src/lib.rs"),
861 Position::new(0, 9),
862 ),
863 work_done_progress_params: Default::default(),
864 },
865 json!({
866 "contents": { "kind": "markdown", "value": "```rust\nfoo\n```\n\n```rust\nstruct Foo\n```" },
867 "range": { "end": { "character": 10, "line": 0 }, "start": { "character": 7, "line": 0 } }
868 })
869 );
870
871 // no hover
872 server.request::<HoverRequest>(
873 HoverParams {
874 text_document_position_params: TextDocumentPositionParams::new(
875 server.doc_id("src/lib.rs"),
876 Position::new(1, 0),
877 ),
878 work_done_progress_params: Default::default(),
879 },
880 json!(null),
881 );
882
883 // no implementations
884 server.request::<HoverRequest>(
885 HoverParams {
886 text_document_position_params: TextDocumentPositionParams::new(
887 server.doc_id("src/lib.rs"),
888 Position::new(2, 12),
889 ),
890 work_done_progress_params: Default::default(),
891 },
892 json!({
893 "contents": { "kind": "markdown", "value": "```rust\nfoo\n```\n\n```rust\nstruct NoImpl\n```" },
894 "range": { "end": { "character": 13, "line": 2 }, "start": { "character": 7, "line": 2 } }
895 })
896 );
897}