From d4e75312ba64c2541e0d97b9ad8d6e2a735882a4 Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 10 Jun 2020 22:58:25 +0300 Subject: Add associated type test. --- .vscode/launch.json | 8 ++++++- Cargo.toml | 2 +- crates/ra_ide/src/hover.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8ca27d878..7a2c033cb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -120,6 +120,12 @@ "sourceMaps": true, "outFiles": [ "${workspaceFolder}/editors/code/out/tests/unit/**/*.js" ], "preLaunchTask": "Pretest" - } + }, + { + "name": "(Windows) Attach", + "type": "cppvsdbg", + "request": "attach", + "processId": "${command:pickProcess}" + } ] } diff --git a/Cargo.toml b/Cargo.toml index 5278b5a16..a5f68f7fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "crates/*", "xtask/" ] [profile.dev] # disabling debug info speeds up builds a bunch, # and we don't rely on it for debugging that much. -debug = 0 +debug = 2 [profile.release] incremental = true diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index c4ee2ff79..2a06006e1 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -2080,4 +2080,61 @@ fn func(foo: i32) { if true { <|>foo; }; } ] "###); } + + #[test] + fn test_hover_associated_type_has_goto_type_action() { + let (_, actions) = check_hover_result( + " + //- /main.rs + trait Foo { + type Item; + fn get(self) -> Self::Item {} + } + + struct Bar{} + struct S{} + + impl Foo for S{ + type Item = Bar; + } + + fn test() -> impl Foo { + S{} + } + + fn main() { + let s<|>t = test().get(); + } + ", + &["Foo::Item"], + ); + assert_debug_snapshot!(actions, + @r###" + [ + GoToType( + [ + HoverGotoTypeData { + mod_path: "Foo", + nav: NavigationTarget { + file_id: FileId( + 1, + ), + full_range: 0..62, + name: "Foo", + kind: TRAIT_DEF, + focus_range: Some( + 6..9, + ), + container_name: None, + description: Some( + "trait Foo", + ), + docs: None, + }, + }, + ], + ), + ] + "###); + } } -- cgit v1.2.3