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.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 25d710c73..3bb42ac58 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -4,7 +4,12 @@ use relative_path::RelativePathBuf;
4use ra_db::{CrateId, Cancelable, FileId}; 4use ra_db::{CrateId, Cancelable, FileId};
5use ra_syntax::{ast, TreePtr, SyntaxNode}; 5use ra_syntax::{ast, TreePtr, SyntaxNode};
6 6
7use crate::{Name, db::HirDatabase, DefId, Path, PerNs, nameres::ModuleScope, adt::VariantData}; 7use crate::{
8 Name, DefId, Path, PerNs,
9 type_ref::TypeRef,
10 nameres::ModuleScope,
11 db::HirDatabase,
12};
8 13
9/// hir::Crate describes a single crate. It's the main inteface with which 14/// hir::Crate describes a single crate. It's the main inteface with which
10/// crate's dependencies interact. Mostly, it should be just a proxy for the 15/// crate's dependencies interact. Mostly, it should be just a proxy for the
@@ -114,6 +119,30 @@ impl Module {
114 } 119 }
115} 120}
116 121
122/// A single field of an enum variant or struct
123#[derive(Debug, Clone, PartialEq, Eq)]
124pub struct StructField {
125 pub(crate) name: Name,
126 pub(crate) type_ref: TypeRef,
127}
128
129impl StructField {
130 pub fn name(&self) -> &Name {
131 &self.name
132 }
133 pub fn type_ref(&self) -> &TypeRef {
134 &self.type_ref
135 }
136}
137
138/// Fields of an enum variant or struct
139#[derive(Debug, Clone, PartialEq, Eq)]
140pub enum VariantData {
141 Struct(Vec<StructField>),
142 Tuple(Vec<StructField>),
143 Unit,
144}
145
117#[derive(Debug, Clone, PartialEq, Eq, Hash)] 146#[derive(Debug, Clone, PartialEq, Eq, Hash)]
118pub struct Struct { 147pub struct Struct {
119 pub(crate) def_id: DefId, 148 pub(crate) def_id: DefId,