diff options
Diffstat (limited to 'crates/ra_hir/src/adt.rs')
-rw-r--r-- | crates/ra_hir/src/adt.rs | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 4b35c01b3..935f39959 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -1,11 +1,9 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_db::Cancelable; | ||
4 | use ra_syntax::ast::{self, NameOwner, StructFlavor}; | 3 | use ra_syntax::ast::{self, NameOwner, StructFlavor}; |
5 | 4 | ||
6 | use crate::{ | 5 | use crate::{ |
7 | DefId, Name, AsName, Struct, | 6 | DefId, Name, AsName, Struct, Enum, |
8 | db::HirDatabase, | ||
9 | type_ref::TypeRef, | 7 | type_ref::TypeRef, |
10 | }; | 8 | }; |
11 | 9 | ||
@@ -13,10 +11,6 @@ impl Struct { | |||
13 | pub(crate) fn new(def_id: DefId) -> Self { | 11 | pub(crate) fn new(def_id: DefId) -> Self { |
14 | Struct { def_id } | 12 | Struct { def_id } |
15 | } | 13 | } |
16 | |||
17 | pub(crate) fn struct_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<StructData>> { | ||
18 | Ok(db.struct_data(self.def_id)?) | ||
19 | } | ||
20 | } | 14 | } |
21 | 15 | ||
22 | #[derive(Debug, Clone, PartialEq, Eq)] | 16 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -42,32 +36,16 @@ impl StructData { | |||
42 | } | 36 | } |
43 | } | 37 | } |
44 | 38 | ||
45 | pub struct Enum { | ||
46 | def_id: DefId, | ||
47 | } | ||
48 | |||
49 | impl Enum { | 39 | impl Enum { |
50 | pub(crate) fn new(def_id: DefId) -> Self { | 40 | pub(crate) fn new(def_id: DefId) -> Self { |
51 | Enum { def_id } | 41 | Enum { def_id } |
52 | } | 42 | } |
53 | |||
54 | pub fn def_id(&self) -> DefId { | ||
55 | self.def_id | ||
56 | } | ||
57 | |||
58 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { | ||
59 | Ok(db.enum_data(self.def_id)?.name.clone()) | ||
60 | } | ||
61 | |||
62 | pub fn variants(&self, db: &impl HirDatabase) -> Cancelable<Vec<(Name, Arc<VariantData>)>> { | ||
63 | Ok(db.enum_data(self.def_id)?.variants.clone()) | ||
64 | } | ||
65 | } | 43 | } |
66 | 44 | ||
67 | #[derive(Debug, Clone, PartialEq, Eq)] | 45 | #[derive(Debug, Clone, PartialEq, Eq)] |
68 | pub struct EnumData { | 46 | pub struct EnumData { |
69 | name: Option<Name>, | 47 | pub(crate) name: Option<Name>, |
70 | variants: Vec<(Name, Arc<VariantData>)>, | 48 | pub(crate) variants: Vec<(Name, Arc<VariantData>)>, |
71 | } | 49 | } |
72 | 50 | ||
73 | impl EnumData { | 51 | impl EnumData { |