aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-22 09:57:40 +0000
committerAleksey Kladov <[email protected]>2019-11-22 10:13:51 +0000
commit4fc900deb121539a5311059e1ebb83ef73b190df (patch)
tree3dab5ec4164b9af8d9f921648ce495f8cd607986 /crates/ra_hir
parentd59bf33b9e1c20d6ef3fd9b72f3cf4730172b5a8 (diff)
Move TypeAlias to hir_def
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir/src/db.rs8
-rw-r--r--crates/ra_hir/src/lib.rs1
-rw-r--r--crates/ra_hir/src/type_alias.rs31
4 files changed, 4 insertions, 40 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 5690040a7..72c9b466f 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -937,7 +937,7 @@ impl TypeAlias {
937 } 937 }
938 938
939 pub fn type_ref(self, db: &impl DefDatabase) -> Option<TypeRef> { 939 pub fn type_ref(self, db: &impl DefDatabase) -> Option<TypeRef> {
940 db.type_alias_data(self).type_ref.clone() 940 db.type_alias_data(self.id).type_ref.clone()
941 } 941 }
942 942
943 pub fn ty(self, db: &impl HirDatabase) -> Ty { 943 pub fn ty(self, db: &impl HirDatabase) -> Ty {
@@ -945,7 +945,7 @@ impl TypeAlias {
945 } 945 }
946 946
947 pub fn name(self, db: &impl DefDatabase) -> Name { 947 pub fn name(self, db: &impl DefDatabase) -> Name {
948 db.type_alias_data(self).name.clone() 948 db.type_alias_data(self.id).name.clone()
949 } 949 }
950} 950}
951 951
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index ed0d68001..689874331 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -16,16 +16,15 @@ use crate::{
16 CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef, 16 CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef,
17 TypeCtor, 17 TypeCtor,
18 }, 18 },
19 type_alias::TypeAliasData,
20 Const, ConstData, Crate, DefWithBody, FnData, Function, GenericDef, ImplBlock, Module, Static, 19 Const, ConstData, Crate, DefWithBody, FnData, Function, GenericDef, ImplBlock, Module, Static,
21 StructField, Trait, TypeAlias, 20 StructField, Trait,
22}; 21};
23 22
24pub use hir_def::db::{ 23pub use hir_def::db::{
25 BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, 24 BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage,
26 EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, 25 EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase,
27 InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, 26 InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery,
28 TraitDataQuery, 27 TraitDataQuery, TypeAliasDataQuery,
29}; 28};
30pub use hir_expand::db::{ 29pub use hir_expand::db::{
31 AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, 30 AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery,
@@ -39,9 +38,6 @@ pub trait DefDatabase: HirDebugDatabase + DefDatabase2 {
39 #[salsa::invoke(FnData::fn_data_query)] 38 #[salsa::invoke(FnData::fn_data_query)]
40 fn fn_data(&self, func: Function) -> Arc<FnData>; 39 fn fn_data(&self, func: Function) -> Arc<FnData>;
41 40
42 #[salsa::invoke(TypeAliasData::type_alias_data_query)]
43 fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>;
44
45 #[salsa::invoke(ConstData::const_data_query)] 41 #[salsa::invoke(ConstData::const_data_query)]
46 fn const_data(&self, konst: Const) -> Arc<ConstData>; 42 fn const_data(&self, konst: Const) -> Arc<ConstData>;
47 43
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 8c6834392..8e532c36c 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -32,7 +32,6 @@ pub mod db;
32pub mod source_binder; 32pub mod source_binder;
33 33
34mod ids; 34mod ids;
35mod type_alias;
36mod ty; 35mod ty;
37mod impl_block; 36mod impl_block;
38mod expr; 37mod expr;
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs
deleted file mode 100644
index 392f244cf..000000000
--- a/crates/ra_hir/src/type_alias.rs
+++ /dev/null
@@ -1,31 +0,0 @@
1//! HIR for type aliases (i.e. the `type` keyword).
2
3use std::sync::Arc;
4
5use hir_def::type_ref::TypeRef;
6use hir_expand::name::{AsName, Name};
7
8use ra_syntax::ast::NameOwner;
9
10use crate::{
11 db::{AstDatabase, DefDatabase},
12 HasSource, TypeAlias,
13};
14
15#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct TypeAliasData {
17 pub(crate) name: Name,
18 pub(crate) type_ref: Option<TypeRef>,
19}
20
21impl TypeAliasData {
22 pub(crate) fn type_alias_data_query(
23 db: &(impl DefDatabase + AstDatabase),
24 typ: TypeAlias,
25 ) -> Arc<TypeAliasData> {
26 let node = typ.source(db).value;
27 let name = node.name().map_or_else(Name::missing, |n| n.as_name());
28 let type_ref = node.type_ref().map(TypeRef::from_ast);
29 Arc::new(TypeAliasData { name, type_ref })
30 }
31}