mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
move hir db
This commit is contained in:
parent
109a7f3717
commit
f14902f67b
3 changed files with 78 additions and 66 deletions
|
@ -122,15 +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 hir::HirDatabase {
|
impl hir::db::HirDatabase {
|
||||||
fn module_tree() for hir::ModuleTreeQuery;
|
fn module_tree() for hir::db::ModuleTreeQuery;
|
||||||
fn fn_scopes() for hir::FnScopesQuery;
|
fn fn_scopes() for hir::db::FnScopesQuery;
|
||||||
fn _file_items() for hir::FileItemsQuery;
|
fn _file_items() for hir::db::FileItemsQuery;
|
||||||
fn _file_item() for hir::FileItemQuery;
|
fn _file_item() for hir::db::FileItemQuery;
|
||||||
fn _input_module_items() for hir::InputModuleItemsQuery;
|
fn _input_module_items() for hir::db::InputModuleItemsQuery;
|
||||||
fn _item_map() for hir::ItemMapQuery;
|
fn _item_map() for hir::db::ItemMapQuery;
|
||||||
fn _fn_syntax() for hir::FnSyntaxQuery;
|
fn _fn_syntax() for hir::db::FnSyntaxQuery;
|
||||||
fn _submodules() for hir::SubmodulesQuery;
|
fn _submodules() for hir::db::SubmodulesQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
63
crates/ra_analysis/src/hir/db.rs
Normal file
63
crates/ra_analysis/src/hir/db.rs
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use ra_syntax::{
|
||||||
|
SyntaxNode,
|
||||||
|
ast::FnDefNode,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
FileId,
|
||||||
|
db::SyntaxDatabase,
|
||||||
|
hir::function::{FnId, FnScopes},
|
||||||
|
hir::module::{
|
||||||
|
ModuleId, ModuleTree, ModuleSource,
|
||||||
|
nameres::{ItemMap, InputModuleItems, FileItems, FileItemId}
|
||||||
|
},
|
||||||
|
input::SourceRootId,
|
||||||
|
loc2id::{IdDatabase},
|
||||||
|
Cancelable,
|
||||||
|
};
|
||||||
|
|
||||||
|
salsa::query_group! {
|
||||||
|
pub(crate) trait HirDatabase: SyntaxDatabase + IdDatabase {
|
||||||
|
fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
|
||||||
|
type FnScopesQuery;
|
||||||
|
use fn crate::hir::function::imp::fn_scopes;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _file_items(file_id: FileId) -> Arc<FileItems> {
|
||||||
|
type FileItemsQuery;
|
||||||
|
storage dependencies;
|
||||||
|
use fn crate::hir::module::nameres::file_items;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
|
||||||
|
type FileItemQuery;
|
||||||
|
storage dependencies;
|
||||||
|
use fn crate::hir::module::nameres::file_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> {
|
||||||
|
type InputModuleItemsQuery;
|
||||||
|
use fn crate::hir::module::nameres::input_module_items;
|
||||||
|
}
|
||||||
|
fn _item_map(source_root_id: SourceRootId) -> Cancelable<Arc<ItemMap>> {
|
||||||
|
type ItemMapQuery;
|
||||||
|
use fn crate::hir::module::nameres::item_map;
|
||||||
|
}
|
||||||
|
fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
|
||||||
|
type ModuleTreeQuery;
|
||||||
|
use fn crate::hir::module::imp::module_tree;
|
||||||
|
}
|
||||||
|
fn _fn_syntax(fn_id: FnId) -> FnDefNode {
|
||||||
|
type FnSyntaxQuery;
|
||||||
|
// Don't retain syntax trees in memory
|
||||||
|
storage dependencies;
|
||||||
|
use fn crate::hir::function::imp::fn_syntax;
|
||||||
|
}
|
||||||
|
fn _submodules(source: ModuleSource) -> Cancelable<Arc<Vec<crate::hir::module::imp::Submodule>>> {
|
||||||
|
type SubmodulesQuery;
|
||||||
|
use fn crate::hir::module::imp::submodules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,25 +7,18 @@
|
||||||
|
|
||||||
pub(crate) mod function;
|
pub(crate) mod function;
|
||||||
pub(crate) mod module;
|
pub(crate) mod module;
|
||||||
|
pub(crate) mod db;
|
||||||
mod path;
|
mod path;
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
ast::{self, FnDefNode, AstNode},
|
ast::{self, AstNode},
|
||||||
TextRange, SyntaxNode,
|
TextRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
FileId,
|
hir::db::HirDatabase,
|
||||||
db::SyntaxDatabase,
|
hir::function::{resolve_local_name, FnScopes},
|
||||||
hir::function::{resolve_local_name, FnId, FnScopes},
|
loc2id::{DefId, DefLoc},
|
||||||
hir::module::{
|
|
||||||
ModuleId, ModuleTree, ModuleSource,
|
|
||||||
nameres::{ItemMap, InputModuleItems, FileItems}
|
|
||||||
},
|
|
||||||
input::SourceRootId,
|
|
||||||
loc2id::{IdDatabase, DefId, DefLoc},
|
|
||||||
syntax_ptr::LocalSyntaxPtr,
|
syntax_ptr::LocalSyntaxPtr,
|
||||||
Cancelable,
|
Cancelable,
|
||||||
};
|
};
|
||||||
|
@ -36,50 +29,6 @@ pub(crate) use self::{
|
||||||
function::FunctionDescriptor,
|
function::FunctionDescriptor,
|
||||||
};
|
};
|
||||||
|
|
||||||
salsa::query_group! {
|
|
||||||
pub(crate) trait HirDatabase: SyntaxDatabase + IdDatabase {
|
|
||||||
fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
|
|
||||||
type FnScopesQuery;
|
|
||||||
use fn function::imp::fn_scopes;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _file_items(file_id: FileId) -> Arc<FileItems> {
|
|
||||||
type FileItemsQuery;
|
|
||||||
storage dependencies;
|
|
||||||
use fn module::nameres::file_items;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
|
|
||||||
type FileItemQuery;
|
|
||||||
storage dependencies;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
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>> {
|
|
||||||
type ModuleTreeQuery;
|
|
||||||
use fn module::imp::module_tree;
|
|
||||||
}
|
|
||||||
fn _fn_syntax(fn_id: FnId) -> FnDefNode {
|
|
||||||
type FnSyntaxQuery;
|
|
||||||
// Don't retain syntax trees in memory
|
|
||||||
storage dependencies;
|
|
||||||
use fn function::imp::fn_syntax;
|
|
||||||
}
|
|
||||||
fn _submodules(source: ModuleSource) -> Cancelable<Arc<Vec<module::imp::Submodule>>> {
|
|
||||||
type SubmodulesQuery;
|
|
||||||
use fn module::imp::submodules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) enum Def {
|
pub(crate) enum Def {
|
||||||
Module(ModuleDescriptor),
|
Module(ModuleDescriptor),
|
||||||
Item,
|
Item,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue