Properly resolve intra doc links in hover and goto_definition

This commit is contained in:
Lukas Wirth 2021-03-29 21:23:45 +02:00
parent 0b68e03bf5
commit 9df78ec4a4
4 changed files with 104 additions and 40 deletions

View file

@ -79,6 +79,29 @@ impl Definition {
};
Some(name)
}
pub fn docs(&self, db: &RootDatabase) -> Option<hir::Documentation> {
match self {
Definition::Macro(it) => it.docs(db),
Definition::Field(it) => it.docs(db),
Definition::ModuleDef(def) => match def {
hir::ModuleDef::Module(it) => it.docs(db),
hir::ModuleDef::Function(it) => it.docs(db),
hir::ModuleDef::Adt(def) => match def {
hir::Adt::Struct(it) => it.docs(db),
hir::Adt::Union(it) => it.docs(db),
hir::Adt::Enum(it) => it.docs(db),
},
hir::ModuleDef::Variant(it) => it.docs(db),
hir::ModuleDef::Const(it) => it.docs(db),
hir::ModuleDef::Static(it) => it.docs(db),
hir::ModuleDef::Trait(it) => it.docs(db),
hir::ModuleDef::TypeAlias(it) => it.docs(db),
hir::ModuleDef::BuiltinType(_) => None,
},
_ => None,
}
}
}
#[derive(Debug)]