aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-27 20:03:08 +0000
committerAleksey Kladov <[email protected]>2018-11-27 20:03:08 +0000
commitf14902f67bbc5f68cb700b6b929b269d3d51a4a9 (patch)
tree79db5df67fc5fbc34fb61c5bfc2ce038e4198fc9 /crates/ra_analysis/src/hir
parent109a7f3717612c58c73c5c153b632385b922fc9d (diff)
move hir db
Diffstat (limited to 'crates/ra_analysis/src/hir')
-rw-r--r--crates/ra_analysis/src/hir/db.rs63
-rw-r--r--crates/ra_analysis/src/hir/mod.rs63
2 files changed, 69 insertions, 57 deletions
diff --git a/crates/ra_analysis/src/hir/db.rs b/crates/ra_analysis/src/hir/db.rs
new file mode 100644
index 000000000..3cdf8e6d6
--- /dev/null
+++ b/crates/ra_analysis/src/hir/db.rs
@@ -0,0 +1,63 @@
1use std::sync::Arc;
2
3use ra_syntax::{
4 SyntaxNode,
5 ast::FnDefNode,
6};
7
8use crate::{
9 FileId,
10 db::SyntaxDatabase,
11 hir::function::{FnId, FnScopes},
12 hir::module::{
13 ModuleId, ModuleTree, ModuleSource,
14 nameres::{ItemMap, InputModuleItems, FileItems, FileItemId}
15 },
16 input::SourceRootId,
17 loc2id::{IdDatabase},
18 Cancelable,
19};
20
21salsa::query_group! {
22pub(crate) trait HirDatabase: SyntaxDatabase + IdDatabase {
23 fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
24 type FnScopesQuery;
25 use fn crate::hir::function::imp::fn_scopes;
26 }
27
28 fn _file_items(file_id: FileId) -> Arc<FileItems> {
29 type FileItemsQuery;
30 storage dependencies;
31 use fn crate::hir::module::nameres::file_items;
32 }
33
34 fn _file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
35 type FileItemQuery;
36 storage dependencies;
37 use fn crate::hir::module::nameres::file_item;
38 }
39
40 fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> {
41 type InputModuleItemsQuery;
42 use fn crate::hir::module::nameres::input_module_items;
43 }
44 fn _item_map(source_root_id: SourceRootId) -> Cancelable<Arc<ItemMap>> {
45 type ItemMapQuery;
46 use fn crate::hir::module::nameres::item_map;
47 }
48 fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
49 type ModuleTreeQuery;
50 use fn crate::hir::module::imp::module_tree;
51 }
52 fn _fn_syntax(fn_id: FnId) -> FnDefNode {
53 type FnSyntaxQuery;
54 // Don't retain syntax trees in memory
55 storage dependencies;
56 use fn crate::hir::function::imp::fn_syntax;
57 }
58 fn _submodules(source: ModuleSource) -> Cancelable<Arc<Vec<crate::hir::module::imp::Submodule>>> {
59 type SubmodulesQuery;
60 use fn crate::hir::module::imp::submodules;
61 }
62 }
63}
diff --git a/crates/ra_analysis/src/hir/mod.rs b/crates/ra_analysis/src/hir/mod.rs
index edeaeb8e6..27ac71a26 100644
--- a/crates/ra_analysis/src/hir/mod.rs
+++ b/crates/ra_analysis/src/hir/mod.rs
@@ -7,25 +7,18 @@
7 7
8pub(crate) mod function; 8pub(crate) mod function;
9pub(crate) mod module; 9pub(crate) mod module;
10pub(crate) mod db;
10mod path; 11mod path;
11 12
12use std::sync::Arc;
13
14use ra_syntax::{ 13use ra_syntax::{
15 ast::{self, FnDefNode, AstNode}, 14 ast::{self, AstNode},
16 TextRange, SyntaxNode, 15 TextRange,
17}; 16};
18 17
19use crate::{ 18use crate::{
20 FileId, 19 hir::db::HirDatabase,
21 db::SyntaxDatabase, 20 hir::function::{resolve_local_name, FnScopes},
22 hir::function::{resolve_local_name, FnId, FnScopes}, 21 loc2id::{DefId, DefLoc},
23 hir::module::{
24 ModuleId, ModuleTree, ModuleSource,
25 nameres::{ItemMap, InputModuleItems, FileItems}
26 },
27 input::SourceRootId,
28 loc2id::{IdDatabase, DefId, DefLoc},
29 syntax_ptr::LocalSyntaxPtr, 22 syntax_ptr::LocalSyntaxPtr,
30 Cancelable, 23 Cancelable,
31}; 24};
@@ -36,50 +29,6 @@ pub(crate) use self::{
36 function::FunctionDescriptor, 29 function::FunctionDescriptor,
37}; 30};
38 31
39salsa::query_group! {
40pub(crate) trait HirDatabase: SyntaxDatabase + IdDatabase {
41 fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
42 type FnScopesQuery;
43 use fn function::imp::fn_scopes;
44 }
45
46 fn _file_items(file_id: FileId) -> Arc<FileItems> {
47 type FileItemsQuery;
48 storage dependencies;
49 use fn module::nameres::file_items;
50 }
51
52 fn _file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
53 type FileItemQuery;
54 storage dependencies;
55 use fn module::nameres::file_item;
56 }
57
58 fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> {
59 type InputModuleItemsQuery;
60 use fn module::nameres::input_module_items;
61 }
62 fn _item_map(source_root_id: SourceRootId) -> Cancelable<Arc<ItemMap>> {
63 type ItemMapQuery;
64 use fn module::nameres::item_map;
65 }
66 fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
67 type ModuleTreeQuery;
68 use fn module::imp::module_tree;
69 }
70 fn _fn_syntax(fn_id: FnId) -> FnDefNode {
71 type FnSyntaxQuery;
72 // Don't retain syntax trees in memory
73 storage dependencies;
74 use fn function::imp::fn_syntax;
75 }
76 fn _submodules(source: ModuleSource) -> Cancelable<Arc<Vec<module::imp::Submodule>>> {
77 type SubmodulesQuery;
78 use fn module::imp::submodules;
79 }
80 }
81}
82
83pub(crate) enum Def { 32pub(crate) enum Def {
84 Module(ModuleDescriptor), 33 Module(ModuleDescriptor),
85 Item, 34 Item,