aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-03-05 23:02:14 +0000
committerKirill Bulatov <[email protected]>2020-03-07 21:20:18 +0000
commit32f5276465266522ebc01b8417feeba99bf00f6f (patch)
tree6388994a0cc67c7ca60658e81489a832569e3c4e /crates/ra_hir/src
parentaff82cf7ac172f213cb5dcca637cb2c5332294c1 (diff)
Show mod path in hover tooltip
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 2944926e6..dca5f27b2 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -480,6 +480,14 @@ impl Adt {
480 pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> { 480 pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
481 Some(self.module(db).krate()) 481 Some(self.module(db).krate())
482 } 482 }
483
484 pub fn name(&self, db: &impl HirDatabase) -> Name {
485 match self {
486 Adt::Struct(s) => s.name(db),
487 Adt::Union(u) => u.name(db),
488 Adt::Enum(e) => e.name(db),
489 }
490 }
483} 491}
484 492
485#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 493#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
@@ -507,6 +515,14 @@ impl VariantDef {
507 } 515 }
508 } 516 }
509 517
518 pub fn name(&self, db: &impl HirDatabase) -> Name {
519 match self {
520 VariantDef::Struct(s) => s.name(db),
521 VariantDef::Union(u) => u.name(db),
522 VariantDef::EnumVariant(e) => e.name(db),
523 }
524 }
525
510 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 526 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
511 match self { 527 match self {
512 VariantDef::Struct(it) => it.variant_data(db), 528 VariantDef::Struct(it) => it.variant_data(db),
@@ -534,6 +550,14 @@ impl DefWithBody {
534 DefWithBody::Static(s) => s.module(db), 550 DefWithBody::Static(s) => s.module(db),
535 } 551 }
536 } 552 }
553
554 pub fn name(self, db: &impl HirDatabase) -> Option<Name> {
555 match self {
556 DefWithBody::Function(f) => Some(f.name(db)),
557 DefWithBody::Static(s) => s.name(db),
558 DefWithBody::Const(c) => c.name(db),
559 }
560 }
537} 561}
538 562
539#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 563#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]