aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db
diff options
context:
space:
mode:
authorFedor Sakharov <[email protected]>2020-05-11 12:28:14 +0100
committerFedor Sakharov <[email protected]>2020-05-11 12:28:14 +0100
commit3d66aa054230ad788162ce49f0d334e900458cac (patch)
tree7828ed862f66f0e99f448e3112930ea602aef3c7 /crates/ra_ide_db
parent753e1e679cf14b4ead73602976d43a8dc89a7052 (diff)
New definition_visibility method
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r--crates/ra_ide_db/src/defs.rs15
1 files changed, 2 insertions, 13 deletions
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 @@
6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). 6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
7 7
8use hir::{ 8use hir::{
9 Adt, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, 9 Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution,
10 Semantics, TypeParam, Visibility, 10 Semantics, TypeParam, Visibility,
11}; 11};
12use ra_prof::profile; 12use ra_prof::profile;
@@ -42,21 +42,10 @@ impl Definition {
42 } 42 }
43 43
44 pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> { 44 pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> {
45 let module = self.module(db);
46
47 match self { 45 match self {
48 Definition::Macro(_) => None, 46 Definition::Macro(_) => None,
49 Definition::Field(sf) => Some(sf.visibility(db)), 47 Definition::Field(sf) => Some(sf.visibility(db)),
50 Definition::ModuleDef(def) => match def { 48 Definition::ModuleDef(def) => def.definition_visibility(db),
51 ModuleDef::EnumVariant(id) => {
52 let parent = id.parent_enum(db);
53 module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent)))
54 }
55 ModuleDef::Function(f) => Some(f.visibility(db)),
56 ModuleDef::Const(c) => Some(c.visibility(db)),
57 ModuleDef::TypeAlias(t) => Some(t.visibility(db)),
58 _ => module?.visibility_of(db, def),
59 },
60 Definition::SelfType(_) => None, 49 Definition::SelfType(_) => None,
61 Definition::Local(_) => None, 50 Definition::Local(_) => None,
62 Definition::TypeParam(_) => None, 51 Definition::TypeParam(_) => None,