aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/hover.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r--crates/ide/src/hover.rs37
1 files changed, 32 insertions, 5 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 845333e2a..832192881 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -1,8 +1,8 @@
1use base_db::SourceDatabase;
2use hir::{ 1use hir::{
3 Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, 2 Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay,
4 Module, ModuleDef, ModuleSource, Semantics, 3 Module, ModuleDef, ModuleSource, Semantics,
5}; 4};
5use ide_db::base_db::SourceDatabase;
6use ide_db::{ 6use ide_db::{
7 defs::{Definition, NameClass, NameRefClass}, 7 defs::{Definition, NameClass, NameRefClass},
8 RootDatabase, 8 RootDatabase,
@@ -300,7 +300,7 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
300 300
301fn render_path(db: &RootDatabase, module: Module, item_name: Option<String>) -> String { 301fn render_path(db: &RootDatabase, module: Module, item_name: Option<String>) -> String {
302 let crate_name = 302 let crate_name =
303 db.crate_graph()[module.krate().into()].declaration_name.as_ref().map(ToString::to_string); 303 db.crate_graph()[module.krate().into()].display_name.as_ref().map(|it| it.to_string());
304 let module_path = module 304 let module_path = module
305 .path_to_root(db) 305 .path_to_root(db)
306 .into_iter() 306 .into_iter()
@@ -385,8 +385,8 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> {
385 385
386#[cfg(test)] 386#[cfg(test)]
387mod tests { 387mod tests {
388 use base_db::FileLoader;
389 use expect_test::{expect, Expect}; 388 use expect_test::{expect, Expect};
389 use ide_db::base_db::FileLoader;
390 390
391 use crate::fixture; 391 use crate::fixture;
392 392
@@ -638,6 +638,33 @@ fn main() { }
638 } 638 }
639 639
640 #[test] 640 #[test]
641 fn hover_shows_fn_doc_attr_raw_string() {
642 check(
643 r##"
644#[doc = r#"Raw string doc attr"#]
645pub fn foo<|>(_: &Path) {}
646
647fn main() { }
648"##,
649 expect![[r##"
650 *foo*
651
652 ```rust
653 test
654 ```
655
656 ```rust
657 pub fn foo(_: &Path)
658 ```
659
660 ---
661
662 Raw string doc attr
663 "##]],
664 );
665 }
666
667 #[test]
641 fn hover_shows_struct_field_info() { 668 fn hover_shows_struct_field_info() {
642 // Hovering over the field when instantiating 669 // Hovering over the field when instantiating
643 check( 670 check(
@@ -2128,7 +2155,7 @@ fn foo_<|>test() {}
2128 ignore: false, 2155 ignore: false,
2129 }, 2156 },
2130 }, 2157 },
2131 cfg_exprs: [], 2158 cfg: None,
2132 }, 2159 },
2133 ), 2160 ),
2134 ] 2161 ]
@@ -2166,7 +2193,7 @@ mod tests<|> {
2166 kind: TestMod { 2193 kind: TestMod {
2167 path: "tests", 2194 path: "tests",
2168 }, 2195 },
2169 cfg_exprs: [], 2196 cfg: None,
2170 }, 2197 },
2171 ), 2198 ),
2172 ] 2199 ]