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 resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
|
||||
}
|
||||
impl hir::HirDatabase {
|
||||
fn module_tree() for hir::ModuleTreeQuery;
|
||||
fn fn_scopes() for hir::FnScopesQuery;
|
||||
fn _file_items() for hir::FileItemsQuery;
|
||||
fn _file_item() for hir::FileItemQuery;
|
||||
fn _input_module_items() for hir::InputModuleItemsQuery;
|
||||
fn _item_map() for hir::ItemMapQuery;
|
||||
fn _fn_syntax() for hir::FnSyntaxQuery;
|
||||
fn _submodules() for hir::SubmodulesQuery;
|
||||
impl hir::db::HirDatabase {
|
||||
fn module_tree() for hir::db::ModuleTreeQuery;
|
||||
fn fn_scopes() for hir::db::FnScopesQuery;
|
||||
fn _file_items() for hir::db::FileItemsQuery;
|
||||
fn _file_item() for hir::db::FileItemQuery;
|
||||
fn _input_module_items() for hir::db::InputModuleItemsQuery;
|
||||
fn _item_map() for hir::db::ItemMapQuery;
|
||||
fn _fn_syntax() for hir::db::FnSyntaxQuery;
|
||||
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 module;
|
||||
pub(crate) mod db;
|
||||
mod path;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::{
|
||||
ast::{self, FnDefNode, AstNode},
|
||||
TextRange, SyntaxNode,
|
||||
ast::{self, AstNode},
|
||||
TextRange,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
FileId,
|
||||
db::SyntaxDatabase,
|
||||
hir::function::{resolve_local_name, FnId, FnScopes},
|
||||
hir::module::{
|
||||
ModuleId, ModuleTree, ModuleSource,
|
||||
nameres::{ItemMap, InputModuleItems, FileItems}
|
||||
},
|
||||
input::SourceRootId,
|
||||
loc2id::{IdDatabase, DefId, DefLoc},
|
||||
hir::db::HirDatabase,
|
||||
hir::function::{resolve_local_name, FnScopes},
|
||||
loc2id::{DefId, DefLoc},
|
||||
syntax_ptr::LocalSyntaxPtr,
|
||||
Cancelable,
|
||||
};
|
||||
|
@ -36,50 +29,6 @@ pub(crate) use self::{
|
|||
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 {
|
||||
Module(ModuleDescriptor),
|
||||
Item,
|
||||
|
|
Loading…
Add table
Reference in a new issue