Show mod path in hover tooltip

This commit is contained in:
Kirill Bulatov 2020-03-06 01:02:14 +02:00
parent aff82cf7ac
commit 32f5276465
4 changed files with 132 additions and 29 deletions

View file

@ -480,6 +480,14 @@ impl Adt {
pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
Some(self.module(db).krate())
}
pub fn name(&self, db: &impl HirDatabase) -> Name {
match self {
Adt::Struct(s) => s.name(db),
Adt::Union(u) => u.name(db),
Adt::Enum(e) => e.name(db),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
@ -507,6 +515,14 @@ impl VariantDef {
}
}
pub fn name(&self, db: &impl HirDatabase) -> Name {
match self {
VariantDef::Struct(s) => s.name(db),
VariantDef::Union(u) => u.name(db),
VariantDef::EnumVariant(e) => e.name(db),
}
}
pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
match self {
VariantDef::Struct(it) => it.variant_data(db),
@ -534,6 +550,14 @@ impl DefWithBody {
DefWithBody::Static(s) => s.module(db),
}
}
pub fn name(self, db: &impl HirDatabase) -> Option<Name> {
match self {
DefWithBody::Function(f) => Some(f.name(db)),
DefWithBody::Static(s) => s.name(db),
DefWithBody::Const(c) => c.name(db),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]