mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
add file items query
This commit is contained in:
parent
8e37208040
commit
16cdd126b6
@ -7,10 +7,7 @@ use salsa::{self, Database};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db,
|
db,
|
||||||
descriptors::{
|
descriptors,
|
||||||
DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleTreeQuery,
|
|
||||||
SubmodulesQuery, ItemMapQuery, InputModuleItemsQuery,
|
|
||||||
},
|
|
||||||
symbol_index::SymbolIndex,
|
symbol_index::SymbolIndex,
|
||||||
syntax_ptr::SyntaxPtr,
|
syntax_ptr::SyntaxPtr,
|
||||||
loc2id::{IdMaps, IdDatabase},
|
loc2id::{IdMaps, IdDatabase},
|
||||||
@ -125,13 +122,15 @@ salsa::database_storage! {
|
|||||||
fn file_symbols() for FileSymbolsQuery;
|
fn file_symbols() for FileSymbolsQuery;
|
||||||
fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
|
fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
|
||||||
}
|
}
|
||||||
impl DescriptorDatabase {
|
impl descriptors::DescriptorDatabase {
|
||||||
fn module_tree() for ModuleTreeQuery;
|
fn module_tree() for descriptors::ModuleTreeQuery;
|
||||||
fn fn_scopes() for FnScopesQuery;
|
fn fn_scopes() for descriptors::FnScopesQuery;
|
||||||
fn _input_module_items() for InputModuleItemsQuery;
|
fn _file_items() for descriptors::FileItemsQuery;
|
||||||
fn _item_map() for ItemMapQuery;
|
fn _file_item() for descriptors::FileItemQuery;
|
||||||
fn _fn_syntax() for FnSyntaxQuery;
|
fn _input_module_items() for descriptors::InputModuleItemsQuery;
|
||||||
fn _submodules() for SubmodulesQuery;
|
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::{
|
use ra_syntax::{
|
||||||
ast::{self, FnDefNode, AstNode},
|
ast::{self, FnDefNode, AstNode},
|
||||||
TextRange,
|
TextRange, SyntaxNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
FileId,
|
||||||
db::SyntaxDatabase,
|
db::SyntaxDatabase,
|
||||||
descriptors::function::{resolve_local_name, FnId, FnScopes},
|
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,
|
input::SourceRootId,
|
||||||
loc2id::IdDatabase,
|
loc2id::IdDatabase,
|
||||||
syntax_ptr::LocalSyntaxPtr,
|
syntax_ptr::LocalSyntaxPtr,
|
||||||
@ -28,6 +29,18 @@ salsa::query_group! {
|
|||||||
use fn function::imp::fn_scopes;
|
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>> {
|
fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> {
|
||||||
type InputModuleItemsQuery;
|
type InputModuleItemsQuery;
|
||||||
use fn module::nameres::input_module_items;
|
use fn module::nameres::input_module_items;
|
||||||
|
@ -22,12 +22,13 @@ use std::{
|
|||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
|
SyntaxNode,
|
||||||
SmolStr, SyntaxKind::{self, *},
|
SmolStr, SyntaxKind::{self, *},
|
||||||
ast::{self, ModuleItemOwner}
|
ast::{self, ModuleItemOwner}
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Cancelable,
|
Cancelable, FileId,
|
||||||
loc2id::{DefId, DefLoc},
|
loc2id::{DefId, DefLoc},
|
||||||
descriptors::{
|
descriptors::{
|
||||||
Path, PathKind,
|
Path, PathKind,
|
||||||
@ -38,6 +39,20 @@ use crate::{
|
|||||||
input::SourceRootId,
|
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
|
/// Item map is the result of the name resolution. Item map contains, for each
|
||||||
/// module, the set of visible items.
|
/// module, the set of visible items.
|
||||||
#[derive(Default, Debug, PartialEq, Eq)]
|
#[derive(Default, Debug, PartialEq, Eq)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user