aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-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)]