diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-02 13:46:50 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-02 13:46:50 +0000 |
commit | 6a585c6ee24bbebfed2d0aafcf2e885a9ae77877 (patch) | |
tree | c8de313a9271d96035836a16a9f80b796e047a66 /crates/ide_db/src | |
parent | 657ec3616f076c85e21d82feba0397690e836bd9 (diff) | |
parent | 8d305680e6560debaf7868c160112e07a7bea8a0 (diff) |
Merge #7795
7795: Show docs on hover for keywords and primitives r=matklad a=Veykril
![lAWFadkziX](https://user-images.githubusercontent.com/3757771/109369534-eeb4f500-789c-11eb-8f2b-2f9c4e129de3.gif)
It's a bit annoying that this requires the `SyntaxNode` and `Semantics` to be pulled through `hover_for_definition` just so we can get the `std` crate but I couldn't think of a better way.
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/helpers.rs | 4 | ||||
-rw-r--r-- | crates/ide_db/src/helpers/famous_defs_fixture.rs | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/crates/ide_db/src/helpers.rs b/crates/ide_db/src/helpers.rs index f9de8ce0e..3ff77400b 100644 --- a/crates/ide_db/src/helpers.rs +++ b/crates/ide_db/src/helpers.rs | |||
@@ -41,6 +41,10 @@ pub struct FamousDefs<'a, 'b>(pub &'a Semantics<'b, RootDatabase>, pub Option<Cr | |||
41 | impl FamousDefs<'_, '_> { | 41 | impl FamousDefs<'_, '_> { |
42 | pub const FIXTURE: &'static str = include_str!("helpers/famous_defs_fixture.rs"); | 42 | pub const FIXTURE: &'static str = include_str!("helpers/famous_defs_fixture.rs"); |
43 | 43 | ||
44 | pub fn std(&self) -> Option<Crate> { | ||
45 | self.find_crate("std") | ||
46 | } | ||
47 | |||
44 | pub fn core(&self) -> Option<Crate> { | 48 | pub fn core(&self) -> Option<Crate> { |
45 | self.find_crate("core") | 49 | self.find_crate("core") |
46 | } | 50 | } |
diff --git a/crates/ide_db/src/helpers/famous_defs_fixture.rs b/crates/ide_db/src/helpers/famous_defs_fixture.rs index bb4e9666b..d3464ae17 100644 --- a/crates/ide_db/src/helpers/famous_defs_fixture.rs +++ b/crates/ide_db/src/helpers/famous_defs_fixture.rs | |||
@@ -129,3 +129,11 @@ pub mod prelude { | |||
129 | } | 129 | } |
130 | #[prelude_import] | 130 | #[prelude_import] |
131 | pub use prelude::*; | 131 | pub use prelude::*; |
132 | //- /libstd.rs crate:std deps:core | ||
133 | //! Signatures of traits, types and functions from the std lib for use in tests. | ||
134 | |||
135 | /// Docs for return_keyword | ||
136 | mod return_keyword {} | ||
137 | |||
138 | /// Docs for prim_str | ||
139 | mod prim_str {} | ||