aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r--crates/ra_hir/src/code_model_api.rs22
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 @@
1use std::sync::Arc;
2
1use relative_path::RelativePathBuf; 3use relative_path::RelativePathBuf;
2use ra_db::{CrateId, Cancelable, FileId}; 4use ra_db::{CrateId, Cancelable, FileId};
3use ra_syntax::{ast, TreePtr, SyntaxNode}; 5use ra_syntax::{ast, TreePtr, SyntaxNode};
4 6
5use crate::{Name, db::HirDatabase, DefId, Path, PerNs, nameres::ModuleScope}; 7use 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
117pub struct Struct {
118 pub(crate) def_id: DefId,
119}
120
121impl 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}