mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
move stuct to code_model_api
This commit is contained in:
parent
3bb1cb7017
commit
e30c533eb6
3 changed files with 27 additions and 22 deletions
|
@ -4,41 +4,25 @@ use ra_db::Cancelable;
|
|||
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 {
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ pub use self::{
|
|||
module_tree::ModuleId,
|
||||
nameres::{ItemMap, PerNs, Namespace, Resolution},
|
||||
function::{Function, FnSignature, FnScopes, ScopesWithSyntaxMapping},
|
||||
adt::{Struct, Enum},
|
||||
adt::Enum,
|
||||
ty::Ty,
|
||||
impl_block::{ImplBlock, ImplItem},
|
||||
};
|
||||
|
@ -60,6 +60,7 @@ pub use self::function::FnSignatureInfo;
|
|||
pub use self::code_model_api::{
|
||||
Crate, CrateDependency,
|
||||
Module, ModuleSource, Problem,
|
||||
Struct,
|
||||
};
|
||||
|
||||
pub enum Def {
|
||||
|
|
Loading…
Reference in a new issue