diff options
author | Seivan Heidari <[email protected]> | 2019-10-31 08:43:20 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-10-31 08:43:20 +0000 |
commit | 8edda0e7b164009d6c03bb3d4be603fb38ad2e2a (patch) | |
tree | 744cf81075d394e2f9c06afb07642a2601800dda /crates/ra_hir/src/db.rs | |
parent | 49562d36b97ddde34cf7585a8c2e8f232519b657 (diff) | |
parent | d067afb064a7fa67b172abf561b7d80740cd6f18 (diff) |
Merge branch 'master' into feature/themes
Diffstat (limited to 'crates/ra_hir/src/db.rs')
-rw-r--r-- | crates/ra_hir/src/db.rs | 94 |
1 files changed, 20 insertions, 74 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 489a3b19c..ebfd970eb 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_db::{salsa, SourceDatabase}; | 5 | use ra_db::salsa; |
6 | use ra_syntax::{ast, Parse, SmolStr, SyntaxNode}; | 6 | use ra_syntax::SmolStr; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | adt::{EnumData, StructData}, | 9 | adt::{EnumData, StructData}, |
@@ -12,81 +12,30 @@ use crate::{ | |||
12 | ids, | 12 | ids, |
13 | impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks}, | 13 | impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks}, |
14 | lang_item::{LangItemTarget, LangItems}, | 14 | lang_item::{LangItemTarget, LangItems}, |
15 | nameres::{CrateDefMap, ImportSourceMap, Namespace, RawItems}, | 15 | nameres::{CrateDefMap, Namespace}, |
16 | traits::TraitData, | 16 | traits::TraitData, |
17 | ty::{ | 17 | ty::{ |
18 | method_resolution::CrateImplBlocks, traits::Impl, CallableDef, FnSig, GenericPredicate, | 18 | method_resolution::CrateImplBlocks, traits::Impl, CallableDef, FnSig, GenericPredicate, |
19 | InferenceResult, Substs, Ty, TypableDef, TypeCtor, | 19 | InferenceResult, Substs, Ty, TypableDef, TypeCtor, |
20 | }, | 20 | }, |
21 | type_alias::TypeAliasData, | 21 | type_alias::TypeAliasData, |
22 | AstIdMap, Const, ConstData, Crate, DefWithBody, Enum, ErasedFileAstId, ExprScopes, FnData, | 22 | Const, ConstData, Crate, DefWithBody, Enum, ExprScopes, FnData, Function, Module, Static, |
23 | Function, HirFileId, MacroCallLoc, MacroDefId, Module, Static, Struct, StructField, Trait, | 23 | Struct, StructField, Trait, TypeAlias, |
24 | TypeAlias, | ||
25 | }; | 24 | }; |
26 | 25 | ||
27 | /// We store all interned things in the single QueryGroup. | 26 | pub use hir_def::db::{ |
28 | /// | 27 | DefDatabase2, DefDatabase2Storage, InternDatabase, InternDatabaseStorage, RawItemsQuery, |
29 | /// This is done mainly to allow both "volatile" `AstDatabase` and "stable" | 28 | RawItemsWithSourceMapQuery, |
30 | /// `DefDatabase` to access macros, without adding hard dependencies between the | 29 | }; |
31 | /// two. | 30 | pub use hir_expand::db::{ |
32 | #[salsa::query_group(InternDatabaseStorage)] | 31 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, |
33 | pub trait InternDatabase: SourceDatabase { | 32 | ParseMacroQuery, |
34 | #[salsa::interned] | 33 | }; |
35 | fn intern_macro(&self, macro_call: MacroCallLoc) -> ids::MacroCallId; | ||
36 | #[salsa::interned] | ||
37 | fn intern_function(&self, loc: ids::ItemLoc<ast::FnDef>) -> ids::FunctionId; | ||
38 | #[salsa::interned] | ||
39 | fn intern_struct(&self, loc: ids::ItemLoc<ast::StructDef>) -> ids::StructId; | ||
40 | #[salsa::interned] | ||
41 | fn intern_enum(&self, loc: ids::ItemLoc<ast::EnumDef>) -> ids::EnumId; | ||
42 | #[salsa::interned] | ||
43 | fn intern_const(&self, loc: ids::ItemLoc<ast::ConstDef>) -> ids::ConstId; | ||
44 | #[salsa::interned] | ||
45 | fn intern_static(&self, loc: ids::ItemLoc<ast::StaticDef>) -> ids::StaticId; | ||
46 | #[salsa::interned] | ||
47 | fn intern_trait(&self, loc: ids::ItemLoc<ast::TraitDef>) -> ids::TraitId; | ||
48 | #[salsa::interned] | ||
49 | fn intern_type_alias(&self, loc: ids::ItemLoc<ast::TypeAliasDef>) -> ids::TypeAliasId; | ||
50 | |||
51 | // Interned IDs for Chalk integration | ||
52 | #[salsa::interned] | ||
53 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId; | ||
54 | #[salsa::interned] | ||
55 | fn intern_impl(&self, impl_: Impl) -> ids::GlobalImplId; | ||
56 | } | ||
57 | |||
58 | /// This database has access to source code, so queries here are not really | ||
59 | /// incremental. | ||
60 | #[salsa::query_group(AstDatabaseStorage)] | ||
61 | pub trait AstDatabase: InternDatabase { | ||
62 | #[salsa::invoke(crate::source_id::AstIdMap::ast_id_map_query)] | ||
63 | fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>; | ||
64 | |||
65 | #[salsa::transparent] | ||
66 | #[salsa::invoke(crate::source_id::AstIdMap::file_item_query)] | ||
67 | fn ast_id_to_node(&self, file_id: HirFileId, ast_id: ErasedFileAstId) -> SyntaxNode; | ||
68 | |||
69 | #[salsa::transparent] | ||
70 | #[salsa::invoke(crate::ids::HirFileId::parse_or_expand_query)] | ||
71 | fn parse_or_expand(&self, file_id: HirFileId) -> Option<SyntaxNode>; | ||
72 | |||
73 | #[salsa::invoke(crate::ids::HirFileId::parse_macro_query)] | ||
74 | fn parse_macro(&self, macro_file: ids::MacroFile) -> Option<Parse<SyntaxNode>>; | ||
75 | |||
76 | #[salsa::invoke(crate::ids::macro_def_query)] | ||
77 | fn macro_def(&self, macro_id: MacroDefId) -> Option<Arc<mbe::MacroRules>>; | ||
78 | |||
79 | #[salsa::invoke(crate::ids::macro_arg_query)] | ||
80 | fn macro_arg(&self, macro_call: ids::MacroCallId) -> Option<Arc<tt::Subtree>>; | ||
81 | |||
82 | #[salsa::invoke(crate::ids::macro_expand_query)] | ||
83 | fn macro_expand(&self, macro_call: ids::MacroCallId) -> Result<Arc<tt::Subtree>, String>; | ||
84 | } | ||
85 | 34 | ||
86 | // This database uses `AstDatabase` internally, | 35 | // This database uses `AstDatabase` internally, |
87 | #[salsa::query_group(DefDatabaseStorage)] | 36 | #[salsa::query_group(DefDatabaseStorage)] |
88 | #[salsa::requires(AstDatabase)] | 37 | #[salsa::requires(AstDatabase)] |
89 | pub trait DefDatabase: InternDatabase + HirDebugDatabase { | 38 | pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { |
90 | #[salsa::invoke(crate::adt::StructData::struct_data_query)] | 39 | #[salsa::invoke(crate::adt::StructData::struct_data_query)] |
91 | fn struct_data(&self, s: Struct) -> Arc<StructData>; | 40 | fn struct_data(&self, s: Struct) -> Arc<StructData>; |
92 | 41 | ||
@@ -99,15 +48,6 @@ pub trait DefDatabase: InternDatabase + HirDebugDatabase { | |||
99 | #[salsa::invoke(crate::traits::TraitItemsIndex::trait_items_index)] | 48 | #[salsa::invoke(crate::traits::TraitItemsIndex::trait_items_index)] |
100 | fn trait_items_index(&self, module: Module) -> crate::traits::TraitItemsIndex; | 49 | fn trait_items_index(&self, module: Module) -> crate::traits::TraitItemsIndex; |
101 | 50 | ||
102 | #[salsa::invoke(RawItems::raw_items_with_source_map_query)] | ||
103 | fn raw_items_with_source_map( | ||
104 | &self, | ||
105 | file_id: HirFileId, | ||
106 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>); | ||
107 | |||
108 | #[salsa::invoke(RawItems::raw_items_query)] | ||
109 | fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>; | ||
110 | |||
111 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] | 51 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] |
112 | fn crate_def_map(&self, krate: Crate) -> Arc<CrateDefMap>; | 52 | fn crate_def_map(&self, krate: Crate) -> Arc<CrateDefMap>; |
113 | 53 | ||
@@ -202,6 +142,12 @@ pub trait HirDatabase: DefDatabase + AstDatabase { | |||
202 | #[salsa::invoke(crate::ty::traits::trait_solver_query)] | 142 | #[salsa::invoke(crate::ty::traits::trait_solver_query)] |
203 | fn trait_solver(&self, krate: Crate) -> crate::ty::traits::TraitSolver; | 143 | fn trait_solver(&self, krate: Crate) -> crate::ty::traits::TraitSolver; |
204 | 144 | ||
145 | // Interned IDs for Chalk integration | ||
146 | #[salsa::interned] | ||
147 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId; | ||
148 | #[salsa::interned] | ||
149 | fn intern_impl(&self, impl_: Impl) -> ids::GlobalImplId; | ||
150 | |||
205 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] | 151 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] |
206 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; | 152 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; |
207 | 153 | ||