From 9d4af40995b4d01ad9b75dee0a000dd57b8bd87f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 1 Jan 2019 20:17:10 +0300 Subject: work towards brining macros to nameres --- crates/ra_hir/src/macros.rs | 6 +++--- crates/ra_hir/src/module/nameres.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 932e2b574..3eedd9e2d 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs @@ -16,9 +16,9 @@ ra_db::impl_numeric_id!(MacroCallId); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct MacroCallLoc { - source_root_id: SourceRootId, - module_id: ModuleId, - source_item_id: SourceItemId, + pub(crate) source_root_id: SourceRootId, + pub(crate) module_id: ModuleId, + pub(crate) source_item_id: SourceItemId, } impl MacroCallId { diff --git a/crates/ra_hir/src/module/nameres.rs b/crates/ra_hir/src/module/nameres.rs index 68eb02a98..46b1dc0b1 100644 --- a/crates/ra_hir/src/module/nameres.rs +++ b/crates/ra_hir/src/module/nameres.rs @@ -31,6 +31,7 @@ use crate::{ Path, PathKind, HirDatabase, Crate, Name, AsName, + macros::{MacroCallId, MacroCallLoc}, module::{Module, ModuleId, ModuleTree}, }; @@ -354,6 +355,18 @@ where if item.kind == MODULE { continue; } + if item.kind == MACRO_CALL { + let loc = MacroCallLoc { + source_root_id: self.source_root, + module_id, + source_item_id: SourceItemId { + file_id, + item_id: Some(item.id), + }, + }; + let id = loc.id(self.db); + continue; + } // depending on the item kind, the location can define something in // the values namespace, the types namespace, or both let kind = DefKind::for_syntax_kind(item.kind); -- cgit v1.2.3