add file items query
This commit is contained in:
parent
8e37208040
commit
16cdd126b6
3 changed files with 41 additions and 14 deletions
|
@ -7,10 +7,7 @@ use salsa::{self, Database};
|
|||
|
||||
use crate::{
|
||||
db,
|
||||
descriptors::{
|
||||
DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleTreeQuery,
|
||||
SubmodulesQuery, ItemMapQuery, InputModuleItemsQuery,
|
||||
},
|
||||
descriptors,
|
||||
symbol_index::SymbolIndex,
|
||||
syntax_ptr::SyntaxPtr,
|
||||
loc2id::{IdMaps, IdDatabase},
|
||||
|
@ -125,13 +122,15 @@ salsa::database_storage! {
|
|||
fn file_symbols() for FileSymbolsQuery;
|
||||
fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
|
||||
}
|
||||
impl DescriptorDatabase {
|
||||
fn module_tree() for ModuleTreeQuery;
|
||||
fn fn_scopes() for FnScopesQuery;
|
||||
fn _input_module_items() for InputModuleItemsQuery;
|
||||
fn _item_map() for ItemMapQuery;
|
||||
fn _fn_syntax() for FnSyntaxQuery;
|
||||
fn _submodules() for SubmodulesQuery;
|
||||
impl descriptors::DescriptorDatabase {
|
||||
fn module_tree() for descriptors::ModuleTreeQuery;
|
||||
fn fn_scopes() for descriptors::FnScopesQuery;
|
||||
fn _file_items() for descriptors::FileItemsQuery;
|
||||
fn _file_item() for descriptors::FileItemQuery;
|
||||
fn _input_module_items() for descriptors::InputModuleItemsQuery;
|
||||
fn _item_map() for descriptors::ItemMapQuery;
|
||||
fn _fn_syntax() for descriptors::FnSyntaxQuery;
|
||||
fn _submodules() for descriptors::SubmodulesQuery;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,14 @@ use std::sync::Arc;
|
|||
|
||||
use ra_syntax::{
|
||||
ast::{self, FnDefNode, AstNode},
|
||||
TextRange,
|
||||
TextRange, SyntaxNode,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
FileId,
|
||||
db::SyntaxDatabase,
|
||||
descriptors::function::{resolve_local_name, FnId, FnScopes},
|
||||
descriptors::module::{ModuleId, ModuleTree, ModuleSource, nameres::{ItemMap, InputModuleItems}},
|
||||
descriptors::module::{ModuleId, ModuleTree, ModuleSource, nameres::{ItemMap, InputModuleItems, FileItemId}},
|
||||
input::SourceRootId,
|
||||
loc2id::IdDatabase,
|
||||
syntax_ptr::LocalSyntaxPtr,
|
||||
|
@ -28,6 +29,18 @@ salsa::query_group! {
|
|||
use fn function::imp::fn_scopes;
|
||||
}
|
||||
|
||||
fn _file_items(file_id: FileId) -> Arc<Vec<SyntaxNode>> {
|
||||
type FileItemsQuery;
|
||||
storage volatile;
|
||||
use fn module::nameres::file_items;
|
||||
}
|
||||
|
||||
fn _file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
|
||||
type FileItemQuery;
|
||||
storage volatile;
|
||||
use fn module::nameres::file_item;
|
||||
}
|
||||
|
||||
fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> {
|
||||
type InputModuleItemsQuery;
|
||||
use fn module::nameres::input_module_items;
|
||||
|
|
|
@ -22,12 +22,13 @@ use std::{
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ra_syntax::{
|
||||
SyntaxNode,
|
||||
SmolStr, SyntaxKind::{self, *},
|
||||
ast::{self, ModuleItemOwner}
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Cancelable,
|
||||
Cancelable, FileId,
|
||||
loc2id::{DefId, DefLoc},
|
||||
descriptors::{
|
||||
Path, PathKind,
|
||||
|
@ -38,6 +39,20 @@ use crate::{
|
|||
input::SourceRootId,
|
||||
};
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
|
||||
pub(crate) struct FileItemId(u32);
|
||||
|
||||
pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc<Vec<SyntaxNode>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub(crate) fn file_item(db: &impl DescriptorDatabase, file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
|
||||
let items = db._file_items(file_id);
|
||||
let idx = file_item_id.0 as usize;
|
||||
items[idx].clone()
|
||||
}
|
||||
|
||||
/// Item map is the result of the name resolution. Item map contains, for each
|
||||
/// module, the set of visible items.
|
||||
#[derive(Default, Debug, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Reference in a new issue