From 762ec9581a4331a2726cc236c565323d0c8cdb07 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Mon, 11 May 2020 12:25:18 +0300 Subject: Find references to a function outside module --- crates/ra_ide_db/src/defs.rs | 1 + 1 file changed, 1 insertion(+) (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 f990e3bb9..c74daff38 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -52,6 +52,7 @@ impl Definition { let parent = id.parent_enum(db); module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent))) } + ModuleDef::Function(f) => Some(f.visibility(db)), _ => module?.visibility_of(db, def), }, Definition::SelfType(_) => None, -- cgit v1.2.3 From 753e1e679cf14b4ead73602976d43a8dc89a7052 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Mon, 11 May 2020 13:52:20 +0300 Subject: Also for consts and type aliases --- crates/ra_ide_db/src/defs.rs | 2 ++ 1 file changed, 2 insertions(+) (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 c74daff38..bddfef240 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -53,6 +53,8 @@ impl Definition { 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::SelfType(_) => None, -- cgit v1.2.3 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