From 2d0ab52212f62345ba9f9d5040c553e59460b349 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Jan 2019 15:27:00 +0300 Subject: move variants to API --- crates/ra_hir/src/code_model_api.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/code_model_api.rs') 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; use ra_db::{CrateId, Cancelable, FileId}; use ra_syntax::{ast, TreePtr, SyntaxNode}; -use crate::{Name, db::HirDatabase, DefId, Path, PerNs, nameres::ModuleScope, adt::VariantData}; +use crate::{ + Name, DefId, Path, PerNs, + type_ref::TypeRef, + nameres::ModuleScope, + db::HirDatabase, +}; /// hir::Crate describes a single crate. It's the main inteface with which /// crate's dependencies interact. Mostly, it should be just a proxy for the @@ -114,6 +119,30 @@ impl Module { } } +/// A single field of an enum variant or struct +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct StructField { + pub(crate) name: Name, + pub(crate) type_ref: TypeRef, +} + +impl StructField { + pub fn name(&self) -> &Name { + &self.name + } + pub fn type_ref(&self) -> &TypeRef { + &self.type_ref + } +} + +/// Fields of an enum variant or struct +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum VariantData { + Struct(Vec), + Tuple(Vec), + Unit, +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Struct { pub(crate) def_id: DefId, -- cgit v1.2.3