diff options
Diffstat (limited to 'crates/ra_analysis/src/descriptors')
-rw-r--r-- | crates/ra_analysis/src/descriptors/mod.rs | 17 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/nameres.rs | 17 |
2 files changed, 31 insertions, 3 deletions
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)] |