From 0e4b710af83844f4a7c471c5335c99aaaa25a90c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 28 Nov 2018 03:42:26 +0300 Subject: introduce hir crate --- crates/ra_hir/src/db.rs | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 crates/ra_hir/src/db.rs (limited to 'crates/ra_hir/src/db.rs') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs new file mode 100644 index 000000000..dbf8785fe --- /dev/null +++ b/crates/ra_hir/src/db.rs @@ -0,0 +1,66 @@ +use std::sync::Arc; + +use ra_syntax::{ + SyntaxNode, + ast::FnDefNode, +}; +use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, FileId, Cancelable}; + +use crate::{ + DefLoc, DefId, FnId, + SourceFileItems, SourceItemId, + query_definitions, + function::{FnScopes}, + module::{ModuleId, ModuleTree, ModuleSource, + nameres::{ItemMap, InputModuleItems}}, +}; + +salsa::query_group! { + +pub(crate) trait HirDatabase: SyntaxDatabase + + AsRef> + + AsRef> +{ + fn fn_scopes(fn_id: FnId) -> Arc { + type FnScopesQuery; + use fn query_definitions::fn_scopes; + } + fn fn_syntax(fn_id: FnId) -> FnDefNode { + type FnSyntaxQuery; + // Don't retain syntax trees in memory + storage dependencies; + use fn query_definitions::fn_syntax; + } + + fn file_items(file_id: FileId) -> Arc { + type SourceFileItemsQuery; + storage dependencies; + use fn query_definitions::file_items; + } + + fn file_item(source_item_id: SourceItemId) -> SyntaxNode { + type FileItemQuery; + storage dependencies; + use fn query_definitions::file_item; + } + + fn submodules(source: ModuleSource) -> Cancelable>> { + type SubmodulesQuery; + use fn query_definitions::submodules; + } + + fn input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable> { + type InputModuleItemsQuery; + use fn query_definitions::input_module_items; + } + fn item_map(source_root_id: SourceRootId) -> Cancelable> { + type ItemMapQuery; + use fn query_definitions::item_map; + } + fn module_tree(source_root_id: SourceRootId) -> Cancelable> { + type ModuleTreeQuery; + use fn crate::module::imp::module_tree; + } +} + +} -- cgit v1.2.3