diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 12:19:37 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 12:19:37 +0000 |
commit | e30c533eb67ba8a24708a94385849854c17e67f9 (patch) | |
tree | 95f42bac96ce8c851938854860746be65e535acd /crates/ra_hir/src/code_model_api.rs | |
parent | 3bb1cb7017aab6fddb38eae3ca671ecbdaedb4da (diff) |
move stuct 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 | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 43cddb504..12947da2d 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -1,8 +1,10 @@ | |||
1 | use std::sync::Arc; | ||
2 | |||
1 | use relative_path::RelativePathBuf; | 3 | use relative_path::RelativePathBuf; |
2 | use ra_db::{CrateId, Cancelable, FileId}; | 4 | use ra_db::{CrateId, Cancelable, FileId}; |
3 | use ra_syntax::{ast, TreePtr, SyntaxNode}; | 5 | use ra_syntax::{ast, TreePtr, SyntaxNode}; |
4 | 6 | ||
5 | use crate::{Name, db::HirDatabase, DefId, Path, PerNs, nameres::ModuleScope}; | 7 | use crate::{Name, db::HirDatabase, DefId, Path, PerNs, nameres::ModuleScope, adt::VariantData}; |
6 | 8 | ||
7 | /// hir::Crate describes a single crate. It's the main inteface with which | 9 | /// hir::Crate describes a single crate. It's the main inteface with which |
8 | /// crate's dependencies interact. Mostly, it should be just a proxy for the | 10 | /// crate's dependencies interact. Mostly, it should be just a proxy for the |
@@ -111,3 +113,21 @@ impl Module { | |||
111 | self.problems_impl(db) | 113 | self.problems_impl(db) |
112 | } | 114 | } |
113 | } | 115 | } |
116 | |||
117 | pub struct Struct { | ||
118 | pub(crate) def_id: DefId, | ||
119 | } | ||
120 | |||
121 | impl Struct { | ||
122 | pub fn def_id(&self) -> DefId { | ||
123 | self.def_id | ||
124 | } | ||
125 | |||
126 | pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> { | ||
127 | Ok(self.struct_data(db)?.variant_data.clone()) | ||
128 | } | ||
129 | |||
130 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { | ||
131 | Ok(self.struct_data(db)?.name.clone()) | ||
132 | } | ||
133 | } | ||