move stuct to code_model_api

This commit is contained in:
Aleksey Kladov 2019-01-08 15:19:37 +03:00
parent 3bb1cb7017
commit e30c533eb6
3 changed files with 27 additions and 22 deletions

View file

@ -1,8 +1,10 @@
use std::sync::Arc;
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};
use crate::{Name, db::HirDatabase, DefId, Path, PerNs, nameres::ModuleScope, adt::VariantData};
/// 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
@ -111,3 +113,21 @@ impl Module {
self.problems_impl(db)
}
}
pub struct Struct {
pub(crate) def_id: DefId,
}
impl Struct {
pub fn def_id(&self) -> DefId {
self.def_id
}
pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> {
Ok(self.struct_data(db)?.variant_data.clone())
}
pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
Ok(self.struct_data(db)?.name.clone())
}
}