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-01-23 14:14:13 -06:00
|
|
|
use ra_db::{SyntaxDatabase, CrateId, salsa};
|
2018-11-27 18:42:26 -06:00
|
|
|
|
|
|
|
use crate::{
|
2019-01-24 14:32:41 -06:00
|
|
|
MacroCallId, Name, HirFileId,
|
2019-01-23 14:14:13 -06:00
|
|
|
SourceFileItems, SourceItemId, Crate, Module, HirInterner,
|
2018-11-27 18:42:26 -06:00
|
|
|
query_definitions,
|
2019-01-24 06:28:50 -06:00
|
|
|
Function, FnSignature, FnScopes,
|
2019-01-25 03:41:23 -06:00
|
|
|
Struct, Enum,
|
2019-01-01 15:37:36 -06:00
|
|
|
macros::MacroExpansion,
|
2019-01-23 14:14:13 -06:00
|
|
|
module_tree::ModuleTree,
|
2019-01-18 07:56:02 -06:00
|
|
|
nameres::{ItemMap, lower::{LoweredModule, ImportSourceMap}},
|
2019-01-24 08:54:18 -06:00
|
|
|
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, VariantDef},
|
2019-01-25 03:41:23 -06:00
|
|
|
adt::{StructData, EnumData},
|
2019-01-04 12:29:53 -06:00
|
|
|
impl_block::ModuleImplBlocks,
|
2019-01-24 06:28:50 -06:00
|
|
|
generics::{GenericParams, GenericDef},
|
2018-11-27 18:42:26 -06:00
|
|
|
};
|
|
|
|
|
2019-01-17 05:11:00 -06:00
|
|
|
#[salsa::query_group]
|
2019-01-24 03:41:08 -06:00
|
|
|
pub trait HirDatabase: SyntaxDatabase + AsRef<HirInterner> {
|
2019-01-17 05:11:00 -06:00
|
|
|
#[salsa::invoke(HirFileId::hir_source_file)]
|
|
|
|
fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::macros::expand_macro_invocation)]
|
|
|
|
fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
|
|
|
|
|
|
|
|
#[salsa::invoke(query_definitions::fn_scopes)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn fn_scopes(&self, func: Function) -> Arc<FnScopes>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[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
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::infer)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn infer(&self, func: Function) -> Arc<InferenceResult>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::type_for_def)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn type_for_def(&self, def: TypableDef) -> Ty;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::type_for_field)]
|
2019-01-24 08:54:18 -06:00
|
|
|
fn type_for_field(&self, def: VariantDef, field: Name) -> Option<Ty>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(query_definitions::file_items)]
|
|
|
|
fn file_items(&self, file_id: HirFileId) -> Arc<SourceFileItems>;
|
|
|
|
|
|
|
|
#[salsa::invoke(query_definitions::file_item)]
|
|
|
|
fn file_item(&self, source_item_id: SourceItemId) -> TreeArc<SyntaxNode>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::module_tree::Submodule::submodules_query)]
|
|
|
|
fn submodules(&self, source: SourceItemId) -> Arc<Vec<crate::module_tree::Submodule>>;
|
|
|
|
|
2019-01-18 07:36:56 -06:00
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_query)]
|
2019-01-23 14:14:13 -06:00
|
|
|
fn lower_module(&self, module: Module) -> (Arc<LoweredModule>, Arc<ImportSourceMap>);
|
2019-01-18 07:36:56 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_module_query)]
|
2019-01-23 14:14:13 -06:00
|
|
|
fn lower_module_module(&self, module: Module) -> Arc<LoweredModule>;
|
2019-01-18 07:36:56 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)]
|
2019-01-23 14:14:13 -06:00
|
|
|
fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>;
|
2019-01-18 07:36:56 -06:00
|
|
|
|
2019-01-17 05:11:00 -06:00
|
|
|
#[salsa::invoke(query_definitions::item_map)]
|
2019-01-23 14:14:13 -06:00
|
|
|
fn item_map(&self, crate_id: CrateId) -> Arc<ItemMap>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)]
|
2019-01-23 14:14:13 -06:00
|
|
|
fn module_tree(&self, crate_id: CrateId) -> Arc<ModuleTree>;
|
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
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)]
|
|
|
|
fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::expr::body_hir)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn body_hir(&self, func: Function) -> Arc<crate::expr::Body>;
|
2019-01-17 05:11:00 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::expr::body_syntax_mapping)]
|
2019-01-24 06:28:50 -06:00
|
|
|
fn body_syntax_mapping(&self, func: Function) -> Arc<crate::expr::BodySyntaxMapping>;
|
2018-11-27 18:42:26 -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>;
|
2018-11-27 18:42:26 -06:00
|
|
|
}
|