aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-20 21:39:50 +0000
committerAleksey Kladov <[email protected]>2018-11-20 21:39:50 +0000
commit36aad851383c7fd1ca5ffaa99ba8cc96b85378c1 (patch)
tree512fce887b8d79fa2d6442dde5c5b0262ac4757f /crates
parent9bb11aee44f377fdf2ce7bed5c09ccbcf30f9b57 (diff)
add item map query
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/db.rs5
-rw-r--r--crates/ra_analysis/src/descriptors/mod.rs6
-rw-r--r--crates/ra_analysis/src/descriptors/module/mod.rs2
-rw-r--r--crates/ra_analysis/src/descriptors/module/nameres.rs18
4 files changed, 23 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs
index 8133b7875..cecce3447 100644
--- a/crates/ra_analysis/src/db.rs
+++ b/crates/ra_analysis/src/db.rs
@@ -8,7 +8,7 @@ use crate::{
8 db, 8 db,
9 descriptors::{ 9 descriptors::{
10 DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleScopeQuery, ModuleTreeQuery, 10 DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleScopeQuery, ModuleTreeQuery,
11 SubmodulesQuery, 11 SubmodulesQuery, ItemMapQuery,
12 }, 12 },
13 symbol_index::SymbolIndex, 13 symbol_index::SymbolIndex,
14 syntax_ptr::SyntaxPtr, 14 syntax_ptr::SyntaxPtr,
@@ -85,8 +85,9 @@ salsa::database_storage! {
85 } 85 }
86 impl DescriptorDatabase { 86 impl DescriptorDatabase {
87 fn module_tree() for ModuleTreeQuery; 87 fn module_tree() for ModuleTreeQuery;
88 fn module_scope() for ModuleScopeQuery;
89 fn fn_scopes() for FnScopesQuery; 88 fn fn_scopes() for FnScopesQuery;
89 fn _item_map() for ItemMapQuery;
90 fn _module_scope() for ModuleScopeQuery;
90 fn _fn_syntax() for FnSyntaxQuery; 91 fn _fn_syntax() for FnSyntaxQuery;
91 fn _submodules() for SubmodulesQuery; 92 fn _submodules() for SubmodulesQuery;
92 } 93 }
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs
index a8489f89c..30bc5eca2 100644
--- a/crates/ra_analysis/src/descriptors/mod.rs
+++ b/crates/ra_analysis/src/descriptors/mod.rs
@@ -11,7 +11,7 @@ use ra_syntax::{
11use crate::{ 11use crate::{
12 db::SyntaxDatabase, 12 db::SyntaxDatabase,
13 descriptors::function::{resolve_local_name, FnId, FnScopes}, 13 descriptors::function::{resolve_local_name, FnId, FnScopes},
14 descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource}, 14 descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource, nameres::ItemMap},
15 input::SourceRootId, 15 input::SourceRootId,
16 loc2id::IdDatabase, 16 loc2id::IdDatabase,
17 syntax_ptr::LocalSyntaxPtr, 17 syntax_ptr::LocalSyntaxPtr,
@@ -25,6 +25,10 @@ salsa::query_group! {
25 use fn function::imp::fn_scopes; 25 use fn function::imp::fn_scopes;
26 } 26 }
27 27
28 fn _item_map(source_root_id: SourceRootId) -> Cancelable<Arc<ItemMap>> {
29 type ItemMapQuery;
30 use fn module::nameres::item_map;
31 }
28 fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> { 32 fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
29 type ModuleTreeQuery; 33 type ModuleTreeQuery;
30 use fn module::imp::module_tree; 34 use fn module::imp::module_tree;
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs
index 2d0bfa64c..124926a40 100644
--- a/crates/ra_analysis/src/descriptors/module/mod.rs
+++ b/crates/ra_analysis/src/descriptors/module/mod.rs
@@ -1,6 +1,6 @@
1pub(super) mod imp; 1pub(super) mod imp;
2mod scope; 2mod scope;
3mod nameres; 3pub(super) mod nameres;
4 4
5use std::sync::Arc; 5use std::sync::Arc;
6 6
diff --git a/crates/ra_analysis/src/descriptors/module/nameres.rs b/crates/ra_analysis/src/descriptors/module/nameres.rs
index 058e64ad1..657e5bd1c 100644
--- a/crates/ra_analysis/src/descriptors/module/nameres.rs
+++ b/crates/ra_analysis/src/descriptors/module/nameres.rs
@@ -9,6 +9,7 @@ use ra_syntax::{
9}; 9};
10 10
11use crate::{ 11use crate::{
12 Cancelable,
12 loc2id::{DefId, DefLoc}, 13 loc2id::{DefId, DefLoc},
13 descriptors::{ 14 descriptors::{
14 DescriptorDatabase, 15 DescriptorDatabase,
@@ -45,12 +46,21 @@ enum PathKind {
45 Crate, 46 Crate,
46} 47}
47 48
48#[derive(Debug)] 49pub(crate) fn item_map(
49struct ItemMap { 50 db: &impl DescriptorDatabase,
51 source_root: SourceRootId,
52) -> Cancelable<Arc<ItemMap>> {
53 unimplemented!()
54}
55
56/// Item map is the result of the name resolution. Item map contains, for each
57/// module, the set of visible items.
58#[derive(Debug, PartialEq, Eq)]
59pub(crate) struct ItemMap {
50 per_module: FxHashMap<ModuleId, ModuleItems>, 60 per_module: FxHashMap<ModuleId, ModuleItems>,
51} 61}
52 62
53#[derive(Debug, Default)] 63#[derive(Debug, Default, PartialEq, Eq)]
54struct ModuleItems { 64struct ModuleItems {
55 items: FxHashMap<SmolStr, Resolution>, 65 items: FxHashMap<SmolStr, Resolution>,
56 import_resolutions: FxHashMap<LocalSyntaxPtr, DefId>, 66 import_resolutions: FxHashMap<LocalSyntaxPtr, DefId>,
@@ -58,7 +68,7 @@ struct ModuleItems {
58 68
59/// Resolution is basically `DefId` atm, but it should account for stuff like 69/// Resolution is basically `DefId` atm, but it should account for stuff like
60/// multiple namespaces, ambiguity and errors. 70/// multiple namespaces, ambiguity and errors.
61#[derive(Debug, Clone)] 71#[derive(Debug, Clone, PartialEq, Eq)]
62struct Resolution { 72struct Resolution {
63 /// None for unresolved 73 /// None for unresolved
64 def_id: Option<DefId>, 74 def_id: Option<DefId>,