From f14902f67bbc5f68cb700b6b929b269d3d51a4a9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 27 Nov 2018 23:03:08 +0300 Subject: move hir db --- crates/ra_analysis/src/db.rs | 18 +++++------ crates/ra_analysis/src/hir/db.rs | 63 +++++++++++++++++++++++++++++++++++++++ crates/ra_analysis/src/hir/mod.rs | 63 ++++----------------------------------- 3 files changed, 78 insertions(+), 66 deletions(-) create mode 100644 crates/ra_analysis/src/hir/db.rs diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index b4fbbe7ad..08aa9053b 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs @@ -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; } } } diff --git a/crates/ra_analysis/src/hir/db.rs b/crates/ra_analysis/src/hir/db.rs new file mode 100644 index 000000000..3cdf8e6d6 --- /dev/null +++ b/crates/ra_analysis/src/hir/db.rs @@ -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 { + type FnScopesQuery; + use fn crate::hir::function::imp::fn_scopes; + } + + fn _file_items(file_id: FileId) -> Arc { + 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> { + type InputModuleItemsQuery; + use fn crate::hir::module::nameres::input_module_items; + } + fn _item_map(source_root_id: SourceRootId) -> Cancelable> { + type ItemMapQuery; + use fn crate::hir::module::nameres::item_map; + } + fn _module_tree(source_root_id: SourceRootId) -> Cancelable> { + 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>> { + type SubmodulesQuery; + use fn crate::hir::module::imp::submodules; + } + } +} diff --git a/crates/ra_analysis/src/hir/mod.rs b/crates/ra_analysis/src/hir/mod.rs index edeaeb8e6..27ac71a26 100644 --- a/crates/ra_analysis/src/hir/mod.rs +++ b/crates/ra_analysis/src/hir/mod.rs @@ -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 { - type FnScopesQuery; - use fn function::imp::fn_scopes; - } - - fn _file_items(file_id: FileId) -> Arc { - 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> { - type InputModuleItemsQuery; - use fn module::nameres::input_module_items; - } - fn _item_map(source_root_id: SourceRootId) -> Cancelable> { - type ItemMapQuery; - use fn module::nameres::item_map; - } - fn _module_tree(source_root_id: SourceRootId) -> Cancelable> { - 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>> { - type SubmodulesQuery; - use fn module::imp::submodules; - } - } -} - pub(crate) enum Def { Module(ModuleDescriptor), Item, -- cgit v1.2.3