From 2d4dc22af8db8f9ebb5f2e95cd25c473494a4b70 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Jan 2019 15:22:57 +0300 Subject: move enum to code_model_api --- crates/ra_hir/src/code_model_api.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 12947da2d..43bd2003c 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -114,6 +114,7 @@ impl Module { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Struct { pub(crate) def_id: DefId, } @@ -124,10 +125,29 @@ impl Struct { } pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable> { - Ok(self.struct_data(db)?.variant_data.clone()) + Ok(db.struct_data(self.def_id)?.variant_data.clone()) } pub fn name(&self, db: &impl HirDatabase) -> Cancelable> { - Ok(self.struct_data(db)?.name.clone()) + Ok(db.struct_data(self.def_id)?.name.clone()) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Enum { + pub(crate) def_id: DefId, +} + +impl Enum { + pub fn def_id(&self) -> DefId { + self.def_id + } + + pub fn name(&self, db: &impl HirDatabase) -> Cancelable> { + Ok(db.enum_data(self.def_id)?.name.clone()) + } + + pub fn variants(&self, db: &impl HirDatabase) -> Cancelable)>> { + Ok(db.enum_data(self.def_id)?.variants.clone()) } } -- cgit v1.2.3