aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/db.rs
blob: 9b5b79d38dc29aaf2ed21a3cac364e2ccf4260a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use std::sync::Arc;

use ra_syntax::{SyntaxNode, TreeArc, SourceFile};
use ra_db::{SourceDatabase, CrateId, salsa};

use crate::{
    MacroCallId, HirFileId,
    SourceFileItems, SourceItemId, Crate, Module, HirInterner,
    query_definitions,
    Function, FnSignature, FnScopes,
    Struct, Enum, StructField,
    macros::MacroExpansion,
    module_tree::ModuleTree,
    nameres::{ItemMap, lower::{LoweredModule, ImportSourceMap}},
    ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef},
    adt::{StructData, EnumData},
    impl_block::ModuleImplBlocks,
    generics::{GenericParams, GenericDef},
};

#[salsa::query_group(HirDatabaseStorage)]
pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
    #[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, func: Function) -> Arc<FnScopes>;

    #[salsa::invoke(crate::adt::StructData::struct_data_query)]
    fn struct_data(&self, s: Struct) -> Arc<StructData>;

    #[salsa::invoke(crate::adt::EnumData::enum_data_query)]
    fn enum_data(&self, e: Enum) -> Arc<EnumData>;

    #[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(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>>;

    #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_query)]
    fn lower_module(&self, module: Module) -> (Arc<LoweredModule>, Arc<ImportSourceMap>);

    #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_module_query)]
    fn lower_module_module(&self, module: Module) -> Arc<LoweredModule>;

    #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)]
    fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>;

    #[salsa::invoke(query_definitions::item_map)]
    fn item_map(&self, crate_id: CrateId) -> Arc<ItemMap>;

    #[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)]
    fn module_tree(&self, crate_id: CrateId) -> Arc<ModuleTree>;

    #[salsa::invoke(crate::impl_block::impls_in_module)]
    fn impls_in_module(&self, module: Module) -> 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, func: Function) -> Arc<crate::expr::Body>;

    #[salsa::invoke(crate::expr::body_syntax_mapping)]
    fn body_syntax_mapping(&self, func: Function) -> Arc<crate::expr::BodySyntaxMapping>;

    #[salsa::invoke(crate::generics::GenericParams::generic_params_query)]
    fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>;

    #[salsa::invoke(crate::FnSignature::fn_signature_query)]
    fn fn_signature(&self, func: Function) -> Arc<FnSignature>;
}