diff options
author | Aleksey Kladov <[email protected]> | 2019-10-16 11:26:02 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-16 11:26:02 +0100 |
commit | 260ae2dbc99a6e56228525baca57317ecd8306dc (patch) | |
tree | b7830a8cc37a5a09bc36fd6d14231c870fafe157 /crates | |
parent | e53c916ce2ab7274b68be80b6791afe5b550500f (diff) |
minor cleanup
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/db.rs | 18 | ||||
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 35 | ||||
-rw-r--r-- | crates/ra_hir/src/type_alias.rs | 18 |
3 files changed, 38 insertions, 33 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 73d7d6fb6..489a3b19c 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -111,37 +111,37 @@ pub trait DefDatabase: InternDatabase + HirDebugDatabase { | |||
111 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] | 111 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] |
112 | fn crate_def_map(&self, krate: Crate) -> Arc<CrateDefMap>; | 112 | fn crate_def_map(&self, krate: Crate) -> Arc<CrateDefMap>; |
113 | 113 | ||
114 | #[salsa::invoke(crate::impl_block::impls_in_module_with_source_map_query)] | 114 | #[salsa::invoke(ModuleImplBlocks::impls_in_module_with_source_map_query)] |
115 | fn impls_in_module_with_source_map( | 115 | fn impls_in_module_with_source_map( |
116 | &self, | 116 | &self, |
117 | module: Module, | 117 | module: Module, |
118 | ) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>); | 118 | ) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>); |
119 | 119 | ||
120 | #[salsa::invoke(crate::impl_block::impls_in_module)] | 120 | #[salsa::invoke(ModuleImplBlocks::impls_in_module_query)] |
121 | fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>; | 121 | fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>; |
122 | 122 | ||
123 | #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] | 123 | #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] |
124 | fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>; | 124 | fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>; |
125 | 125 | ||
126 | #[salsa::invoke(crate::FnData::fn_data_query)] | 126 | #[salsa::invoke(FnData::fn_data_query)] |
127 | fn fn_data(&self, func: Function) -> Arc<FnData>; | 127 | fn fn_data(&self, func: Function) -> Arc<FnData>; |
128 | 128 | ||
129 | #[salsa::invoke(crate::type_alias::type_alias_data_query)] | 129 | #[salsa::invoke(TypeAliasData::type_alias_data_query)] |
130 | fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>; | 130 | fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>; |
131 | 131 | ||
132 | #[salsa::invoke(crate::ConstData::const_data_query)] | 132 | #[salsa::invoke(ConstData::const_data_query)] |
133 | fn const_data(&self, konst: Const) -> Arc<ConstData>; | 133 | fn const_data(&self, konst: Const) -> Arc<ConstData>; |
134 | 134 | ||
135 | #[salsa::invoke(crate::ConstData::static_data_query)] | 135 | #[salsa::invoke(ConstData::static_data_query)] |
136 | fn static_data(&self, konst: Static) -> Arc<ConstData>; | 136 | fn static_data(&self, konst: Static) -> Arc<ConstData>; |
137 | 137 | ||
138 | #[salsa::invoke(crate::lang_item::LangItems::module_lang_items_query)] | 138 | #[salsa::invoke(LangItems::module_lang_items_query)] |
139 | fn module_lang_items(&self, module: Module) -> Option<Arc<LangItems>>; | 139 | fn module_lang_items(&self, module: Module) -> Option<Arc<LangItems>>; |
140 | 140 | ||
141 | #[salsa::invoke(crate::lang_item::LangItems::crate_lang_items_query)] | 141 | #[salsa::invoke(LangItems::crate_lang_items_query)] |
142 | fn crate_lang_items(&self, krate: Crate) -> Arc<LangItems>; | 142 | fn crate_lang_items(&self, krate: Crate) -> Arc<LangItems>; |
143 | 143 | ||
144 | #[salsa::invoke(crate::lang_item::LangItems::lang_item_query)] | 144 | #[salsa::invoke(LangItems::lang_item_query)] |
145 | fn lang_item(&self, start_crate: Crate, item: SmolStr) -> Option<LangItemTarget>; | 145 | fn lang_item(&self, start_crate: Crate, item: SmolStr) -> Option<LangItemTarget>; |
146 | 146 | ||
147 | #[salsa::invoke(crate::code_model::docs::documentation_query)] | 147 | #[salsa::invoke(crate::code_model::docs::documentation_query)] |
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 55dfc393b..33ef87563 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -176,6 +176,25 @@ pub struct ModuleImplBlocks { | |||
176 | } | 176 | } |
177 | 177 | ||
178 | impl ModuleImplBlocks { | 178 | impl ModuleImplBlocks { |
179 | pub(crate) fn impls_in_module_with_source_map_query( | ||
180 | db: &(impl DefDatabase + AstDatabase), | ||
181 | module: Module, | ||
182 | ) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>) { | ||
183 | let mut source_map = ImplSourceMap::default(); | ||
184 | let crate_graph = db.crate_graph(); | ||
185 | let cfg_options = crate_graph.cfg_options(module.krate.crate_id()); | ||
186 | |||
187 | let result = ModuleImplBlocks::collect(db, cfg_options, module, &mut source_map); | ||
188 | (Arc::new(result), Arc::new(source_map)) | ||
189 | } | ||
190 | |||
191 | pub(crate) fn impls_in_module_query( | ||
192 | db: &impl DefDatabase, | ||
193 | module: Module, | ||
194 | ) -> Arc<ModuleImplBlocks> { | ||
195 | db.impls_in_module_with_source_map(module).0 | ||
196 | } | ||
197 | |||
179 | fn collect( | 198 | fn collect( |
180 | db: &(impl DefDatabase + AstDatabase), | 199 | db: &(impl DefDatabase + AstDatabase), |
181 | cfg_options: &CfgOptions, | 200 | cfg_options: &CfgOptions, |
@@ -264,19 +283,3 @@ impl ModuleImplBlocks { | |||
264 | } | 283 | } |
265 | } | 284 | } |
266 | } | 285 | } |
267 | |||
268 | pub(crate) fn impls_in_module_with_source_map_query( | ||
269 | db: &(impl DefDatabase + AstDatabase), | ||
270 | module: Module, | ||
271 | ) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>) { | ||
272 | let mut source_map = ImplSourceMap::default(); | ||
273 | let crate_graph = db.crate_graph(); | ||
274 | let cfg_options = crate_graph.cfg_options(module.krate.crate_id()); | ||
275 | |||
276 | let result = ModuleImplBlocks::collect(db, cfg_options, module, &mut source_map); | ||
277 | (Arc::new(result), Arc::new(source_map)) | ||
278 | } | ||
279 | |||
280 | pub(crate) fn impls_in_module(db: &impl DefDatabase, module: Module) -> Arc<ModuleImplBlocks> { | ||
281 | db.impls_in_module_with_source_map(module).0 | ||
282 | } | ||
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs index 3b38c4740..674a46102 100644 --- a/crates/ra_hir/src/type_alias.rs +++ b/crates/ra_hir/src/type_alias.rs | |||
@@ -17,12 +17,14 @@ pub struct TypeAliasData { | |||
17 | pub(crate) type_ref: Option<TypeRef>, | 17 | pub(crate) type_ref: Option<TypeRef>, |
18 | } | 18 | } |
19 | 19 | ||
20 | pub(crate) fn type_alias_data_query( | 20 | impl TypeAliasData { |
21 | db: &(impl DefDatabase + AstDatabase), | 21 | pub(crate) fn type_alias_data_query( |
22 | typ: TypeAlias, | 22 | db: &(impl DefDatabase + AstDatabase), |
23 | ) -> Arc<TypeAliasData> { | 23 | typ: TypeAlias, |
24 | let node = typ.source(db).ast; | 24 | ) -> Arc<TypeAliasData> { |
25 | let name = node.name().map_or_else(Name::missing, |n| n.as_name()); | 25 | let node = typ.source(db).ast; |
26 | let type_ref = node.type_ref().map(TypeRef::from_ast); | 26 | let name = node.name().map_or_else(Name::missing, |n| n.as_name()); |
27 | Arc::new(TypeAliasData { name, type_ref }) | 27 | let type_ref = node.type_ref().map(TypeRef::from_ast); |
28 | Arc::new(TypeAliasData { name, type_ref }) | ||
29 | } | ||
28 | } | 30 | } |