diff options
Diffstat (limited to 'crates/ra_hir/src/db.rs')
-rw-r--r-- | crates/ra_hir/src/db.rs | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index cc03da1e2..5304f5d31 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -1,20 +1,21 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; | 3 | use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; |
4 | use ra_db::{SourceRootId, SyntaxDatabase, salsa}; | 4 | use ra_db::{SyntaxDatabase, CrateId, salsa}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | HirInterner, DefId, MacroCallId, Name, HirFileId, | 7 | MacroCallId, Name, HirFileId, |
8 | SourceFileItems, SourceItemId, Crate, | 8 | SourceFileItems, SourceItemId, Crate, Module, HirInterner, |
9 | query_definitions, | 9 | query_definitions, |
10 | FnSignature, FnScopes, | 10 | Function, FnSignature, FnScopes, |
11 | Struct, Enum, EnumVariant, | ||
11 | macros::MacroExpansion, | 12 | macros::MacroExpansion, |
12 | module_tree::{ModuleId, ModuleTree}, | 13 | module_tree::ModuleTree, |
13 | nameres::{ItemMap, lower::{LoweredModule, ImportSourceMap}}, | 14 | nameres::{ItemMap, lower::{LoweredModule, ImportSourceMap}}, |
14 | ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks}, | 15 | ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, VariantDef}, |
15 | adt::{StructData, EnumData, EnumVariantData}, | 16 | adt::{StructData, EnumData, EnumVariantData}, |
16 | impl_block::ModuleImplBlocks, | 17 | impl_block::ModuleImplBlocks, |
17 | generics::GenericParams, | 18 | generics::{GenericParams, GenericDef}, |
18 | }; | 19 | }; |
19 | 20 | ||
20 | #[salsa::query_group] | 21 | #[salsa::query_group] |
@@ -26,25 +27,25 @@ pub trait HirDatabase: SyntaxDatabase + AsRef<HirInterner> { | |||
26 | fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; | 27 | fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; |
27 | 28 | ||
28 | #[salsa::invoke(query_definitions::fn_scopes)] | 29 | #[salsa::invoke(query_definitions::fn_scopes)] |
29 | fn fn_scopes(&self, def_id: DefId) -> Arc<FnScopes>; | 30 | fn fn_scopes(&self, func: Function) -> Arc<FnScopes>; |
30 | 31 | ||
31 | #[salsa::invoke(crate::adt::StructData::struct_data_query)] | 32 | #[salsa::invoke(crate::adt::StructData::struct_data_query)] |
32 | fn struct_data(&self, def_id: DefId) -> Arc<StructData>; | 33 | fn struct_data(&self, s: Struct) -> Arc<StructData>; |
33 | 34 | ||
34 | #[salsa::invoke(crate::adt::EnumData::enum_data_query)] | 35 | #[salsa::invoke(crate::adt::EnumData::enum_data_query)] |
35 | fn enum_data(&self, def_id: DefId) -> Arc<EnumData>; | 36 | fn enum_data(&self, e: Enum) -> Arc<EnumData>; |
36 | 37 | ||
37 | #[salsa::invoke(crate::adt::EnumVariantData::enum_variant_data_query)] | 38 | #[salsa::invoke(crate::adt::EnumVariantData::enum_variant_data_query)] |
38 | fn enum_variant_data(&self, def_id: DefId) -> Arc<EnumVariantData>; | 39 | fn enum_variant_data(&self, var: EnumVariant) -> Arc<EnumVariantData>; |
39 | 40 | ||
40 | #[salsa::invoke(crate::ty::infer)] | 41 | #[salsa::invoke(crate::ty::infer)] |
41 | fn infer(&self, def_id: DefId) -> Arc<InferenceResult>; | 42 | fn infer(&self, func: Function) -> Arc<InferenceResult>; |
42 | 43 | ||
43 | #[salsa::invoke(crate::ty::type_for_def)] | 44 | #[salsa::invoke(crate::ty::type_for_def)] |
44 | fn type_for_def(&self, def_id: DefId) -> Ty; | 45 | fn type_for_def(&self, def: TypableDef) -> Ty; |
45 | 46 | ||
46 | #[salsa::invoke(crate::ty::type_for_field)] | 47 | #[salsa::invoke(crate::ty::type_for_field)] |
47 | fn type_for_field(&self, def_id: DefId, field: Name) -> Option<Ty>; | 48 | fn type_for_field(&self, def: VariantDef, field: Name) -> Option<Ty>; |
48 | 49 | ||
49 | #[salsa::invoke(query_definitions::file_items)] | 50 | #[salsa::invoke(query_definitions::file_items)] |
50 | fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>; | 51 | fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>; |
@@ -56,51 +57,35 @@ pub trait HirDatabase: SyntaxDatabase + AsRef<HirInterner> { | |||
56 | fn submodules(&self, source: SourceItemId) -> Arc<Vec<crate::module_tree::Submodule>>; | 57 | fn submodules(&self, source: SourceItemId) -> Arc<Vec<crate::module_tree::Submodule>>; |
57 | 58 | ||
58 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_query)] | 59 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_query)] |
59 | fn lower_module( | 60 | fn lower_module(&self, module: Module) -> (Arc<LoweredModule>, Arc<ImportSourceMap>); |
60 | &self, | ||
61 | source_root_id: SourceRootId, | ||
62 | module_id: ModuleId, | ||
63 | ) -> (Arc<LoweredModule>, Arc<ImportSourceMap>); | ||
64 | 61 | ||
65 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_module_query)] | 62 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_module_query)] |
66 | fn lower_module_module( | 63 | fn lower_module_module(&self, module: Module) -> Arc<LoweredModule>; |
67 | &self, | ||
68 | source_root_id: SourceRootId, | ||
69 | module_id: ModuleId, | ||
70 | ) -> Arc<LoweredModule>; | ||
71 | 64 | ||
72 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)] | 65 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)] |
73 | fn lower_module_source_map( | 66 | fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>; |
74 | &self, | ||
75 | source_root_id: SourceRootId, | ||
76 | module_id: ModuleId, | ||
77 | ) -> Arc<ImportSourceMap>; | ||
78 | 67 | ||
79 | #[salsa::invoke(query_definitions::item_map)] | 68 | #[salsa::invoke(query_definitions::item_map)] |
80 | fn item_map(&self, source_root_id: SourceRootId) -> Arc<ItemMap>; | 69 | fn item_map(&self, crate_id: CrateId) -> Arc<ItemMap>; |
81 | 70 | ||
82 | #[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)] | 71 | #[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)] |
83 | fn module_tree(&self, source_root_id: SourceRootId) -> Arc<ModuleTree>; | 72 | fn module_tree(&self, crate_id: CrateId) -> Arc<ModuleTree>; |
84 | 73 | ||
85 | #[salsa::invoke(crate::impl_block::impls_in_module)] | 74 | #[salsa::invoke(crate::impl_block::impls_in_module)] |
86 | fn impls_in_module( | 75 | fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>; |
87 | &self, | ||
88 | source_root_id: SourceRootId, | ||
89 | module_id: ModuleId, | ||
90 | ) -> Arc<ModuleImplBlocks>; | ||
91 | 76 | ||
92 | #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] | 77 | #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] |
93 | fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>; | 78 | fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>; |
94 | 79 | ||
95 | #[salsa::invoke(crate::expr::body_hir)] | 80 | #[salsa::invoke(crate::expr::body_hir)] |
96 | fn body_hir(&self, def_id: DefId) -> Arc<crate::expr::Body>; | 81 | fn body_hir(&self, func: Function) -> Arc<crate::expr::Body>; |
97 | 82 | ||
98 | #[salsa::invoke(crate::expr::body_syntax_mapping)] | 83 | #[salsa::invoke(crate::expr::body_syntax_mapping)] |
99 | fn body_syntax_mapping(&self, def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping>; | 84 | fn body_syntax_mapping(&self, func: Function) -> Arc<crate::expr::BodySyntaxMapping>; |
100 | 85 | ||
101 | #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] | 86 | #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] |
102 | fn generic_params(&self, def_id: DefId) -> Arc<GenericParams>; | 87 | fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>; |
103 | 88 | ||
104 | #[salsa::invoke(crate::FnSignature::fn_signature_query)] | 89 | #[salsa::invoke(crate::FnSignature::fn_signature_query)] |
105 | fn fn_signature(&self, def_id: DefId) -> Arc<FnSignature>; | 90 | fn fn_signature(&self, func: Function) -> Arc<FnSignature>; |
106 | } | 91 | } |