mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
add item map query
This commit is contained in:
parent
9bb11aee44
commit
36aad85138
4 changed files with 23 additions and 8 deletions
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
db,
|
db,
|
||||||
descriptors::{
|
descriptors::{
|
||||||
DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleScopeQuery, ModuleTreeQuery,
|
DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleScopeQuery, ModuleTreeQuery,
|
||||||
SubmodulesQuery,
|
SubmodulesQuery, ItemMapQuery,
|
||||||
},
|
},
|
||||||
symbol_index::SymbolIndex,
|
symbol_index::SymbolIndex,
|
||||||
syntax_ptr::SyntaxPtr,
|
syntax_ptr::SyntaxPtr,
|
||||||
|
@ -85,8 +85,9 @@ salsa::database_storage! {
|
||||||
}
|
}
|
||||||
impl DescriptorDatabase {
|
impl DescriptorDatabase {
|
||||||
fn module_tree() for ModuleTreeQuery;
|
fn module_tree() for ModuleTreeQuery;
|
||||||
fn module_scope() for ModuleScopeQuery;
|
|
||||||
fn fn_scopes() for FnScopesQuery;
|
fn fn_scopes() for FnScopesQuery;
|
||||||
|
fn _item_map() for ItemMapQuery;
|
||||||
|
fn _module_scope() for ModuleScopeQuery;
|
||||||
fn _fn_syntax() for FnSyntaxQuery;
|
fn _fn_syntax() for FnSyntaxQuery;
|
||||||
fn _submodules() for SubmodulesQuery;
|
fn _submodules() for SubmodulesQuery;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use ra_syntax::{
|
||||||
use crate::{
|
use crate::{
|
||||||
db::SyntaxDatabase,
|
db::SyntaxDatabase,
|
||||||
descriptors::function::{resolve_local_name, FnId, FnScopes},
|
descriptors::function::{resolve_local_name, FnId, FnScopes},
|
||||||
descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource},
|
descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource, nameres::ItemMap},
|
||||||
input::SourceRootId,
|
input::SourceRootId,
|
||||||
loc2id::IdDatabase,
|
loc2id::IdDatabase,
|
||||||
syntax_ptr::LocalSyntaxPtr,
|
syntax_ptr::LocalSyntaxPtr,
|
||||||
|
@ -25,6 +25,10 @@ salsa::query_group! {
|
||||||
use fn function::imp::fn_scopes;
|
use fn function::imp::fn_scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn _item_map(source_root_id: SourceRootId) -> Cancelable<Arc<ItemMap>> {
|
||||||
|
type ItemMapQuery;
|
||||||
|
use fn module::nameres::item_map;
|
||||||
|
}
|
||||||
fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
|
fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
|
||||||
type ModuleTreeQuery;
|
type ModuleTreeQuery;
|
||||||
use fn module::imp::module_tree;
|
use fn module::imp::module_tree;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pub(super) mod imp;
|
pub(super) mod imp;
|
||||||
mod scope;
|
mod scope;
|
||||||
mod nameres;
|
pub(super) mod nameres;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ use ra_syntax::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Cancelable,
|
||||||
loc2id::{DefId, DefLoc},
|
loc2id::{DefId, DefLoc},
|
||||||
descriptors::{
|
descriptors::{
|
||||||
DescriptorDatabase,
|
DescriptorDatabase,
|
||||||
|
@ -45,12 +46,21 @@ enum PathKind {
|
||||||
Crate,
|
Crate,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
pub(crate) fn item_map(
|
||||||
struct ItemMap {
|
db: &impl DescriptorDatabase,
|
||||||
|
source_root: SourceRootId,
|
||||||
|
) -> Cancelable<Arc<ItemMap>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Item map is the result of the name resolution. Item map contains, for each
|
||||||
|
/// module, the set of visible items.
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub(crate) struct ItemMap {
|
||||||
per_module: FxHashMap<ModuleId, ModuleItems>,
|
per_module: FxHashMap<ModuleId, ModuleItems>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, PartialEq, Eq)]
|
||||||
struct ModuleItems {
|
struct ModuleItems {
|
||||||
items: FxHashMap<SmolStr, Resolution>,
|
items: FxHashMap<SmolStr, Resolution>,
|
||||||
import_resolutions: FxHashMap<LocalSyntaxPtr, DefId>,
|
import_resolutions: FxHashMap<LocalSyntaxPtr, DefId>,
|
||||||
|
@ -58,7 +68,7 @@ struct ModuleItems {
|
||||||
|
|
||||||
/// Resolution is basically `DefId` atm, but it should account for stuff like
|
/// Resolution is basically `DefId` atm, but it should account for stuff like
|
||||||
/// multiple namespaces, ambiguity and errors.
|
/// multiple namespaces, ambiguity and errors.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
struct Resolution {
|
struct Resolution {
|
||||||
/// None for unresolved
|
/// None for unresolved
|
||||||
def_id: Option<DefId>,
|
def_id: Option<DefId>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue