diff options
Diffstat (limited to 'crates/ra_ide_db/src/defs.rs')
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 97961bb6d..e9934844e 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -6,12 +6,12 @@ | |||
6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). | 6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). |
7 | 7 | ||
8 | use hir::{ | 8 | use hir::{ |
9 | Adt, FieldSource, HasSource, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, | 9 | HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, |
10 | Semantics, StructField, TypeParam, | 10 | StructField, TypeParam, Visibility, |
11 | }; | 11 | }; |
12 | use ra_prof::profile; | 12 | use ra_prof::profile; |
13 | use ra_syntax::{ | 13 | use ra_syntax::{ |
14 | ast::{self, AstNode, VisibilityOwner}, | 14 | ast::{self, AstNode}, |
15 | match_ast, | 15 | match_ast, |
16 | }; | 16 | }; |
17 | use test_utils::tested_by; | 17 | use test_utils::tested_by; |
@@ -41,28 +41,13 @@ impl Definition { | |||
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | pub fn visibility(&self, db: &RootDatabase) -> Option<ast::Visibility> { | 44 | pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> { |
45 | let module = self.module(db); | ||
46 | |||
45 | match self { | 47 | match self { |
46 | Definition::Macro(_) => None, | 48 | Definition::Macro(_) => None, |
47 | Definition::StructField(sf) => match sf.source(db).value { | 49 | Definition::StructField(sf) => Some(sf.visibility(db)), |
48 | FieldSource::Named(it) => it.visibility(), | 50 | Definition::ModuleDef(def) => module?.visibility_of(db, def), |
49 | FieldSource::Pos(it) => it.visibility(), | ||
50 | }, | ||
51 | Definition::ModuleDef(def) => match def { | ||
52 | ModuleDef::Module(it) => it.declaration_source(db)?.value.visibility(), | ||
53 | ModuleDef::Function(it) => it.source(db).value.visibility(), | ||
54 | ModuleDef::Adt(adt) => match adt { | ||
55 | Adt::Struct(it) => it.source(db).value.visibility(), | ||
56 | Adt::Union(it) => it.source(db).value.visibility(), | ||
57 | Adt::Enum(it) => it.source(db).value.visibility(), | ||
58 | }, | ||
59 | ModuleDef::Const(it) => it.source(db).value.visibility(), | ||
60 | ModuleDef::Static(it) => it.source(db).value.visibility(), | ||
61 | ModuleDef::Trait(it) => it.source(db).value.visibility(), | ||
62 | ModuleDef::TypeAlias(it) => it.source(db).value.visibility(), | ||
63 | ModuleDef::EnumVariant(_) => None, | ||
64 | ModuleDef::BuiltinType(_) => None, | ||
65 | }, | ||
66 | Definition::SelfType(_) => None, | 51 | Definition::SelfType(_) => None, |
67 | Definition::Local(_) => None, | 52 | Definition::Local(_) => None, |
68 | Definition::TypeParam(_) => None, | 53 | Definition::TypeParam(_) => None, |