diff options
author | Florian Diebold <[email protected]> | 2019-12-26 14:57:14 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-12-26 15:23:40 +0000 |
commit | e1a2961273bdf7ef24c81f22fe86041a20812365 (patch) | |
tree | 1b2e3e4e76b121a43a6fc3fb1112668089c44abc /crates/ra_hir_def/src/visibility.rs | |
parent | 04e8eaa14b11c432d43ad95f3766f8649da30347 (diff) |
Rename Visibility -> RawVisibility
Diffstat (limited to 'crates/ra_hir_def/src/visibility.rs')
-rw-r--r-- | crates/ra_hir_def/src/visibility.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index 990b2975c..b11e9bc52 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs | |||
@@ -16,7 +16,7 @@ use crate::{ | |||
16 | 16 | ||
17 | /// Visibility of an item, not yet resolved. | 17 | /// Visibility of an item, not yet resolved. |
18 | #[derive(Debug, Clone, PartialEq, Eq)] | 18 | #[derive(Debug, Clone, PartialEq, Eq)] |
19 | pub enum Visibility { | 19 | pub enum RawVisibility { |
20 | // FIXME: We could avoid the allocation in many cases by special-casing | 20 | // FIXME: We could avoid the allocation in many cases by special-casing |
21 | // pub(crate), pub(super) and private. Alternatively, `ModPath` could be | 21 | // pub(crate), pub(super) and private. Alternatively, `ModPath` could be |
22 | // made to contain an Arc<[Segment]> instead of a Vec? | 22 | // made to contain an Arc<[Segment]> instead of a Vec? |
@@ -27,16 +27,16 @@ pub enum Visibility { | |||
27 | Public, | 27 | Public, |
28 | } | 28 | } |
29 | 29 | ||
30 | impl Visibility { | 30 | impl RawVisibility { |
31 | pub(crate) fn visibility_query(db: &impl DefDatabase, def: VisibilityDefId) -> Visibility { | 31 | pub(crate) fn visibility_query(db: &impl DefDatabase, def: VisibilityDefId) -> RawVisibility { |
32 | match def { | 32 | match def { |
33 | VisibilityDefId::ModuleId(module) => { | 33 | VisibilityDefId::ModuleId(module) => { |
34 | let def_map = db.crate_def_map(module.krate); | 34 | let def_map = db.crate_def_map(module.krate); |
35 | let src = match def_map[module.local_id].declaration_source(db) { | 35 | let src = match def_map[module.local_id].declaration_source(db) { |
36 | Some(it) => it, | 36 | Some(it) => it, |
37 | None => return Visibility::private(), | 37 | None => return RawVisibility::private(), |
38 | }; | 38 | }; |
39 | Visibility::from_ast(db, src.map(|it| it.visibility())) | 39 | RawVisibility::from_ast(db, src.map(|it| it.visibility())) |
40 | } | 40 | } |
41 | VisibilityDefId::StructFieldId(it) => { | 41 | VisibilityDefId::StructFieldId(it) => { |
42 | let src = it.parent.child_source(db); | 42 | let src = it.parent.child_source(db); |
@@ -49,9 +49,9 @@ impl Visibility { | |||
49 | Either::Right(record) => record.visibility(), | 49 | Either::Right(record) => record.visibility(), |
50 | }); | 50 | }); |
51 | if vis_node.value.is_none() && is_enum { | 51 | if vis_node.value.is_none() && is_enum { |
52 | Visibility::Public | 52 | RawVisibility::Public |
53 | } else { | 53 | } else { |
54 | Visibility::from_ast(db, vis_node) | 54 | RawVisibility::from_ast(db, vis_node) |
55 | } | 55 | } |
56 | } | 56 | } |
57 | VisibilityDefId::AdtId(it) => match it { | 57 | VisibilityDefId::AdtId(it) => match it { |
@@ -67,41 +67,41 @@ impl Visibility { | |||
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | fn private() -> Visibility { | 70 | fn private() -> RawVisibility { |
71 | let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() }; | 71 | let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() }; |
72 | Visibility::Module(Arc::new(path)) | 72 | RawVisibility::Module(Arc::new(path)) |
73 | } | 73 | } |
74 | 74 | ||
75 | fn from_ast(db: &impl DefDatabase, node: InFile<Option<ast::Visibility>>) -> Visibility { | 75 | fn from_ast(db: &impl DefDatabase, node: InFile<Option<ast::Visibility>>) -> RawVisibility { |
76 | Self::from_ast_with_hygiene(node.value, &Hygiene::new(db, node.file_id)) | 76 | Self::from_ast_with_hygiene(node.value, &Hygiene::new(db, node.file_id)) |
77 | } | 77 | } |
78 | 78 | ||
79 | pub(crate) fn from_ast_with_hygiene( | 79 | pub(crate) fn from_ast_with_hygiene( |
80 | node: Option<ast::Visibility>, | 80 | node: Option<ast::Visibility>, |
81 | hygiene: &Hygiene, | 81 | hygiene: &Hygiene, |
82 | ) -> Visibility { | 82 | ) -> RawVisibility { |
83 | let node = match node { | 83 | let node = match node { |
84 | None => return Visibility::private(), | 84 | None => return RawVisibility::private(), |
85 | Some(node) => node, | 85 | Some(node) => node, |
86 | }; | 86 | }; |
87 | match node.kind() { | 87 | match node.kind() { |
88 | ast::VisibilityKind::In(path) => { | 88 | ast::VisibilityKind::In(path) => { |
89 | let path = ModPath::from_src(path, hygiene); | 89 | let path = ModPath::from_src(path, hygiene); |
90 | let path = match path { | 90 | let path = match path { |
91 | None => return Visibility::private(), | 91 | None => return RawVisibility::private(), |
92 | Some(path) => path, | 92 | Some(path) => path, |
93 | }; | 93 | }; |
94 | Visibility::Module(Arc::new(path)) | 94 | RawVisibility::Module(Arc::new(path)) |
95 | } | 95 | } |
96 | ast::VisibilityKind::PubCrate => { | 96 | ast::VisibilityKind::PubCrate => { |
97 | let path = ModPath { kind: PathKind::Crate, segments: Vec::new() }; | 97 | let path = ModPath { kind: PathKind::Crate, segments: Vec::new() }; |
98 | Visibility::Module(Arc::new(path)) | 98 | RawVisibility::Module(Arc::new(path)) |
99 | } | 99 | } |
100 | ast::VisibilityKind::PubSuper => { | 100 | ast::VisibilityKind::PubSuper => { |
101 | let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; | 101 | let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; |
102 | Visibility::Module(Arc::new(path)) | 102 | RawVisibility::Module(Arc::new(path)) |
103 | } | 103 | } |
104 | ast::VisibilityKind::Pub => Visibility::Public, | 104 | ast::VisibilityKind::Pub => RawVisibility::Public, |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
@@ -156,11 +156,11 @@ impl ResolvedVisibility { | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | fn visibility_from_loc<T>(node: T, db: &impl DefDatabase) -> Visibility | 159 | fn visibility_from_loc<T>(node: T, db: &impl DefDatabase) -> RawVisibility |
160 | where | 160 | where |
161 | T: HasSource, | 161 | T: HasSource, |
162 | T::Value: ast::VisibilityOwner, | 162 | T::Value: ast::VisibilityOwner, |
163 | { | 163 | { |
164 | let src = node.source(db); | 164 | let src = node.source(db); |
165 | Visibility::from_ast(db, src.map(|n| n.visibility())) | 165 | RawVisibility::from_ast(db, src.map(|n| n.visibility())) |
166 | } | 166 | } |