2018-11-28 00:42:26 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2019-01-11 16:59:06 +00:00
|
|
|
use ra_syntax::{SyntaxNode, TreeArc, SourceFile};
|
2019-01-30 19:23:14 +00:00
|
|
|
use ra_db::{SourceDatabase, salsa};
|
2018-11-28 00:42:26 +00:00
|
|
|
|
|
|
|
use crate::{
|
2019-01-25 11:21:14 +00:00
|
|
|
MacroCallId, HirFileId,
|
2019-01-23 20:14:13 +00:00
|
|
|
SourceFileItems, SourceItemId, Crate, Module, HirInterner,
|
2018-11-28 00:42:26 +00:00
|
|
|
query_definitions,
|
2019-01-19 18:47:56 +00:00
|
|
|
Function, FnSignature, ExprScopes,
|
2019-01-25 11:21:14 +00:00
|
|
|
Struct, Enum, StructField,
|
2019-01-01 21:37:36 +00:00
|
|
|
macros::MacroExpansion,
|
2019-01-23 20:14:13 +00:00
|
|
|
module_tree::ModuleTree,
|
2019-01-18 13:56:02 +00:00
|
|
|
nameres::{ItemMap, lower::{LoweredModule, ImportSourceMap}},
|
2019-01-25 11:21:14 +00:00
|
|
|
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef},
|
2019-01-25 09:41:23 +00:00
|
|
|
adt::{StructData, EnumData},
|
2019-01-28 14:26:32 +00:00
|
|
|
impl_block::{ModuleImplBlocks, ImplSourceMap},
|
2019-01-24 12:28:50 +00:00
|
|
|
generics::{GenericParams, GenericDef},
|
2019-01-26 20:25:18 +00:00
|
|
|
ids::SourceFileItemId,
|
2018-11-28 00:42:26 +00:00
|
|
|
};
|
|
|
|
|
2019-01-31 14:28:31 +00:00
|
|
|
#[salsa::query_group(PersistentHirDatabaseStorage)]
|
|
|
|
pub trait PersistentHirDatabase: SourceDatabase + AsRef<HirInterner> {
|
2019-01-26 08:51:36 +00:00
|
|
|
#[salsa::invoke(HirFileId::hir_parse)]
|
|
|
|
fn hir_parse(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::macros::expand_macro_invocation)]
|
|
|
|
fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::adt::StructData::struct_data_query)]
|
2019-01-24 15:56:38 +00:00
|
|
|
fn struct_data(&self, s: Struct) -> Arc<StructData>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::adt::EnumData::enum_data_query)]
|
2019-01-24 15:56:38 +00:00
|
|
|
fn enum_data(&self, e: Enum) -> Arc<EnumData>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(query_definitions::file_items)]
|
|
|
|
fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>;
|
|
|
|
|
2019-02-01 10:33:41 +00:00
|
|
|
#[salsa::invoke(query_definitions::file_item)]
|
|
|
|
fn file_item(&self, source_item_id: SourceItemId) -> TreeArc<SyntaxNode>;
|
|
|
|
|
2019-01-17 11:11:00 +00:00
|
|
|
#[salsa::invoke(crate::module_tree::Submodule::submodules_query)]
|
2019-01-26 20:25:18 +00:00
|
|
|
fn submodules(
|
|
|
|
&self,
|
|
|
|
file_id: HirFileId,
|
|
|
|
delc_id: Option<SourceFileItemId>,
|
|
|
|
) -> Arc<Vec<crate::module_tree::Submodule>>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
2019-01-18 13:36:56 +00:00
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_query)]
|
2019-01-23 20:14:13 +00:00
|
|
|
fn lower_module(&self, module: Module) -> (Arc<LoweredModule>, Arc<ImportSourceMap>);
|
2019-01-18 13:36:56 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_module_query)]
|
2019-01-23 20:14:13 +00:00
|
|
|
fn lower_module_module(&self, module: Module) -> Arc<LoweredModule>;
|
2019-01-18 13:36:56 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)]
|
2019-01-23 20:14:13 +00:00
|
|
|
fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>;
|
2019-01-18 13:36:56 +00:00
|
|
|
|
2019-01-30 19:18:17 +00:00
|
|
|
#[salsa::invoke(crate::nameres::ItemMap::item_map_query)]
|
2019-01-30 19:23:14 +00:00
|
|
|
fn item_map(&self, krate: Crate) -> Arc<ItemMap>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)]
|
2019-01-30 19:23:14 +00:00
|
|
|
fn module_tree(&self, krate: Crate) -> Arc<ModuleTree>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::impl_block::impls_in_module)]
|
2019-01-23 20:14:13 +00:00
|
|
|
fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>;
|
2019-01-17 11:11:00 +00:00
|
|
|
|
2019-01-28 14:26:32 +00:00
|
|
|
#[salsa::invoke(crate::impl_block::impls_in_module_source_map_query)]
|
|
|
|
fn impls_in_module_source_map(&self, module: Module) -> Arc<ImplSourceMap>;
|
|
|
|
|
2019-02-01 10:33:41 +00:00
|
|
|
#[salsa::invoke(crate::impl_block::impls_in_module_with_source_map_query)]
|
|
|
|
fn impls_in_module_with_source_map(
|
|
|
|
&self,
|
|
|
|
module: Module,
|
|
|
|
) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>);
|
2019-01-17 11:11:00 +00:00
|
|
|
|
2019-01-19 17:58:04 +00:00
|
|
|
#[salsa::invoke(crate::generics::GenericParams::generic_params_query)]
|
2019-01-24 12:28:50 +00:00
|
|
|
fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>;
|
2019-01-12 20:27:35 +00:00
|
|
|
|
2019-01-17 11:11:00 +00:00
|
|
|
#[salsa::invoke(crate::FnSignature::fn_signature_query)]
|
2019-01-24 12:28:50 +00:00
|
|
|
fn fn_signature(&self, func: Function) -> Arc<FnSignature>;
|
2018-11-28 00:42:26 +00:00
|
|
|
}
|
2019-01-31 14:28:31 +00:00
|
|
|
|
|
|
|
#[salsa::query_group(HirDatabaseStorage)]
|
|
|
|
pub trait HirDatabase: PersistentHirDatabase {
|
2019-02-01 10:33:41 +00:00
|
|
|
#[salsa::invoke(ExprScopes::expr_scopes_query)]
|
|
|
|
fn expr_scopes(&self, func: Function) -> Arc<ExprScopes>;
|
2019-01-31 14:28:31 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::infer)]
|
|
|
|
fn infer(&self, func: Function) -> Arc<InferenceResult>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::type_for_def)]
|
|
|
|
fn type_for_def(&self, def: TypableDef) -> Ty;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::type_for_field)]
|
|
|
|
fn type_for_field(&self, field: StructField) -> Ty;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::expr::body_hir)]
|
|
|
|
fn body_hir(&self, func: Function) -> Arc<crate::expr::Body>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::expr::body_syntax_mapping)]
|
|
|
|
fn body_syntax_mapping(&self, func: Function) -> Arc<crate::expr::BodySyntaxMapping>;
|
2019-02-01 10:33:41 +00:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)]
|
|
|
|
fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>;
|
2019-01-31 14:28:31 +00:00
|
|
|
}
|
2019-02-03 19:15:31 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hir_database_is_object_safe() {
|
|
|
|
fn _assert_object_safe(_: &dyn HirDatabase) {}
|
|
|
|
}
|