aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-08 11:20:59 +0000
committerAleksey Kladov <[email protected]>2019-12-08 11:24:21 +0000
commit7aacf9a19739f53a45840df2d08b5f3cca761192 (patch)
treee8ab5c5a7168e9c7068e34609456a543dad3e00e /crates/ra_hir/src
parent200bda3daf66f338e9bb1d833146f06fb81f829e (diff)
Drop some unused methods
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs48
-rw-r--r--crates/ra_hir/src/from_source.rs6
2 files changed, 5 insertions, 49 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index e854b22bf..9cbea024a 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -158,13 +158,6 @@ impl Module {
158 self.with_module_id(def_map.root) 158 self.with_module_id(def_map.root)
159 } 159 }
160 160
161 /// Finds a child module with the specified name.
162 pub fn child(self, db: &impl DefDatabase, name: &Name) -> Option<Module> {
163 let def_map = db.crate_def_map(self.id.krate);
164 let child_id = def_map[self.id.local_id].children.get(name)?;
165 Some(self.with_module_id(*child_id))
166 }
167
168 /// Iterates over all child modules. 161 /// Iterates over all child modules.
169 pub fn children(self, db: &impl DefDatabase) -> impl Iterator<Item = Module> { 162 pub fn children(self, db: &impl DefDatabase) -> impl Iterator<Item = Module> {
170 let def_map = db.crate_def_map(self.id.krate); 163 let def_map = db.crate_def_map(self.id.krate);
@@ -238,7 +231,7 @@ impl Module {
238 def_map[self.id.local_id].impls.iter().copied().map(ImplBlock::from).collect() 231 def_map[self.id.local_id].impls.iter().copied().map(ImplBlock::from).collect()
239 } 232 }
240 233
241 fn with_module_id(self, module_id: LocalModuleId) -> Module { 234 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
242 Module::new(self.krate(), module_id) 235 Module::new(self.krate(), module_id)
243 } 236 }
244} 237}
@@ -303,23 +296,10 @@ impl Struct {
303 .collect() 296 .collect()
304 } 297 }
305 298
306 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
307 db.struct_data(self.id.into())
308 .variant_data
309 .fields()
310 .iter()
311 .find(|(_id, data)| data.name == *name)
312 .map(|(id, _)| StructField { parent: self.into(), id })
313 }
314
315 pub fn ty(self, db: &impl HirDatabase) -> Type { 299 pub fn ty(self, db: &impl HirDatabase) -> Type {
316 Type::from_def(db, self.id.module(db).krate, self.id) 300 Type::from_def(db, self.id.module(db).krate, self.id)
317 } 301 }
318 302
319 pub fn constructor_ty(self, db: &impl HirDatabase) -> Ty {
320 db.value_ty(self.id.into())
321 }
322
323 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 303 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
324 db.struct_data(self.id.into()).variant_data.clone() 304 db.struct_data(self.id.into()).variant_data.clone()
325 } 305 }
@@ -352,15 +332,6 @@ impl Union {
352 .collect() 332 .collect()
353 } 333 }
354 334
355 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
356 db.union_data(self.id)
357 .variant_data
358 .fields()
359 .iter()
360 .find(|(_id, data)| data.name == *name)
361 .map(|(id, _)| StructField { parent: self.into(), id })
362 }
363
364 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 335 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
365 db.union_data(self.id).variant_data.clone() 336 db.union_data(self.id).variant_data.clone()
366 } 337 }
@@ -392,11 +363,6 @@ impl Enum {
392 .collect() 363 .collect()
393 } 364 }
394 365
395 pub fn variant(self, db: &impl DefDatabase, name: &Name) -> Option<EnumVariant> {
396 let id = db.enum_data(self.id).variant(name)?;
397 Some(EnumVariant { parent: self, id })
398 }
399
400 pub fn ty(self, db: &impl HirDatabase) -> Type { 366 pub fn ty(self, db: &impl HirDatabase) -> Type {
401 Type::from_def(db, self.id.module(db).krate, self.id) 367 Type::from_def(db, self.id.module(db).krate, self.id)
402 } 368 }
@@ -428,14 +394,6 @@ impl EnumVariant {
428 .collect() 394 .collect()
429 } 395 }
430 396
431 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
432 self.variant_data(db)
433 .fields()
434 .iter()
435 .find(|(_id, data)| data.name == *name)
436 .map(|(id, _)| StructField { parent: self.into(), id })
437 }
438
439 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 397 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
440 db.enum_data(self.parent.id).variants[self.id].variant_data.clone() 398 db.enum_data(self.parent.id).variants[self.id].variant_data.clone()
441 } 399 }
@@ -561,10 +519,6 @@ impl Function {
561 db.body(self.id.into()) 519 db.body(self.id.into())
562 } 520 }
563 521
564 pub fn ty(self, db: &impl HirDatabase) -> Ty {
565 db.value_ty(self.id.into())
566 }
567
568 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 522 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
569 db.infer(self.id.into()) 523 db.infer(self.id.into())
570 } 524 }
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index 071ca2e5a..307f3d5bf 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -216,8 +216,10 @@ impl Module {
216 } 216 }
217 }?; 217 }?;
218 218
219 let child_name = src.value.name()?; 219 let child_name = src.value.name()?.as_name();
220 parent_module.child(db, &child_name.as_name()) 220 let def_map = db.crate_def_map(parent_module.id.krate);
221 let child_id = def_map[parent_module.id.local_id].children.get(&child_name)?;
222 Some(parent_module.with_module_id(*child_id))
221 } 223 }
222 224
223 pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Option<Self> { 225 pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Option<Self> {