diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/raw.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index afd538e4a..39b011ad7 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -266,8 +266,8 @@ impl RawItemsCollector { | |||
266 | self.add_macro(current_module, it); | 266 | self.add_macro(current_module, it); |
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | ast::ModuleItem::ExternBlock(_) => { | 269 | ast::ModuleItem::ExternBlock(it) => { |
270 | // FIXME: add extern block | 270 | self.add_extern_block(current_module, it); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | }; | 273 | }; |
@@ -278,6 +278,34 @@ impl RawItemsCollector { | |||
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | fn add_extern_block( | ||
282 | &mut self, | ||
283 | current_module: Option<Idx<ModuleData>>, | ||
284 | block: ast::ExternBlock, | ||
285 | ) { | ||
286 | if let Some(items) = block.extern_item_list() { | ||
287 | for item in items.extern_items() { | ||
288 | let attrs = self.parse_attrs(&item); | ||
289 | let visibility = | ||
290 | RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene); | ||
291 | let (kind, name) = match item { | ||
292 | ast::ExternItem::FnDef(it) => { | ||
293 | (DefKind::Function(self.source_ast_id_map.ast_id(&it)), it.name()) | ||
294 | } | ||
295 | ast::ExternItem::StaticDef(it) => { | ||
296 | (DefKind::Static(self.source_ast_id_map.ast_id(&it)), it.name()) | ||
297 | } | ||
298 | }; | ||
299 | |||
300 | if let Some(name) = name { | ||
301 | let name = name.as_name(); | ||
302 | let def = self.raw_items.defs.alloc(DefData { name, kind, visibility }); | ||
303 | self.push_item(current_module, attrs, RawItemKind::Def(def)); | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | } | ||
308 | |||
281 | fn add_module(&mut self, current_module: Option<Idx<ModuleData>>, module: ast::Module) { | 309 | fn add_module(&mut self, current_module: Option<Idx<ModuleData>>, module: ast::Module) { |
282 | let name = match module.name() { | 310 | let name = match module.name() { |
283 | Some(it) => it.as_name(), | 311 | Some(it) => it.as_name(), |