From d0b6ed4441469acfb6bc6555d78abf12637b6cf4 Mon Sep 17 00:00:00 2001
From: Edwin Cheng <edwin0cheng@gmail.com>
Date: Wed, 18 Mar 2020 20:56:46 +0800
Subject: Add ProcMacroClient

---
 crates/ra_hir_def/src/nameres/collector.rs | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

(limited to 'crates/ra_hir_def/src')

diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 9c125f32f..9b46431cb 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -11,8 +11,8 @@ use hir_expand::{
     HirFileId, MacroCallId, MacroDefId, MacroDefKind,
 };
 use ra_cfg::CfgOptions;
-use ra_db::{CrateId, FileId};
-use ra_syntax::ast;
+use ra_db::{CrateId, FileId, ProcMacroId};
+use ra_syntax::{ast, SmolStr};
 use rustc_hash::FxHashMap;
 use test_utils::tested_by;
 
@@ -53,6 +53,16 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> Cr
     }
 
     let cfg_options = &crate_graph[def_map.krate].cfg_options;
+    let proc_macros = &crate_graph[def_map.krate].proc_macro;
+    let proc_macros = proc_macros
+        .iter()
+        .enumerate()
+        .map(|(idx, it)| {
+            // FIXME: a hacky way to create a Name from string.
+            let name = tt::Ident { text: SmolStr::new(&it.name()), id: tt::TokenId::unspecified() };
+            (name.as_name(), ProcMacroExpander::new(def_map.krate, ProcMacroId(idx)))
+        })
+        .collect();
 
     let mut collector = DefCollector {
         db,
@@ -65,9 +75,7 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> Cr
         unexpanded_attribute_macros: Vec::new(),
         mod_dirs: FxHashMap::default(),
         cfg_options,
-
-        // FIXME: pass proc-macro from crate-graph
-        proc_macros: Default::default(),
+        proc_macros,
     };
     collector.collect();
     collector.finish()
-- 
cgit v1.2.3


From db162df264a222021dbc7f1f93af94029f3948d9 Mon Sep 17 00:00:00 2001
From: Edwin Cheng <edwin0cheng@gmail.com>
Date: Fri, 27 Mar 2020 00:41:44 +0800
Subject: Remove deps on tt_mbe

---
 crates/ra_hir_def/src/nameres/collector.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'crates/ra_hir_def/src')

diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 9b46431cb..8fe3f8617 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -12,7 +12,7 @@ use hir_expand::{
 };
 use ra_cfg::CfgOptions;
 use ra_db::{CrateId, FileId, ProcMacroId};
-use ra_syntax::{ast, SmolStr};
+use ra_syntax::ast;
 use rustc_hash::FxHashMap;
 use test_utils::tested_by;
 
@@ -59,8 +59,8 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> Cr
         .enumerate()
         .map(|(idx, it)| {
             // FIXME: a hacky way to create a Name from string.
-            let name = tt::Ident { text: SmolStr::new(&it.name()), id: tt::TokenId::unspecified() };
-            (name.as_name(), ProcMacroExpander::new(def_map.krate, ProcMacroId(idx)))
+            let name = tt::Ident { text: it.name.clone(), id: tt::TokenId::unspecified() };
+            (name.as_name(), ProcMacroExpander::new(def_map.krate, ProcMacroId(idx as u32)))
         })
         .collect();
 
-- 
cgit v1.2.3