diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/db.rs | 21 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/mod.rs | 17 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/nameres.rs | 17 |
3 files changed, 41 insertions, 14 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index 6b56f99ac..418711300 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -7,10 +7,7 @@ use salsa::{self, Database}; | |||
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | db, | 9 | db, |
10 | descriptors::{ | 10 | descriptors, |
11 | DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleTreeQuery, | ||
12 | SubmodulesQuery, ItemMapQuery, InputModuleItemsQuery, | ||
13 | }, | ||
14 | symbol_index::SymbolIndex, | 11 | symbol_index::SymbolIndex, |
15 | syntax_ptr::SyntaxPtr, | 12 | syntax_ptr::SyntaxPtr, |
16 | loc2id::{IdMaps, IdDatabase}, | 13 | loc2id::{IdMaps, IdDatabase}, |
@@ -125,13 +122,15 @@ salsa::database_storage! { | |||
125 | fn file_symbols() for FileSymbolsQuery; | 122 | fn file_symbols() for FileSymbolsQuery; |
126 | fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; | 123 | fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; |
127 | } | 124 | } |
128 | impl DescriptorDatabase { | 125 | impl descriptors::DescriptorDatabase { |
129 | fn module_tree() for ModuleTreeQuery; | 126 | fn module_tree() for descriptors::ModuleTreeQuery; |
130 | fn fn_scopes() for FnScopesQuery; | 127 | fn fn_scopes() for descriptors::FnScopesQuery; |
131 | fn _input_module_items() for InputModuleItemsQuery; | 128 | fn _file_items() for descriptors::FileItemsQuery; |
132 | fn _item_map() for ItemMapQuery; | 129 | fn _file_item() for descriptors::FileItemQuery; |
133 | fn _fn_syntax() for FnSyntaxQuery; | 130 | fn _input_module_items() for descriptors::InputModuleItemsQuery; |
134 | fn _submodules() for SubmodulesQuery; | 131 | fn _item_map() for descriptors::ItemMapQuery; |
132 | fn _fn_syntax() for descriptors::FnSyntaxQuery; | ||
133 | fn _submodules() for descriptors::SubmodulesQuery; | ||
135 | } | 134 | } |
136 | } | 135 | } |
137 | } | 136 | } |
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs index 97750ea64..f6b9102e7 100644 --- a/crates/ra_analysis/src/descriptors/mod.rs +++ b/crates/ra_analysis/src/descriptors/mod.rs | |||
@@ -6,13 +6,14 @@ use std::sync::Arc; | |||
6 | 6 | ||
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | ast::{self, FnDefNode, AstNode}, | 8 | ast::{self, FnDefNode, AstNode}, |
9 | TextRange, | 9 | TextRange, SyntaxNode, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | FileId, | ||
13 | db::SyntaxDatabase, | 14 | db::SyntaxDatabase, |
14 | descriptors::function::{resolve_local_name, FnId, FnScopes}, | 15 | descriptors::function::{resolve_local_name, FnId, FnScopes}, |
15 | descriptors::module::{ModuleId, ModuleTree, ModuleSource, nameres::{ItemMap, InputModuleItems}}, | 16 | descriptors::module::{ModuleId, ModuleTree, ModuleSource, nameres::{ItemMap, InputModuleItems, FileItemId}}, |
16 | input::SourceRootId, | 17 | input::SourceRootId, |
17 | loc2id::IdDatabase, | 18 | loc2id::IdDatabase, |
18 | syntax_ptr::LocalSyntaxPtr, | 19 | syntax_ptr::LocalSyntaxPtr, |
@@ -28,6 +29,18 @@ salsa::query_group! { | |||
28 | use fn function::imp::fn_scopes; | 29 | use fn function::imp::fn_scopes; |
29 | } | 30 | } |
30 | 31 | ||
32 | fn _file_items(file_id: FileId) -> Arc<Vec<SyntaxNode>> { | ||
33 | type FileItemsQuery; | ||
34 | storage volatile; | ||
35 | use fn module::nameres::file_items; | ||
36 | } | ||
37 | |||
38 | fn _file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode { | ||
39 | type FileItemQuery; | ||
40 | storage volatile; | ||
41 | use fn module::nameres::file_item; | ||
42 | } | ||
43 | |||
31 | fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> { | 44 | fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> { |
32 | type InputModuleItemsQuery; | 45 | type InputModuleItemsQuery; |
33 | use fn module::nameres::input_module_items; | 46 | use fn module::nameres::input_module_items; |
diff --git a/crates/ra_analysis/src/descriptors/module/nameres.rs b/crates/ra_analysis/src/descriptors/module/nameres.rs index 648ec5e43..6251f5b86 100644 --- a/crates/ra_analysis/src/descriptors/module/nameres.rs +++ b/crates/ra_analysis/src/descriptors/module/nameres.rs | |||
@@ -22,12 +22,13 @@ use std::{ | |||
22 | use rustc_hash::FxHashMap; | 22 | use rustc_hash::FxHashMap; |
23 | 23 | ||
24 | use ra_syntax::{ | 24 | use ra_syntax::{ |
25 | SyntaxNode, | ||
25 | SmolStr, SyntaxKind::{self, *}, | 26 | SmolStr, SyntaxKind::{self, *}, |
26 | ast::{self, ModuleItemOwner} | 27 | ast::{self, ModuleItemOwner} |
27 | }; | 28 | }; |
28 | 29 | ||
29 | use crate::{ | 30 | use crate::{ |
30 | Cancelable, | 31 | Cancelable, FileId, |
31 | loc2id::{DefId, DefLoc}, | 32 | loc2id::{DefId, DefLoc}, |
32 | descriptors::{ | 33 | descriptors::{ |
33 | Path, PathKind, | 34 | Path, PathKind, |
@@ -38,6 +39,20 @@ use crate::{ | |||
38 | input::SourceRootId, | 39 | input::SourceRootId, |
39 | }; | 40 | }; |
40 | 41 | ||
42 | |||
43 | #[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] | ||
44 | pub(crate) struct FileItemId(u32); | ||
45 | |||
46 | pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc<Vec<SyntaxNode>> { | ||
47 | unimplemented!() | ||
48 | } | ||
49 | |||
50 | pub(crate) fn file_item(db: &impl DescriptorDatabase, file_id: FileId, file_item_id: FileItemId) -> SyntaxNode { | ||
51 | let items = db._file_items(file_id); | ||
52 | let idx = file_item_id.0 as usize; | ||
53 | items[idx].clone() | ||
54 | } | ||
55 | |||
41 | /// Item map is the result of the name resolution. Item map contains, for each | 56 | /// Item map is the result of the name resolution. Item map contains, for each |
42 | /// module, the set of visible items. | 57 | /// module, the set of visible items. |
43 | #[derive(Default, Debug, PartialEq, Eq)] | 58 | #[derive(Default, Debug, PartialEq, Eq)] |