diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/data.rs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 8b343af9d..a72eb5369 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -97,6 +97,7 @@ fn desugar_future_path(orig: TypeRef) -> Path { | |||
97 | pub struct TypeAliasData { | 97 | pub struct TypeAliasData { |
98 | pub name: Name, | 98 | pub name: Name, |
99 | pub type_ref: Option<TypeRef>, | 99 | pub type_ref: Option<TypeRef>, |
100 | pub visibility: RawVisibility, | ||
100 | } | 101 | } |
101 | 102 | ||
102 | impl TypeAliasData { | 103 | impl TypeAliasData { |
@@ -104,10 +105,11 @@ impl TypeAliasData { | |||
104 | db: &impl DefDatabase, | 105 | db: &impl DefDatabase, |
105 | typ: TypeAliasId, | 106 | typ: TypeAliasId, |
106 | ) -> Arc<TypeAliasData> { | 107 | ) -> Arc<TypeAliasData> { |
107 | let node = typ.lookup(db).source(db).value; | 108 | let node = typ.lookup(db).source(db); |
108 | let name = node.name().map_or_else(Name::missing, |n| n.as_name()); | 109 | let name = node.value.name().map_or_else(Name::missing, |n| n.as_name()); |
109 | let type_ref = node.type_ref().map(TypeRef::from_ast); | 110 | let type_ref = node.value.type_ref().map(TypeRef::from_ast); |
110 | Arc::new(TypeAliasData { name, type_ref }) | 111 | let visibility = RawVisibility::from_ast(db, node.map(|n| n.visibility())); |
112 | Arc::new(TypeAliasData { name, type_ref, visibility }) | ||
111 | } | 113 | } |
112 | } | 114 | } |
113 | 115 | ||
@@ -223,23 +225,28 @@ pub struct ConstData { | |||
223 | /// const _: () = (); | 225 | /// const _: () = (); |
224 | pub name: Option<Name>, | 226 | pub name: Option<Name>, |
225 | pub type_ref: TypeRef, | 227 | pub type_ref: TypeRef, |
228 | pub visibility: RawVisibility, | ||
226 | } | 229 | } |
227 | 230 | ||
228 | impl ConstData { | 231 | impl ConstData { |
229 | pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> { | 232 | pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> { |
230 | let node = konst.lookup(db).source(db).value; | 233 | let node = konst.lookup(db).source(db); |
231 | Arc::new(ConstData::new(&node)) | 234 | Arc::new(ConstData::new(db, node)) |
232 | } | 235 | } |
233 | 236 | ||
234 | pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> { | 237 | pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> { |
235 | let node = konst.lookup(db).source(db).value; | 238 | let node = konst.lookup(db).source(db); |
236 | Arc::new(ConstData::new(&node)) | 239 | Arc::new(ConstData::new(db, node)) |
237 | } | 240 | } |
238 | 241 | ||
239 | fn new<N: NameOwner + TypeAscriptionOwner + VisibilityOwner>(node: &N) -> ConstData { | 242 | fn new<N: NameOwner + TypeAscriptionOwner + VisibilityOwner>( |
240 | let name = node.name().map(|n| n.as_name()); | 243 | db: &impl DefDatabase, |
241 | let type_ref = TypeRef::from_ast_opt(node.ascribed_type()); | 244 | node: InFile<N>, |
242 | ConstData { name, type_ref } | 245 | ) -> ConstData { |
246 | let name = node.value.name().map(|n| n.as_name()); | ||
247 | let type_ref = TypeRef::from_ast_opt(node.value.ascribed_type()); | ||
248 | let visibility = RawVisibility::from_ast(db, node.map(|n| n.visibility())); | ||
249 | ConstData { name, type_ref, visibility } | ||
243 | } | 250 | } |
244 | } | 251 | } |
245 | 252 | ||