diff options
author | Seivan Heidari <[email protected]> | 2019-11-25 00:54:54 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-11-25 00:54:54 +0000 |
commit | 15ea338ac991707d330288ba4d1bf5daa0fc75d9 (patch) | |
tree | 16aeab28bcdb07d36aae28e3fb4a385614865a48 /crates/ra_hir/src/db.rs | |
parent | eb7363d167c7a9f7c73cb950b621eb1dce493318 (diff) | |
parent | f7f9757b6b144385ab8ce57b15764473b1f57331 (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir/src/db.rs')
-rw-r--r-- | crates/ra_hir/src/db.rs | 72 |
1 files changed, 21 insertions, 51 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ed0d68001..5084bbacf 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -2,79 +2,46 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use hir_def::attr::Attr; | 5 | use ra_arena::map::ArenaMap; |
6 | use ra_db::salsa; | 6 | use ra_db::salsa; |
7 | use ra_syntax::SmolStr; | ||
8 | 7 | ||
9 | use crate::{ | 8 | use crate::{ |
10 | debug::HirDebugDatabase, | ||
11 | ids, | ||
12 | lang_item::{LangItemTarget, LangItems}, | ||
13 | ty::{ | 9 | ty::{ |
14 | method_resolution::CrateImplBlocks, | 10 | method_resolution::CrateImplBlocks, |
15 | traits::{AssocTyValue, Impl}, | 11 | traits::{AssocTyValue, Impl}, |
16 | CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef, | 12 | CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef, |
17 | TypeCtor, | 13 | TypeCtor, |
18 | }, | 14 | }, |
19 | type_alias::TypeAliasData, | 15 | Crate, DefWithBody, GenericDef, ImplBlock, Trait, |
20 | Const, ConstData, Crate, DefWithBody, FnData, Function, GenericDef, ImplBlock, Module, Static, | ||
21 | StructField, Trait, TypeAlias, | ||
22 | }; | 16 | }; |
23 | 17 | ||
24 | pub use hir_def::db::{ | 18 | pub use hir_def::{ |
25 | BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, | 19 | db::{ |
26 | EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, | 20 | BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery, |
27 | InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, | 21 | DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery, |
28 | TraitDataQuery, | 22 | FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, |
23 | InternDatabaseStorage, LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, | ||
24 | RawItemsWithSourceMapQuery, StaticDataQuery, StructDataQuery, TraitDataQuery, | ||
25 | TypeAliasDataQuery, | ||
26 | }, | ||
27 | LocalStructFieldId, VariantId, | ||
29 | }; | 28 | }; |
30 | pub use hir_expand::db::{ | 29 | pub use hir_expand::db::{ |
31 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, | 30 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, |
32 | ParseMacroQuery, | 31 | ParseMacroQuery, |
33 | }; | 32 | }; |
34 | 33 | ||
35 | // This database uses `AstDatabase` internally, | ||
36 | #[salsa::query_group(DefDatabaseStorage)] | ||
37 | #[salsa::requires(AstDatabase)] | ||
38 | pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { | ||
39 | #[salsa::invoke(FnData::fn_data_query)] | ||
40 | fn fn_data(&self, func: Function) -> Arc<FnData>; | ||
41 | |||
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)] | ||
46 | fn const_data(&self, konst: Const) -> Arc<ConstData>; | ||
47 | |||
48 | #[salsa::invoke(ConstData::static_data_query)] | ||
49 | fn static_data(&self, konst: Static) -> Arc<ConstData>; | ||
50 | |||
51 | #[salsa::invoke(LangItems::module_lang_items_query)] | ||
52 | fn module_lang_items(&self, module: Module) -> Option<Arc<LangItems>>; | ||
53 | |||
54 | #[salsa::invoke(LangItems::crate_lang_items_query)] | ||
55 | fn crate_lang_items(&self, krate: Crate) -> Arc<LangItems>; | ||
56 | |||
57 | #[salsa::invoke(LangItems::lang_item_query)] | ||
58 | fn lang_item(&self, start_crate: Crate, item: SmolStr) -> Option<LangItemTarget>; | ||
59 | |||
60 | #[salsa::invoke(crate::code_model::docs::documentation_query)] | ||
61 | fn documentation(&self, def: crate::DocDef) -> Option<crate::Documentation>; | ||
62 | |||
63 | #[salsa::invoke(crate::code_model::attrs::attributes_query)] | ||
64 | fn attrs(&self, def: crate::AttrDef) -> Option<Arc<[Attr]>>; | ||
65 | } | ||
66 | |||
67 | #[salsa::query_group(HirDatabaseStorage)] | 34 | #[salsa::query_group(HirDatabaseStorage)] |
68 | #[salsa::requires(salsa::Database)] | 35 | #[salsa::requires(salsa::Database)] |
69 | pub trait HirDatabase: DefDatabase + AstDatabase { | 36 | pub trait HirDatabase: DefDatabase { |
70 | #[salsa::invoke(crate::ty::infer_query)] | 37 | #[salsa::invoke(crate::ty::infer_query)] |
71 | fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>; | 38 | fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>; |
72 | 39 | ||
73 | #[salsa::invoke(crate::ty::type_for_def)] | 40 | #[salsa::invoke(crate::ty::type_for_def)] |
74 | fn type_for_def(&self, def: TypableDef, ns: Namespace) -> Ty; | 41 | fn type_for_def(&self, def: TypableDef, ns: Namespace) -> Ty; |
75 | 42 | ||
76 | #[salsa::invoke(crate::ty::type_for_field)] | 43 | #[salsa::invoke(crate::ty::field_types_query)] |
77 | fn type_for_field(&self, field: StructField) -> Ty; | 44 | fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>; |
78 | 45 | ||
79 | #[salsa::invoke(crate::ty::callable_item_sig)] | 46 | #[salsa::invoke(crate::ty::callable_item_sig)] |
80 | fn callable_item_signature(&self, def: CallableDef) -> FnSig; | 47 | fn callable_item_signature(&self, def: CallableDef) -> FnSig; |
@@ -108,11 +75,14 @@ pub trait HirDatabase: DefDatabase + AstDatabase { | |||
108 | 75 | ||
109 | // Interned IDs for Chalk integration | 76 | // Interned IDs for Chalk integration |
110 | #[salsa::interned] | 77 | #[salsa::interned] |
111 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId; | 78 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> crate::ty::TypeCtorId; |
112 | #[salsa::interned] | 79 | #[salsa::interned] |
113 | fn intern_chalk_impl(&self, impl_: Impl) -> ids::GlobalImplId; | 80 | fn intern_chalk_impl(&self, impl_: Impl) -> crate::ty::traits::GlobalImplId; |
114 | #[salsa::interned] | 81 | #[salsa::interned] |
115 | fn intern_assoc_ty_value(&self, assoc_ty_value: AssocTyValue) -> ids::AssocTyValueId; | 82 | fn intern_assoc_ty_value( |
83 | &self, | ||
84 | assoc_ty_value: AssocTyValue, | ||
85 | ) -> crate::ty::traits::AssocTyValueId; | ||
116 | 86 | ||
117 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] | 87 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] |
118 | fn associated_ty_data( | 88 | fn associated_ty_data( |