diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 12:22:57 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 12:22:57 +0000 |
commit | 2d4dc22af8db8f9ebb5f2e95cd25c473494a4b70 (patch) | |
tree | 963dfadfe92595982ba0c374e467bdbb41d04c3d /crates/ra_hir/src/code_model_api.rs | |
parent | e30c533eb67ba8a24708a94385849854c17e67f9 (diff) |
move enum to code_model_api
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 24 |
1 files changed, 22 insertions, 2 deletions
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 { | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
117 | pub struct Struct { | 118 | pub struct Struct { |
118 | pub(crate) def_id: DefId, | 119 | pub(crate) def_id: DefId, |
119 | } | 120 | } |
@@ -124,10 +125,29 @@ impl Struct { | |||
124 | } | 125 | } |
125 | 126 | ||
126 | pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> { | 127 | pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> { |
127 | Ok(self.struct_data(db)?.variant_data.clone()) | 128 | Ok(db.struct_data(self.def_id)?.variant_data.clone()) |
128 | } | 129 | } |
129 | 130 | ||
130 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { | 131 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { |
131 | Ok(self.struct_data(db)?.name.clone()) | 132 | Ok(db.struct_data(self.def_id)?.name.clone()) |
133 | } | ||
134 | } | ||
135 | |||
136 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
137 | pub struct Enum { | ||
138 | pub(crate) def_id: DefId, | ||
139 | } | ||
140 | |||
141 | impl Enum { | ||
142 | pub fn def_id(&self) -> DefId { | ||
143 | self.def_id | ||
144 | } | ||
145 | |||
146 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { | ||
147 | Ok(db.enum_data(self.def_id)?.name.clone()) | ||
148 | } | ||
149 | |||
150 | pub fn variants(&self, db: &impl HirDatabase) -> Cancelable<Vec<(Name, Arc<VariantData>)>> { | ||
151 | Ok(db.enum_data(self.def_id)?.variants.clone()) | ||
132 | } | 152 | } |
133 | } | 153 | } |