rust/crates/ra_hir/src/db.rs

107 lines
3.9 KiB
Rust
Raw Normal View History

2018-11-27 18:42:26 -06:00
use std::sync::Arc;
use ra_syntax::{SyntaxNode, TreeArc, SourceFile};
2019-01-17 05:11:00 -06:00
use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, salsa};
2018-11-27 18:42:26 -06:00
use crate::{
DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId,
SourceFileItems, SourceItemId, Crate,
2018-11-27 18:42:26 -06:00
query_definitions,
2019-01-05 18:00:34 -06:00
FnSignature, FnScopes,
2019-01-01 15:37:36 -06:00
macros::MacroExpansion,
2019-01-06 10:58:10 -06:00
module_tree::{ModuleId, ModuleTree},
2019-01-18 07:56:02 -06:00
nameres::{ItemMap, lower::{LoweredModule, ImportSourceMap}},
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks},
adt::{StructData, EnumData, EnumVariantData},
impl_block::ModuleImplBlocks,
2018-11-27 18:42:26 -06:00
};
2019-01-17 05:11:00 -06:00
#[salsa::query_group]
pub trait HirDatabase:
SyntaxDatabase
2018-11-27 18:42:26 -06:00
+ AsRef<LocationIntener<DefLoc, DefId>>
2019-01-01 09:12:31 -06:00
+ AsRef<LocationIntener<MacroCallLoc, MacroCallId>>
2018-11-27 18:42:26 -06:00
{
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)]
fn fn_scopes(&self, def_id: DefId) -> Arc<FnScopes>;
#[salsa::invoke(crate::adt::StructData::struct_data_query)]
fn struct_data(&self, def_id: DefId) -> Arc<StructData>;
#[salsa::invoke(crate::adt::EnumData::enum_data_query)]
fn enum_data(&self, def_id: DefId) -> Arc<EnumData>;
#[salsa::invoke(crate::adt::EnumVariantData::enum_variant_data_query)]
fn enum_variant_data(&self, def_id: DefId) -> Arc<EnumVariantData>;
#[salsa::invoke(crate::ty::infer)]
fn infer(&self, def_id: DefId) -> Arc<InferenceResult>;
#[salsa::invoke(crate::ty::type_for_def)]
fn type_for_def(&self, def_id: DefId) -> Ty;
#[salsa::invoke(crate::ty::type_for_field)]
fn type_for_field(&self, def_id: DefId, field: Name) -> Option<Ty>;
#[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)]
fn lower_module(
&self,
source_root_id: SourceRootId,
module_id: ModuleId,
) -> (Arc<LoweredModule>, Arc<ImportSourceMap>);
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_module_query)]
fn lower_module_module(
&self,
source_root_id: SourceRootId,
module_id: ModuleId,
) -> Arc<LoweredModule>;
#[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)]
fn lower_module_source_map(
&self,
source_root_id: SourceRootId,
module_id: ModuleId,
) -> Arc<ImportSourceMap>;
2019-01-17 05:11:00 -06:00
#[salsa::invoke(query_definitions::item_map)]
fn item_map(&self, source_root_id: SourceRootId) -> Arc<ItemMap>;
#[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)]
fn module_tree(&self, source_root_id: SourceRootId) -> Arc<ModuleTree>;
#[salsa::invoke(crate::impl_block::impls_in_module)]
fn impls_in_module(
&self,
source_root_id: SourceRootId,
module_id: ModuleId,
) -> Arc<ModuleImplBlocks>;
#[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)]
fn body_hir(&self, def_id: DefId) -> Arc<crate::expr::Body>;
#[salsa::invoke(crate::expr::body_syntax_mapping)]
fn body_syntax_mapping(&self, def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping>;
2018-11-27 18:42:26 -06:00
2019-01-17 05:11:00 -06:00
#[salsa::invoke(crate::FnSignature::fn_signature_query)]
fn fn_signature(&self, def_id: DefId) -> Arc<FnSignature>;
2018-11-27 18:42:26 -06:00
}