2018-11-27 18:42:26 -06:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2019-01-11 10:59:06 -06:00
|
|
|
use ra_syntax::{SyntaxNode, TreeArc, SourceFile};
|
2019-03-13 08:38:02 -05:00
|
|
|
use ra_db::{SourceDatabase, salsa, FileId};
|
2018-11-27 18:42:26 -06:00
|
|
|
|
|
|
|
use crate::{
|
2019-01-25 05:21:14 -06:00
|
|
|
MacroCallId, HirFileId,
|
2019-01-23 14:14:13 -06:00
|
|
|
SourceFileItems, SourceItemId, Crate, Module, HirInterner,
|
2019-02-24 14:36:49 -06:00
|
|
|
Function, FnSignature, ExprScopes, TypeAlias,
|
2019-01-25 05:21:14 -06:00
|
|
|
Struct, Enum, StructField,
|
2019-02-25 02:21:01 -06:00
|
|
|
Const, ConstSignature, Static,
|
2019-01-01 15:37:36 -06:00
|
|
|
macros::MacroExpansion,
|
2019-03-14 04:54:03 -05:00
|
|
|
nameres::{Namespace, lower::{LoweredModule, ImportSourceMap}, crate_def_map::{RawItems, CrateDefMap}},
|
2019-03-16 11:29:55 -05:00
|
|
|
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, CallableDef, FnSig},
|
2019-01-25 03:41:23 -06:00
|
|
|
adt::{StructData, EnumData},
|
2019-01-28 08:26:32 -06:00
|
|
|
impl_block::{ModuleImplBlocks, ImplSourceMap},
|
2019-01-24 06:28:50 -06:00
|
|
|
generics::{GenericParams, GenericDef},
|
2019-02-24 14:36:49 -06:00
|
|
|
type_ref::TypeRef,
|
2018-11-27 18:42:26 -06:00
|
|
|
};
|
|
|
|
|
2019-01-31 08:28:31 -06:00
|
|
|
#[salsa::query_group(PersistentHirDatabaseStorage)]
|
|
|
|
pub trait PersistentHirDatabase: SourceDatabase + AsRef<HirInterner> {
|
2019-01-26 02:51:36 -06:00
|
|
|
#[salsa::invoke(HirFileId::hir_parse)]
|
|
|
|
fn hir_parse(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
2019-01-17 05:11:00 -06: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 09:56:38 -06:00
|
|
|
fn struct_data(&self, s: Struct) -> Arc<StructData>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::adt::EnumData::enum_data_query)]
|
2019-01-24 09:56:38 -06:00
|
|
|
fn enum_data(&self, e: Enum) -> Arc<EnumData>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
2019-02-11 08:44:54 -06:00
|
|
|
#[salsa::invoke(crate::ids::SourceFileItems::file_items_query)]
|
2019-01-17 05:11:00 -06:00
|
|
|
fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>;
|
|
|
|
|
2019-02-11 08:44:54 -06:00
|
|
|
#[salsa::invoke(crate::ids::SourceFileItems::file_item_query)]
|
2019-02-01 04:33:41 -06:00
|
|
|
fn file_item(&self, source_item_id: SourceItemId) -> TreeArc<SyntaxNode>;
|
|
|
|
|
2019-03-02 07:49:06 -06:00
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_with_source_map_query)]
|
|
|
|
fn lower_module_with_source_map(
|
|
|
|
&self,
|
|
|
|
module: Module,
|
|
|
|
) -> (Arc<LoweredModule>, Arc<ImportSourceMap>);
|
2019-01-18 07:36:56 -06:00
|
|
|
|
2019-03-02 07:49:06 -06:00
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_query)]
|
|
|
|
fn lower_module(&self, module: Module) -> Arc<LoweredModule>;
|
2019-01-18 07:36:56 -06:00
|
|
|
|
2019-03-13 08:38:02 -05:00
|
|
|
#[salsa::invoke(RawItems::raw_items_query)]
|
|
|
|
fn raw_items(&self, file_id: FileId) -> Arc<RawItems>;
|
|
|
|
|
|
|
|
#[salsa::invoke(CrateDefMap::crate_def_map_query)]
|
|
|
|
fn crate_def_map(&self, krate: Crate) -> Arc<CrateDefMap>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::impl_block::impls_in_module)]
|
2019-01-23 14:14:13 -06:00
|
|
|
fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
2019-01-28 08:26:32 -06: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 04:33:41 -06: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 05:11:00 -06:00
|
|
|
|
2019-01-19 11:58:04 -06:00
|
|
|
#[salsa::invoke(crate::generics::GenericParams::generic_params_query)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>;
|
2019-01-12 14:27:35 -06:00
|
|
|
|
2019-01-17 05:11:00 -06:00
|
|
|
#[salsa::invoke(crate::FnSignature::fn_signature_query)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn fn_signature(&self, func: Function) -> Arc<FnSignature>;
|
2019-02-24 10:25:41 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::type_alias::type_alias_ref_query)]
|
2019-02-24 14:36:49 -06:00
|
|
|
fn type_alias_ref(&self, typ: TypeAlias) -> Arc<TypeRef>;
|
2019-02-25 01:27:47 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ConstSignature::const_signature_query)]
|
|
|
|
fn const_signature(&self, konst: Const) -> Arc<ConstSignature>;
|
2019-02-25 02:21:01 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ConstSignature::static_signature_query)]
|
|
|
|
fn static_signature(&self, konst: Static) -> Arc<ConstSignature>;
|
2018-11-27 18:42:26 -06:00
|
|
|
}
|
2019-01-31 08:28:31 -06:00
|
|
|
|
|
|
|
#[salsa::query_group(HirDatabaseStorage)]
|
|
|
|
pub trait HirDatabase: PersistentHirDatabase {
|
2019-02-01 04:33:41 -06:00
|
|
|
#[salsa::invoke(ExprScopes::expr_scopes_query)]
|
|
|
|
fn expr_scopes(&self, func: Function) -> Arc<ExprScopes>;
|
2019-01-31 08:28:31 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::infer)]
|
|
|
|
fn infer(&self, func: Function) -> Arc<InferenceResult>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::type_for_def)]
|
2019-02-17 10:29:51 -06:00
|
|
|
fn type_for_def(&self, def: TypableDef, ns: Namespace) -> Ty;
|
2019-01-31 08:28:31 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::type_for_field)]
|
|
|
|
fn type_for_field(&self, field: StructField) -> Ty;
|
|
|
|
|
2019-03-16 11:29:55 -05:00
|
|
|
#[salsa::invoke(crate::ty::callable_item_sig)]
|
|
|
|
fn callable_item_signature(&self, def: CallableDef) -> FnSig;
|
|
|
|
|
2019-03-02 07:18:40 -06:00
|
|
|
#[salsa::invoke(crate::expr::body_with_source_map_query)]
|
|
|
|
fn body_with_source_map(
|
|
|
|
&self,
|
|
|
|
func: Function,
|
|
|
|
) -> (Arc<crate::expr::Body>, Arc<crate::expr::BodySourceMap>);
|
2019-01-31 08:28:31 -06:00
|
|
|
|
2019-03-02 07:18:40 -06:00
|
|
|
#[salsa::invoke(crate::expr::body_hir_query)]
|
|
|
|
fn body_hir(&self, func: Function) -> Arc<crate::expr::Body>;
|
2019-02-01 04:33:41 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)]
|
|
|
|
fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>;
|
2019-01-31 08:28:31 -06:00
|
|
|
}
|
2019-02-03 13:15:31 -06:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hir_database_is_object_safe() {
|
|
|
|
fn _assert_object_safe(_: &dyn HirDatabase) {}
|
|
|
|
}
|