aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/db.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-26 19:51:29 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-26 19:51:29 +0100
commit5536a249145fc67c415ad48738e62fc2a9e848ff (patch)
tree0dacb8b02ca5b705123a022893512c61d3c8c718 /crates/ra_hir/src/db.rs
parent203d5dd0d0092b505db9efcff377fea154cbfe11 (diff)
parent6e2369938a6f5214680dcc0f4bb58cdb20dc1015 (diff)
Merge #1447
1447: make sure that CrateDefMap is independent from syntax r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/db.rs')
-rw-r--r--crates/ra_hir/src/db.rs60
1 files changed, 33 insertions, 27 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index a9840905c..8f4de1c85 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -20,13 +20,41 @@ use crate::{
20 lang_item::{LangItems, LangItemTarget}, type_alias::TypeAliasData, 20 lang_item::{LangItems, LangItemTarget}, type_alias::TypeAliasData,
21}; 21};
22 22
23// This database has access to source code, so queries here are not really 23/// We store all interned things in the single QueryGroup.
24// incremental. 24///
25#[salsa::query_group(AstDatabaseStorage)] 25/// This is done mainly to allow both "volatile" `AstDatabase` and "stable"
26pub trait AstDatabase: SourceDatabase { 26/// `DefDatabase` to access macros, without adding hard dependencies between the
27/// two.
28#[salsa::query_group(InternDatabaseStorage)]
29pub trait InternDatabase: SourceDatabase {
27 #[salsa::interned] 30 #[salsa::interned]
28 fn intern_macro(&self, macro_call: MacroCallLoc) -> ids::MacroCallId; 31 fn intern_macro(&self, macro_call: MacroCallLoc) -> ids::MacroCallId;
32 #[salsa::interned]
33 fn intern_function(&self, loc: ids::ItemLoc<ast::FnDef>) -> ids::FunctionId;
34 #[salsa::interned]
35 fn intern_struct(&self, loc: ids::ItemLoc<ast::StructDef>) -> ids::StructId;
36 #[salsa::interned]
37 fn intern_enum(&self, loc: ids::ItemLoc<ast::EnumDef>) -> ids::EnumId;
38 #[salsa::interned]
39 fn intern_const(&self, loc: ids::ItemLoc<ast::ConstDef>) -> ids::ConstId;
40 #[salsa::interned]
41 fn intern_static(&self, loc: ids::ItemLoc<ast::StaticDef>) -> ids::StaticId;
42 #[salsa::interned]
43 fn intern_trait(&self, loc: ids::ItemLoc<ast::TraitDef>) -> ids::TraitId;
44 #[salsa::interned]
45 fn intern_type_alias(&self, loc: ids::ItemLoc<ast::TypeAliasDef>) -> ids::TypeAliasId;
29 46
47 // Interned IDs for Chalk integration
48 #[salsa::interned]
49 fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId;
50 #[salsa::interned]
51 fn intern_impl_block(&self, impl_block: ImplBlock) -> ids::GlobalImplId;
52}
53
54/// This database has access to source code, so queries here are not really
55/// incremental.
56#[salsa::query_group(AstDatabaseStorage)]
57pub trait AstDatabase: InternDatabase {
30 #[salsa::invoke(crate::source_id::AstIdMap::ast_id_map_query)] 58 #[salsa::invoke(crate::source_id::AstIdMap::ast_id_map_query)]
31 fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>; 59 fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
32 #[salsa::transparent] 60 #[salsa::transparent]
@@ -40,7 +68,6 @@ pub trait AstDatabase: SourceDatabase {
40 68
41 #[salsa::invoke(crate::ids::macro_def_query)] 69 #[salsa::invoke(crate::ids::macro_def_query)]
42 fn macro_def(&self, macro_id: MacroDefId) -> Option<Arc<mbe::MacroRules>>; 70 fn macro_def(&self, macro_id: MacroDefId) -> Option<Arc<mbe::MacroRules>>;
43
44 #[salsa::invoke(crate::ids::macro_arg_query)] 71 #[salsa::invoke(crate::ids::macro_arg_query)]
45 fn macro_arg(&self, macro_call: ids::MacroCallId) -> Option<Arc<tt::Subtree>>; 72 fn macro_arg(&self, macro_call: ids::MacroCallId) -> Option<Arc<tt::Subtree>>;
46 73
@@ -51,28 +78,7 @@ pub trait AstDatabase: SourceDatabase {
51// This database uses `AstDatabase` internally, 78// This database uses `AstDatabase` internally,
52#[salsa::query_group(DefDatabaseStorage)] 79#[salsa::query_group(DefDatabaseStorage)]
53#[salsa::requires(AstDatabase)] 80#[salsa::requires(AstDatabase)]
54pub trait DefDatabase: SourceDatabase { 81pub trait DefDatabase: InternDatabase {
55 #[salsa::interned]
56 fn intern_function(&self, loc: ids::ItemLoc<ast::FnDef>) -> ids::FunctionId;
57 #[salsa::interned]
58 fn intern_struct(&self, loc: ids::ItemLoc<ast::StructDef>) -> ids::StructId;
59 #[salsa::interned]
60 fn intern_enum(&self, loc: ids::ItemLoc<ast::EnumDef>) -> ids::EnumId;
61 #[salsa::interned]
62 fn intern_const(&self, loc: ids::ItemLoc<ast::ConstDef>) -> ids::ConstId;
63 #[salsa::interned]
64 fn intern_static(&self, loc: ids::ItemLoc<ast::StaticDef>) -> ids::StaticId;
65 #[salsa::interned]
66 fn intern_trait(&self, loc: ids::ItemLoc<ast::TraitDef>) -> ids::TraitId;
67 #[salsa::interned]
68 fn intern_type_alias(&self, loc: ids::ItemLoc<ast::TypeAliasDef>) -> ids::TypeAliasId;
69
70 // Interned IDs for Chalk integration
71 #[salsa::interned]
72 fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId;
73 #[salsa::interned]
74 fn intern_impl_block(&self, impl_block: ImplBlock) -> ids::GlobalImplId;
75
76 #[salsa::invoke(crate::adt::StructData::struct_data_query)] 82 #[salsa::invoke(crate::adt::StructData::struct_data_query)]
77 fn struct_data(&self, s: Struct) -> Arc<StructData>; 83 fn struct_data(&self, s: Struct) -> Arc<StructData>;
78 84