From 3d66aa054230ad788162ce49f0d334e900458cac Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Mon, 11 May 2020 14:28:14 +0300 Subject: New definition_visibility method --- crates/ra_ide_db/src/defs.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'crates/ra_ide_db') diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index bddfef240..60c11178e 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -6,7 +6,7 @@ // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). use hir::{ - Adt, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, + Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, }; use ra_prof::profile; @@ -42,21 +42,10 @@ impl Definition { } pub fn visibility(&self, db: &RootDatabase) -> Option { - let module = self.module(db); - match self { Definition::Macro(_) => None, Definition::Field(sf) => Some(sf.visibility(db)), - Definition::ModuleDef(def) => match def { - ModuleDef::EnumVariant(id) => { - let parent = id.parent_enum(db); - module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent))) - } - ModuleDef::Function(f) => Some(f.visibility(db)), - ModuleDef::Const(c) => Some(c.visibility(db)), - ModuleDef::TypeAlias(t) => Some(t.visibility(db)), - _ => module?.visibility_of(db, def), - }, + Definition::ModuleDef(def) => def.definition_visibility(db), Definition::SelfType(_) => None, Definition::Local(_) => None, Definition::TypeParam(_) => None, -- cgit v1.2.3