1
1
use std:: sync:: Arc ;
2
2
3
3
use ra_syntax:: { SyntaxNode , TreeArc , SourceFile } ;
4
- use ra_db:: { SourceRootId , LocationIntener , SyntaxDatabase } ;
4
+ use ra_db:: { SourceRootId , LocationIntener , SyntaxDatabase , salsa } ;
5
5
6
6
use crate :: {
7
7
DefLoc , DefId , MacroCallLoc , MacroCallId , Name , HirFileId ,
@@ -16,111 +16,77 @@ use crate::{
16
16
impl_block:: ModuleImplBlocks ,
17
17
} ;
18
18
19
- salsa:: query_group! {
20
-
21
- pub trait HirDatabase : SyntaxDatabase
19
+ # [ salsa:: query_group]
20
+ pub trait HirDatabase :
21
+ SyntaxDatabase
22
22
+ AsRef < LocationIntener < DefLoc , DefId > >
23
23
+ AsRef < LocationIntener < MacroCallLoc , MacroCallId > >
24
24
{
25
- fn hir_source_file( file_id: HirFileId ) -> TreeArc <SourceFile > {
26
- type HirSourceFileQuery ;
27
- use fn HirFileId :: hir_source_file;
28
- }
29
-
30
- fn expand_macro_invocation( invoc: MacroCallId ) -> Option <Arc <MacroExpansion >> {
31
- type ExpandMacroCallQuery ;
32
- use fn crate :: macros:: expand_macro_invocation;
33
- }
34
-
35
- fn fn_scopes( def_id: DefId ) -> Arc <FnScopes > {
36
- type FnScopesQuery ;
37
- use fn query_definitions:: fn_scopes;
38
- }
39
-
40
- fn struct_data( def_id: DefId ) -> Arc <StructData > {
41
- type StructDataQuery ;
42
- use fn crate :: adt:: StructData :: struct_data_query;
43
- }
44
-
45
- fn enum_data( def_id: DefId ) -> Arc <EnumData > {
46
- type EnumDataQuery ;
47
- use fn crate :: adt:: EnumData :: enum_data_query;
48
- }
49
-
50
- fn enum_variant_data( def_id: DefId ) -> Arc <EnumVariantData > {
51
- type EnumVariantDataQuery ;
52
- use fn crate :: adt:: EnumVariantData :: enum_variant_data_query;
53
- }
54
-
55
- fn infer( def_id: DefId ) -> Arc <InferenceResult > {
56
- type InferQuery ;
57
- use fn crate :: ty:: infer;
58
- }
59
-
60
- fn type_for_def( def_id: DefId ) -> Ty {
61
- type TypeForDefQuery ;
62
- use fn crate :: ty:: type_for_def;
63
- }
64
-
65
- fn type_for_field( def_id: DefId , field: Name ) -> Option <Ty > {
66
- type TypeForFieldQuery ;
67
- use fn crate :: ty:: type_for_field;
68
- }
69
-
70
- fn file_items( file_id: HirFileId ) -> Arc <SourceFileItems > {
71
- type SourceFileItemsQuery ;
72
- use fn query_definitions:: file_items;
73
- }
74
-
75
- fn file_item( source_item_id: SourceItemId ) -> TreeArc <SyntaxNode > {
76
- type FileItemQuery ;
77
- use fn query_definitions:: file_item;
78
- }
79
-
80
- fn submodules( source: SourceItemId ) -> Arc <Vec <crate :: module_tree:: Submodule >> {
81
- type SubmodulesQuery ;
82
- use fn crate :: module_tree:: Submodule :: submodules_query;
83
- }
84
-
85
- fn input_module_items( source_root_id: SourceRootId , module_id: ModuleId ) -> Arc <InputModuleItems > {
86
- type InputModuleItemsQuery ;
87
- use fn query_definitions:: input_module_items;
88
- }
89
-
90
- fn item_map( source_root_id: SourceRootId ) -> Arc <ItemMap > {
91
- type ItemMapQuery ;
92
- use fn query_definitions:: item_map;
93
- }
94
-
95
- fn module_tree( source_root_id: SourceRootId ) -> Arc <ModuleTree > {
96
- type ModuleTreeQuery ;
97
- use fn crate :: module_tree:: ModuleTree :: module_tree_query;
98
- }
99
-
100
- fn impls_in_module( source_root_id: SourceRootId , module_id: ModuleId ) -> Arc <ModuleImplBlocks > {
101
- type ImplsInModuleQuery ;
102
- use fn crate :: impl_block:: impls_in_module;
103
- }
104
-
105
- fn impls_in_crate( krate: Crate ) -> Arc <CrateImplBlocks > {
106
- type ImplsInCrateQuery ;
107
- use fn crate :: ty:: method_resolution:: CrateImplBlocks :: impls_in_crate_query;
108
- }
109
-
110
- fn body_hir( def_id: DefId ) -> Arc <crate :: expr:: Body > {
111
- type BodyHirQuery ;
112
- use fn crate :: expr:: body_hir;
113
- }
114
-
115
- fn body_syntax_mapping( def_id: DefId ) -> Arc <crate :: expr:: BodySyntaxMapping > {
116
- type BodySyntaxMappingQuery ;
117
- use fn crate :: expr:: body_syntax_mapping;
118
- }
119
-
120
- fn fn_signature( def_id: DefId ) -> Arc <FnSignature > {
121
- type FnSignatureQuery ;
122
- use fn crate :: FnSignature :: fn_signature_query;
123
- }
124
- }
25
+ #[ salsa:: invoke( HirFileId :: hir_source_file) ]
26
+ fn hir_source_file ( & self , file_id : HirFileId ) -> TreeArc < SourceFile > ;
27
+
28
+ #[ salsa:: invoke( crate :: macros:: expand_macro_invocation) ]
29
+ fn expand_macro_invocation ( & self , invoc : MacroCallId ) -> Option < Arc < MacroExpansion > > ;
30
+
31
+ #[ salsa:: invoke( query_definitions:: fn_scopes) ]
32
+ fn fn_scopes ( & self , def_id : DefId ) -> Arc < FnScopes > ;
33
+
34
+ #[ salsa:: invoke( crate :: adt:: StructData :: struct_data_query) ]
35
+ fn struct_data ( & self , def_id : DefId ) -> Arc < StructData > ;
36
+
37
+ #[ salsa:: invoke( crate :: adt:: EnumData :: enum_data_query) ]
38
+ fn enum_data ( & self , def_id : DefId ) -> Arc < EnumData > ;
39
+
40
+ #[ salsa:: invoke( crate :: adt:: EnumVariantData :: enum_variant_data_query) ]
41
+ fn enum_variant_data ( & self , def_id : DefId ) -> Arc < EnumVariantData > ;
42
+
43
+ #[ salsa:: invoke( crate :: ty:: infer) ]
44
+ fn infer ( & self , def_id : DefId ) -> Arc < InferenceResult > ;
45
+
46
+ #[ salsa:: invoke( crate :: ty:: type_for_def) ]
47
+ fn type_for_def ( & self , def_id : DefId ) -> Ty ;
48
+
49
+ #[ salsa:: invoke( crate :: ty:: type_for_field) ]
50
+ fn type_for_field ( & self , def_id : DefId , field : Name ) -> Option < Ty > ;
51
+
52
+ #[ salsa:: invoke( query_definitions:: file_items) ]
53
+ fn file_items ( & self , file_id : HirFileId ) -> Arc < SourceFileItems > ;
54
+
55
+ #[ salsa:: invoke( query_definitions:: file_item) ]
56
+ fn file_item ( & self , source_item_id : SourceItemId ) -> TreeArc < SyntaxNode > ;
57
+
58
+ #[ salsa:: invoke( crate :: module_tree:: Submodule :: submodules_query) ]
59
+ fn submodules ( & self , source : SourceItemId ) -> Arc < Vec < crate :: module_tree:: Submodule > > ;
60
+
61
+ #[ salsa:: invoke( query_definitions:: input_module_items) ]
62
+ fn input_module_items (
63
+ & self ,
64
+ source_root_id : SourceRootId ,
65
+ module_id : ModuleId ,
66
+ ) -> Arc < InputModuleItems > ;
67
+
68
+ #[ salsa:: invoke( query_definitions:: item_map) ]
69
+ fn item_map ( & self , source_root_id : SourceRootId ) -> Arc < ItemMap > ;
70
+
71
+ #[ salsa:: invoke( crate :: module_tree:: ModuleTree :: module_tree_query) ]
72
+ fn module_tree ( & self , source_root_id : SourceRootId ) -> Arc < ModuleTree > ;
73
+
74
+ #[ salsa:: invoke( crate :: impl_block:: impls_in_module) ]
75
+ fn impls_in_module (
76
+ & self ,
77
+ source_root_id : SourceRootId ,
78
+ module_id : ModuleId ,
79
+ ) -> Arc < ModuleImplBlocks > ;
80
+
81
+ #[ salsa:: invoke( crate :: ty:: method_resolution:: CrateImplBlocks :: impls_in_crate_query) ]
82
+ fn impls_in_crate ( & self , krate : Crate ) -> Arc < CrateImplBlocks > ;
83
+
84
+ #[ salsa:: invoke( crate :: expr:: body_hir) ]
85
+ fn body_hir ( & self , def_id : DefId ) -> Arc < crate :: expr:: Body > ;
86
+
87
+ #[ salsa:: invoke( crate :: expr:: body_syntax_mapping) ]
88
+ fn body_syntax_mapping ( & self , def_id : DefId ) -> Arc < crate :: expr:: BodySyntaxMapping > ;
125
89
90
+ #[ salsa:: invoke( crate :: FnSignature :: fn_signature_query) ]
91
+ fn fn_signature ( & self , def_id : DefId ) -> Arc < FnSignature > ;
126
92
}
0 commit comments