diff options
Diffstat (limited to 'crates/ra_hir/src/impl_block.rs')
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 0d3861a28..40d368cd9 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -9,7 +9,7 @@ use ra_syntax::{ | |||
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | Const, TypeAlias, Function, HirFileId, | 11 | Const, TypeAlias, Function, HirFileId, |
12 | HirDatabase, PersistentHirDatabase, | 12 | HirDatabase, DefDatabase, |
13 | ModuleDef, Trait, Resolution, | 13 | ModuleDef, Trait, Resolution, |
14 | type_ref::TypeRef, | 14 | type_ref::TypeRef, |
15 | ids::LocationCtx, | 15 | ids::LocationCtx, |
@@ -59,7 +59,7 @@ impl ImplBlock { | |||
59 | } | 59 | } |
60 | 60 | ||
61 | /// Returns the syntax of the impl block | 61 | /// Returns the syntax of the impl block |
62 | pub fn source(&self, db: &impl PersistentHirDatabase) -> (HirFileId, TreeArc<ast::ImplBlock>) { | 62 | pub fn source(&self, db: &impl DefDatabase) -> (HirFileId, TreeArc<ast::ImplBlock>) { |
63 | let source_map = db.impls_in_module_source_map(self.module); | 63 | let source_map = db.impls_in_module_source_map(self.module); |
64 | let (file_id, source) = self.module.definition_source(db); | 64 | let (file_id, source) = self.module.definition_source(db); |
65 | (file_id, source_map.get(&source, self.impl_id)) | 65 | (file_id, source_map.get(&source, self.impl_id)) |
@@ -73,11 +73,11 @@ impl ImplBlock { | |||
73 | self.module | 73 | self.module |
74 | } | 74 | } |
75 | 75 | ||
76 | pub fn target_trait_ref(&self, db: &impl PersistentHirDatabase) -> Option<TypeRef> { | 76 | pub fn target_trait_ref(&self, db: &impl DefDatabase) -> Option<TypeRef> { |
77 | db.impls_in_module(self.module).impls[self.impl_id].target_trait().cloned() | 77 | db.impls_in_module(self.module).impls[self.impl_id].target_trait().cloned() |
78 | } | 78 | } |
79 | 79 | ||
80 | pub fn target_type(&self, db: &impl PersistentHirDatabase) -> TypeRef { | 80 | pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef { |
81 | db.impls_in_module(self.module).impls[self.impl_id].target_type().clone() | 81 | db.impls_in_module(self.module).impls[self.impl_id].target_type().clone() |
82 | } | 82 | } |
83 | 83 | ||
@@ -97,11 +97,11 @@ impl ImplBlock { | |||
97 | None | 97 | None |
98 | } | 98 | } |
99 | 99 | ||
100 | pub fn items(&self, db: &impl PersistentHirDatabase) -> Vec<ImplItem> { | 100 | pub fn items(&self, db: &impl DefDatabase) -> Vec<ImplItem> { |
101 | db.impls_in_module(self.module).impls[self.impl_id].items().to_vec() | 101 | db.impls_in_module(self.module).impls[self.impl_id].items().to_vec() |
102 | } | 102 | } |
103 | 103 | ||
104 | pub fn generic_params(&self, db: &impl PersistentHirDatabase) -> Arc<GenericParams> { | 104 | pub fn generic_params(&self, db: &impl DefDatabase) -> Arc<GenericParams> { |
105 | db.generic_params((*self).into()) | 105 | db.generic_params((*self).into()) |
106 | } | 106 | } |
107 | 107 | ||
@@ -124,7 +124,7 @@ pub struct ImplData { | |||
124 | 124 | ||
125 | impl ImplData { | 125 | impl ImplData { |
126 | pub(crate) fn from_ast( | 126 | pub(crate) fn from_ast( |
127 | db: &impl PersistentHirDatabase, | 127 | db: &impl DefDatabase, |
128 | file_id: HirFileId, | 128 | file_id: HirFileId, |
129 | module: Module, | 129 | module: Module, |
130 | node: &ast::ImplBlock, | 130 | node: &ast::ImplBlock, |
@@ -193,11 +193,7 @@ pub struct ModuleImplBlocks { | |||
193 | } | 193 | } |
194 | 194 | ||
195 | impl ModuleImplBlocks { | 195 | impl ModuleImplBlocks { |
196 | fn collect( | 196 | fn collect(db: &impl DefDatabase, module: Module, source_map: &mut ImplSourceMap) -> Self { |
197 | db: &impl PersistentHirDatabase, | ||
198 | module: Module, | ||
199 | source_map: &mut ImplSourceMap, | ||
200 | ) -> Self { | ||
201 | let mut m = ModuleImplBlocks { | 197 | let mut m = ModuleImplBlocks { |
202 | module, | 198 | module, |
203 | impls: Arena::default(), | 199 | impls: Arena::default(), |
@@ -228,7 +224,7 @@ impl ModuleImplBlocks { | |||
228 | } | 224 | } |
229 | 225 | ||
230 | pub(crate) fn impls_in_module_with_source_map_query( | 226 | pub(crate) fn impls_in_module_with_source_map_query( |
231 | db: &impl PersistentHirDatabase, | 227 | db: &impl DefDatabase, |
232 | module: Module, | 228 | module: Module, |
233 | ) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>) { | 229 | ) -> (Arc<ModuleImplBlocks>, Arc<ImplSourceMap>) { |
234 | let mut source_map = ImplSourceMap::default(); | 230 | let mut source_map = ImplSourceMap::default(); |
@@ -238,15 +234,12 @@ pub(crate) fn impls_in_module_with_source_map_query( | |||
238 | (Arc::new(result), Arc::new(source_map)) | 234 | (Arc::new(result), Arc::new(source_map)) |
239 | } | 235 | } |
240 | 236 | ||
241 | pub(crate) fn impls_in_module( | 237 | pub(crate) fn impls_in_module(db: &impl DefDatabase, module: Module) -> Arc<ModuleImplBlocks> { |
242 | db: &impl PersistentHirDatabase, | ||
243 | module: Module, | ||
244 | ) -> Arc<ModuleImplBlocks> { | ||
245 | db.impls_in_module_with_source_map(module).0 | 238 | db.impls_in_module_with_source_map(module).0 |
246 | } | 239 | } |
247 | 240 | ||
248 | pub(crate) fn impls_in_module_source_map_query( | 241 | pub(crate) fn impls_in_module_source_map_query( |
249 | db: &impl PersistentHirDatabase, | 242 | db: &impl DefDatabase, |
250 | module: Module, | 243 | module: Module, |
251 | ) -> Arc<ImplSourceMap> { | 244 | ) -> Arc<ImplSourceMap> { |
252 | db.impls_in_module_with_source_map(module).1 | 245 | db.impls_in_module_with_source_map(module).1 |