aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/db.rs
blob: 03e65387d8ff2e03a0e26ebcd7aae75fa431bae1 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use std::sync::Arc;

use ra_syntax::{SyntaxNode, TreePtr, SourceFile};
use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable};

use crate::{
    DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId,
    SourceFileItems, SourceItemId,
    query_definitions,
    FnSignature, FnScopes,
    macros::MacroExpansion,
    module_tree::{ModuleId, ModuleTree},
    nameres::{ItemMap, InputModuleItems},
    ty::{InferenceResult, Ty},
    adt::{StructData, EnumData},
    impl_block::ModuleImplBlocks,
};

salsa::query_group! {

pub trait HirDatabase: SyntaxDatabase
    + AsRef<LocationIntener<DefLoc, DefId>>
    + AsRef<LocationIntener<MacroCallLoc, MacroCallId>>
{
    fn hir_source_file(file_id: HirFileId) -> TreePtr<SourceFile> {
        type HirSourceFileQuery;
        use fn HirFileId::hir_source_file;
    }
    fn expand_macro_invocation(invoc: MacroCallId) -> Option<Arc<MacroExpansion>> {
        type ExpandMacroCallQuery;
        use fn crate::macros::expand_macro_invocation;
    }

    fn fn_scopes(def_id: DefId) -> Cancelable<Arc<FnScopes>> {
        type FnScopesQuery;
        use fn query_definitions::fn_scopes;
    }

    fn struct_data(def_id: DefId) -> Cancelable<Arc<StructData>> {
        type StructDataQuery;
        use fn query_definitions::struct_data;
    }

    fn enum_data(def_id: DefId) -> Cancelable<Arc<EnumData>> {
        type EnumDataQuery;
        use fn query_definitions::enum_data;
    }

    fn infer(def_id: DefId) -> Cancelable<Arc<InferenceResult>> {
        type InferQuery;
        use fn crate::ty::infer;
    }

    fn type_for_def(def_id: DefId) -> Cancelable<Ty> {
        type TypeForDefQuery;
        use fn crate::ty::type_for_def;
    }

    fn type_for_field(def_id: DefId, field: Name) -> Cancelable<Option<Ty>> {
        type TypeForFieldQuery;
        use fn crate::ty::type_for_field;
    }

    fn file_items(file_id: HirFileId) -> Arc<SourceFileItems> {
        type SourceFileItemsQuery;
        use fn query_definitions::file_items;
    }

    fn file_item(source_item_id: SourceItemId) -> TreePtr<SyntaxNode> {
        type FileItemQuery;
        use fn query_definitions::file_item;
    }

    fn submodules(source: SourceItemId) -> Cancelable<Arc<Vec<crate::module_tree::Submodule>>> {
        type SubmodulesQuery;
        use fn crate::module_tree::Submodule::submodules_query;
    }

    fn input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<InputModuleItems>> {
        type InputModuleItemsQuery;
        use fn query_definitions::input_module_items;
    }
    fn item_map(source_root_id: SourceRootId) -> Cancelable<Arc<ItemMap>> {
        type ItemMapQuery;
        use fn query_definitions::item_map;
    }
    fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
        type ModuleTreeQuery;
        use fn crate::module_tree::ModuleTree::module_tree_query;
    }

    fn impls_in_module(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleImplBlocks>> {
        type ImplsInModuleQuery;
        use fn crate::impl_block::impls_in_module;
    }

    fn body_hir(def_id: DefId) -> Cancelable<Arc<crate::expr::Body>> {
        type BodyHirQuery;
        use fn crate::expr::body_hir;
    }

    fn body_syntax_mapping(def_id: DefId) -> Cancelable<Arc<crate::expr::BodySyntaxMapping>> {
        type BodySyntaxMappingQuery;
        use fn crate::expr::body_syntax_mapping;
    }

    fn fn_signature(def_id: DefId) -> Arc<FnSignature> {
        type FnSignatureQuery;
        use fn crate::function::fn_signature;
    }
}

}