diff options
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r-- | crates/ide/src/hover.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 02a1a5b37..5a497e92d 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -115,10 +115,11 @@ pub(crate) fn hover( | |||
115 | 115 | ||
116 | _ => ast::Comment::cast(token.clone()) | 116 | _ => ast::Comment::cast(token.clone()) |
117 | .and_then(|comment| { | 117 | .and_then(|comment| { |
118 | let def = doc_owner_to_def(&sema, &node)?; | ||
119 | let docs = def.docs(db)?; | ||
118 | let (idl_range, link, ns) = | 120 | let (idl_range, link, ns) = |
119 | extract_positioned_link_from_comment(position.offset, &comment)?; | 121 | extract_positioned_link_from_comment(position.offset, &comment, docs)?; |
120 | range = Some(idl_range); | 122 | range = Some(idl_range); |
121 | let def = doc_owner_to_def(&sema, &node)?; | ||
122 | resolve_doc_path_for_def(db, def, &link, ns) | 123 | resolve_doc_path_for_def(db, def, &link, ns) |
123 | }) | 124 | }) |
124 | .map(Definition::ModuleDef), | 125 | .map(Definition::ModuleDef), |
@@ -3812,23 +3813,33 @@ fn main() { | |||
3812 | fn hover_intra_doc_links() { | 3813 | fn hover_intra_doc_links() { |
3813 | check( | 3814 | check( |
3814 | r#" | 3815 | r#" |
3815 | /// This is the [`foo`](foo$0) function. | 3816 | |
3816 | fn foo() {} | 3817 | pub mod theitem { |
3818 | /// This is the item. Cool! | ||
3819 | pub struct TheItem; | ||
3820 | } | ||
3821 | |||
3822 | /// Gives you a [`TheItem$0`]. | ||
3823 | /// | ||
3824 | /// [`TheItem`]: theitem::TheItem | ||
3825 | pub fn gimme() -> theitem::TheItem { | ||
3826 | theitem::TheItem | ||
3827 | } | ||
3817 | "#, | 3828 | "#, |
3818 | expect![[r#" | 3829 | expect![[r#" |
3819 | *[`foo`](foo)* | 3830 | *[`TheItem`]* |
3820 | 3831 | ||
3821 | ```rust | 3832 | ```rust |
3822 | test | 3833 | test::theitem |
3823 | ``` | 3834 | ``` |
3824 | 3835 | ||
3825 | ```rust | 3836 | ```rust |
3826 | fn foo() | 3837 | pub struct TheItem |
3827 | ``` | 3838 | ``` |
3828 | 3839 | ||
3829 | --- | 3840 | --- |
3830 | 3841 | ||
3831 | This is the [`foo`](https://docs.rs/test/*/test/fn.foo.html) function. | 3842 | This is the item. Cool! |
3832 | "#]], | 3843 | "#]], |
3833 | ); | 3844 | ); |
3834 | } | 3845 | } |