mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Move TypeAlias to hir_def
This commit is contained in:
parent
d59bf33b9e
commit
4fc900deb1
6 changed files with 16 additions and 20 deletions
|
@ -937,7 +937,7 @@ impl TypeAlias {
|
|||
}
|
||||
|
||||
pub fn type_ref(self, db: &impl DefDatabase) -> Option<TypeRef> {
|
||||
db.type_alias_data(self).type_ref.clone()
|
||||
db.type_alias_data(self.id).type_ref.clone()
|
||||
}
|
||||
|
||||
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
||||
|
@ -945,7 +945,7 @@ impl TypeAlias {
|
|||
}
|
||||
|
||||
pub fn name(self, db: &impl DefDatabase) -> Name {
|
||||
db.type_alias_data(self).name.clone()
|
||||
db.type_alias_data(self.id).name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,16 +16,15 @@ use crate::{
|
|||
CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef,
|
||||
TypeCtor,
|
||||
},
|
||||
type_alias::TypeAliasData,
|
||||
Const, ConstData, Crate, DefWithBody, FnData, Function, GenericDef, ImplBlock, Module, Static,
|
||||
StructField, Trait, TypeAlias,
|
||||
StructField, Trait,
|
||||
};
|
||||
|
||||
pub use hir_def::db::{
|
||||
BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage,
|
||||
EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase,
|
||||
InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery,
|
||||
TraitDataQuery,
|
||||
TraitDataQuery, TypeAliasDataQuery,
|
||||
};
|
||||
pub use hir_expand::db::{
|
||||
AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery,
|
||||
|
@ -39,9 +38,6 @@ pub trait DefDatabase: HirDebugDatabase + DefDatabase2 {
|
|||
#[salsa::invoke(FnData::fn_data_query)]
|
||||
fn fn_data(&self, func: Function) -> Arc<FnData>;
|
||||
|
||||
#[salsa::invoke(TypeAliasData::type_alias_data_query)]
|
||||
fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>;
|
||||
|
||||
#[salsa::invoke(ConstData::const_data_query)]
|
||||
fn const_data(&self, konst: Const) -> Arc<ConstData>;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ pub mod db;
|
|||
pub mod source_binder;
|
||||
|
||||
mod ids;
|
||||
mod type_alias;
|
||||
mod ty;
|
||||
mod impl_block;
|
||||
mod expr;
|
||||
|
|
|
@ -15,7 +15,8 @@ use crate::{
|
|||
CrateDefMap,
|
||||
},
|
||||
traits::TraitData,
|
||||
DefWithBodyId, EnumId, GenericDefId, ImplId, ItemLoc, StructOrUnionId, TraitId,
|
||||
type_alias::TypeAliasData,
|
||||
DefWithBodyId, EnumId, GenericDefId, ImplId, ItemLoc, StructOrUnionId, TraitId, TypeAliasId,
|
||||
};
|
||||
|
||||
#[salsa::query_group(InternDatabaseStorage)]
|
||||
|
@ -64,6 +65,9 @@ pub trait DefDatabase2: InternDatabase + AstDatabase {
|
|||
#[salsa::invoke(TraitData::trait_data_query)]
|
||||
fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
|
||||
|
||||
#[salsa::invoke(TypeAliasData::type_alias_data_query)]
|
||||
fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>;
|
||||
|
||||
#[salsa::invoke(Body::body_with_source_map_query)]
|
||||
fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ pub mod body;
|
|||
pub mod generics;
|
||||
pub mod traits;
|
||||
pub mod resolver;
|
||||
pub mod type_alias;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_db;
|
||||
|
|
|
@ -2,28 +2,24 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use hir_def::type_ref::TypeRef;
|
||||
use hir_expand::name::{AsName, Name};
|
||||
|
||||
use ra_syntax::ast::NameOwner;
|
||||
|
||||
use crate::{
|
||||
db::{AstDatabase, DefDatabase},
|
||||
HasSource, TypeAlias,
|
||||
};
|
||||
use crate::{db::DefDatabase2, type_ref::TypeRef, HasSource, Lookup, TypeAliasId};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TypeAliasData {
|
||||
pub(crate) name: Name,
|
||||
pub(crate) type_ref: Option<TypeRef>,
|
||||
pub name: Name,
|
||||
pub type_ref: Option<TypeRef>,
|
||||
}
|
||||
|
||||
impl TypeAliasData {
|
||||
pub(crate) fn type_alias_data_query(
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
typ: TypeAlias,
|
||||
db: &impl DefDatabase2,
|
||||
typ: TypeAliasId,
|
||||
) -> Arc<TypeAliasData> {
|
||||
let node = typ.source(db).value;
|
||||
let node = typ.lookup(db).source(db).value;
|
||||
let name = node.name().map_or_else(Name::missing, |n| n.as_name());
|
||||
let type_ref = node.type_ref().map(TypeRef::from_ast);
|
||||
Arc::new(TypeAliasData { name, type_ref })
|
Loading…
Reference in a new issue