let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
let (idl_range, link, ns) =
extract_definitions_from_markdown(docs.as_str()).into_iter().find_map(|(range, link, ns)| {
- let InFile { file_id, value: range } = doc_mapping.map(range.clone())?;
+ let InFile { file_id, value: range } = doc_mapping.map(range)?;
if file_id == position.file_id.into() && range.contains(position.offset) {
Some((range, link, ns))
} else {
) -> Option<HoverAction> {
match def {
Definition::ModuleDef(it) => match it {
- ModuleDef::Module(it) => runnable_mod(&sema, it).map(|it| HoverAction::Runnable(it)),
+ ModuleDef::Module(it) => runnable_mod(sema, it).map(HoverAction::Runnable),
ModuleDef::Function(func) => {
let src = func.source(sema.db)?;
if src.file_id != file_id.into() {
return None;
}
- runnable_fn(&sema, func).map(HoverAction::Runnable)
+ runnable_fn(sema, func).map(HoverAction::Runnable)
}
_ => None,
},
return match def {
Definition::Macro(it) => match &it.source(db)?.value {
Either::Left(mac) => {
- let label = macro_label(&mac);
+ let label = macro_label(mac);
from_def_source_labeled(db, it, Some(label), mod_path)
}
Either::Right(_) => {
if !token.kind().is_keyword() {
return None;
}
- let famous_defs = FamousDefs(&sema, sema.scope(&token.parent()?).krate());
+ let famous_defs = FamousDefs(sema, sema.scope(&token.parent()?).krate());
// std exposes {}_keyword modules with docstrings on the root to document keywords
let keyword_mod = format!("{}_keyword", token.text());
let doc_owner = find_std_module(&famous_defs, &keyword_mod)?;
use crate::fixture;
- use super::*;
-
fn check_hover_no_result(ra_fixture: &str) {
let (analysis, position) = fixture::position(ra_fixture);
assert!(analysis.hover(position, true, true).unwrap().is_none());
);
}
- #[ignore = "path based links currently only support documentation on ModuleDef items"]
#[test]
fn test_hover_path_link_field() {
+ // FIXME: Should be
+ // [Foo](https://docs.rs/test/*/test/struct.Foo.html)
check(
r#"
pub struct Foo;
---
- [Foo](https://docs.rs/test/*/test/struct.Foo.html)
+ [Foo](struct.Foo.html)
"#]],
);
}
fn test_hover_async_block_impl_trait_has_goto_type_action() {
check_actions(
r#"
+//- minicore: future
struct S;
fn foo() {
let fo$0o = async { S };
}
-
-#[prelude_import] use future::*;
-mod future {
- #[lang = "future_trait"]
- pub trait Future { type Output; }
-}
"#,
expect![[r#"
[
GoToType(
[
HoverGotoTypeData {
- mod_path: "test::future::Future",
+ mod_path: "core::future::Future",
nav: NavigationTarget {
file_id: FileId(
- 0,
+ 1,
),
- full_range: 101..163,
- focus_range: 140..146,
+ full_range: 248..430,
+ focus_range: 287..293,
name: "Future",
kind: Trait,
description: "pub trait Future",
#[test]
fn hover_keyword() {
- let ra_fixture = r#"//- /main.rs crate:main deps:std
-fn f() { retur$0n; }"#;
- let fixture = format!("{}\n{}", ra_fixture, FamousDefs::FIXTURE);
check(
- &fixture,
+ r#"
+//- /main.rs crate:main deps:std
+fn f() { retur$0n; }
+//- /libstd.rs crate:std
+/// Docs for return_keyword
+mod return_keyword {}
+"#,
expect![[r#"
*return*
#[test]
fn hover_builtin() {
- let ra_fixture = r#"//- /main.rs crate:main deps:std
-cosnt _: &str$0 = ""; }"#;
- let fixture = format!("{}\n{}", ra_fixture, FamousDefs::FIXTURE);
check(
- &fixture,
+ r#"
+//- /main.rs crate:main deps:std
+cosnt _: &str$0 = ""; }
+
+//- /libstd.rs crate:std
+/// Docs for prim_str
+mod prim_str {}
+"#,
expect![[r#"
*str*