diff options
Diffstat (limited to 'crates/ra_hir_def/src/db.rs')
-rw-r--r-- | crates/ra_hir_def/src/db.rs | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 844f8bbe8..32adb11bd 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -3,43 +3,47 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use hir_expand::{db::AstDatabase, HirFileId}; | 4 | use hir_expand::{db::AstDatabase, HirFileId}; |
5 | use ra_db::{salsa, CrateId, SourceDatabase}; | 5 | use ra_db::{salsa, CrateId, SourceDatabase}; |
6 | use ra_syntax::ast; | 6 | use ra_syntax::{ast, SmolStr}; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | adt::{EnumData, StructData}, | 9 | adt::{EnumData, StructData}, |
10 | attr::Attrs, | ||
10 | body::{scope::ExprScopes, Body, BodySourceMap}, | 11 | body::{scope::ExprScopes, Body, BodySourceMap}, |
12 | data::{ConstData, FunctionData, ImplData, TraitData, TypeAliasData}, | ||
13 | docs::Documentation, | ||
11 | generics::GenericParams, | 14 | generics::GenericParams, |
12 | impls::ImplData, | 15 | lang_item::{LangItemTarget, LangItems}, |
13 | nameres::{ | 16 | nameres::{ |
14 | raw::{ImportSourceMap, RawItems}, | 17 | raw::{ImportSourceMap, RawItems}, |
15 | CrateDefMap, | 18 | CrateDefMap, |
16 | }, | 19 | }, |
17 | traits::TraitData, | 20 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, FunctionId, FunctionLoc, GenericDefId, |
18 | DefWithBodyId, EnumId, GenericDefId, ImplId, ItemLoc, StructOrUnionId, TraitId, | 21 | ImplId, ItemLoc, ModuleId, StaticId, StaticLoc, StructOrUnionId, TraitId, TypeAliasId, |
22 | TypeAliasLoc, | ||
19 | }; | 23 | }; |
20 | 24 | ||
21 | #[salsa::query_group(InternDatabaseStorage)] | 25 | #[salsa::query_group(InternDatabaseStorage)] |
22 | pub trait InternDatabase: SourceDatabase { | 26 | pub trait InternDatabase: SourceDatabase { |
23 | #[salsa::interned] | 27 | #[salsa::interned] |
24 | fn intern_function(&self, loc: crate::FunctionLoc) -> crate::FunctionId; | 28 | fn intern_function(&self, loc: FunctionLoc) -> FunctionId; |
25 | #[salsa::interned] | 29 | #[salsa::interned] |
26 | fn intern_struct_or_union(&self, loc: ItemLoc<ast::StructDef>) -> crate::StructOrUnionId; | 30 | fn intern_struct_or_union(&self, loc: ItemLoc<ast::StructDef>) -> StructOrUnionId; |
27 | #[salsa::interned] | 31 | #[salsa::interned] |
28 | fn intern_enum(&self, loc: ItemLoc<ast::EnumDef>) -> crate::EnumId; | 32 | fn intern_enum(&self, loc: ItemLoc<ast::EnumDef>) -> EnumId; |
29 | #[salsa::interned] | 33 | #[salsa::interned] |
30 | fn intern_const(&self, loc: crate::ConstLoc) -> crate::ConstId; | 34 | fn intern_const(&self, loc: ConstLoc) -> ConstId; |
31 | #[salsa::interned] | 35 | #[salsa::interned] |
32 | fn intern_static(&self, loc: ItemLoc<ast::StaticDef>) -> crate::StaticId; | 36 | fn intern_static(&self, loc: StaticLoc) -> StaticId; |
33 | #[salsa::interned] | 37 | #[salsa::interned] |
34 | fn intern_trait(&self, loc: ItemLoc<ast::TraitDef>) -> crate::TraitId; | 38 | fn intern_trait(&self, loc: ItemLoc<ast::TraitDef>) -> TraitId; |
35 | #[salsa::interned] | 39 | #[salsa::interned] |
36 | fn intern_type_alias(&self, loc: crate::TypeAliasLoc) -> crate::TypeAliasId; | 40 | fn intern_type_alias(&self, loc: TypeAliasLoc) -> TypeAliasId; |
37 | #[salsa::interned] | 41 | #[salsa::interned] |
38 | fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId; | 42 | fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> ImplId; |
39 | } | 43 | } |
40 | 44 | ||
41 | #[salsa::query_group(DefDatabase2Storage)] | 45 | #[salsa::query_group(DefDatabaseStorage)] |
42 | pub trait DefDatabase2: InternDatabase + AstDatabase { | 46 | pub trait DefDatabase: InternDatabase + AstDatabase { |
43 | #[salsa::invoke(RawItems::raw_items_with_source_map_query)] | 47 | #[salsa::invoke(RawItems::raw_items_with_source_map_query)] |
44 | fn raw_items_with_source_map( | 48 | fn raw_items_with_source_map( |
45 | &self, | 49 | &self, |
@@ -64,6 +68,18 @@ pub trait DefDatabase2: InternDatabase + AstDatabase { | |||
64 | #[salsa::invoke(TraitData::trait_data_query)] | 68 | #[salsa::invoke(TraitData::trait_data_query)] |
65 | fn trait_data(&self, e: TraitId) -> Arc<TraitData>; | 69 | fn trait_data(&self, e: TraitId) -> Arc<TraitData>; |
66 | 70 | ||
71 | #[salsa::invoke(TypeAliasData::type_alias_data_query)] | ||
72 | fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>; | ||
73 | |||
74 | #[salsa::invoke(FunctionData::fn_data_query)] | ||
75 | fn function_data(&self, func: FunctionId) -> Arc<FunctionData>; | ||
76 | |||
77 | #[salsa::invoke(ConstData::const_data_query)] | ||
78 | fn const_data(&self, konst: ConstId) -> Arc<ConstData>; | ||
79 | |||
80 | #[salsa::invoke(ConstData::static_data_query)] | ||
81 | fn static_data(&self, konst: StaticId) -> Arc<ConstData>; | ||
82 | |||
67 | #[salsa::invoke(Body::body_with_source_map_query)] | 83 | #[salsa::invoke(Body::body_with_source_map_query)] |
68 | fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>); | 84 | fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>); |
69 | 85 | ||
@@ -75,4 +91,21 @@ pub trait DefDatabase2: InternDatabase + AstDatabase { | |||
75 | 91 | ||
76 | #[salsa::invoke(GenericParams::generic_params_query)] | 92 | #[salsa::invoke(GenericParams::generic_params_query)] |
77 | fn generic_params(&self, def: GenericDefId) -> Arc<GenericParams>; | 93 | fn generic_params(&self, def: GenericDefId) -> Arc<GenericParams>; |
94 | |||
95 | #[salsa::invoke(Attrs::attrs_query)] | ||
96 | fn attrs(&self, def: AttrDefId) -> Attrs; | ||
97 | |||
98 | #[salsa::invoke(LangItems::module_lang_items_query)] | ||
99 | fn module_lang_items(&self, module: ModuleId) -> Option<Arc<LangItems>>; | ||
100 | |||
101 | #[salsa::invoke(LangItems::crate_lang_items_query)] | ||
102 | fn crate_lang_items(&self, krate: CrateId) -> Arc<LangItems>; | ||
103 | |||
104 | #[salsa::invoke(LangItems::lang_item_query)] | ||
105 | fn lang_item(&self, start_crate: CrateId, item: SmolStr) -> Option<LangItemTarget>; | ||
106 | |||
107 | // FIXME(https://github.com/rust-analyzer/rust-analyzer/issues/2148#issuecomment-550519102) | ||
108 | // Remove this query completely, in favor of `Attrs::docs` method | ||
109 | #[salsa::invoke(Documentation::documentation_query)] | ||
110 | fn documentation(&self, def: AttrDefId) -> Option<Documentation>; | ||
78 | } | 111 | } |