use ra_syntax::ast::{self, NameOwner, StructFlavor};
use crate::{
- DefId, Name, AsName,
+ DefId, Name, AsName, Struct,
db::HirDatabase,
type_ref::TypeRef,
};
-pub struct Struct {
- def_id: DefId,
-}
-
impl Struct {
pub(crate) fn new(def_id: DefId) -> Self {
Struct { def_id }
}
- pub fn def_id(&self) -> DefId {
- self.def_id
- }
-
- pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> {
- Ok(db.struct_data(self.def_id)?.variant_data.clone())
- }
-
- pub fn struct_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<StructData>> {
+ pub(crate) fn struct_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<StructData>> {
Ok(db.struct_data(self.def_id)?)
}
-
- pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
- Ok(db.struct_data(self.def_id)?.name.clone())
- }
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StructData {
- name: Option<Name>,
- variant_data: Arc<VariantData>,
+ pub(crate) name: Option<Name>,
+ pub(crate) variant_data: Arc<VariantData>,
}
impl StructData {
+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
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())
+ }
+}
module_tree::ModuleId,
nameres::{ItemMap, PerNs, Namespace, Resolution},
function::{Function, FnSignature, FnScopes, ScopesWithSyntaxMapping},
- adt::{Struct, Enum},
+ adt::Enum,
ty::Ty,
impl_block::{ImplBlock, ImplItem},
};
pub use self::code_model_api::{
Crate, CrateDependency,
Module, ModuleSource, Problem,
+ Struct,
};
pub enum Def {