aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-26 17:09:32 +0000
committerGitHub <[email protected]>2020-03-26 17:09:32 +0000
commitb1594f108041813c9fa32538950c15c55202cbd5 (patch)
treecef1e662a7acf2807422e7c232014c5326ac37b6 /crates/ra_hir_def/src/nameres
parent20c110e57f24aa54154942ee40921e9129fbc595 (diff)
parentdb162df264a222021dbc7f1f93af94029f3948d9 (diff)
Merge #3727
3727: Introduce ra_proc_macro r=matklad a=edwin0cheng This PR implemented: 1. Reading dylib path of proc-macro crate from cargo check , similar to how `OUTDIR` is obtained. 2. Added a new crate `ra_proc_macro` and implement the foot-work for reading result from external proc-macro expander. 3. Added a struct `ProcMacroClient` , which will be responsible to the client side communication to the External process. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 9c125f32f..8fe3f8617 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -11,7 +11,7 @@ use hir_expand::{
11 HirFileId, MacroCallId, MacroDefId, MacroDefKind, 11 HirFileId, MacroCallId, MacroDefId, MacroDefKind,
12}; 12};
13use ra_cfg::CfgOptions; 13use ra_cfg::CfgOptions;
14use ra_db::{CrateId, FileId}; 14use ra_db::{CrateId, FileId, ProcMacroId};
15use ra_syntax::ast; 15use ra_syntax::ast;
16use rustc_hash::FxHashMap; 16use rustc_hash::FxHashMap;
17use test_utils::tested_by; 17use test_utils::tested_by;
@@ -53,6 +53,16 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> Cr
53 } 53 }
54 54
55 let cfg_options = &crate_graph[def_map.krate].cfg_options; 55 let cfg_options = &crate_graph[def_map.krate].cfg_options;
56 let proc_macros = &crate_graph[def_map.krate].proc_macro;
57 let proc_macros = proc_macros
58 .iter()
59 .enumerate()
60 .map(|(idx, it)| {
61 // FIXME: a hacky way to create a Name from string.
62 let name = tt::Ident { text: it.name.clone(), id: tt::TokenId::unspecified() };
63 (name.as_name(), ProcMacroExpander::new(def_map.krate, ProcMacroId(idx as u32)))
64 })
65 .collect();
56 66
57 let mut collector = DefCollector { 67 let mut collector = DefCollector {
58 db, 68 db,
@@ -65,9 +75,7 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> Cr
65 unexpanded_attribute_macros: Vec::new(), 75 unexpanded_attribute_macros: Vec::new(),
66 mod_dirs: FxHashMap::default(), 76 mod_dirs: FxHashMap::default(),
67 cfg_options, 77 cfg_options,
68 78 proc_macros,
69 // FIXME: pass proc-macro from crate-graph
70 proc_macros: Default::default(),
71 }; 79 };
72 collector.collect(); 80 collector.collect();
73 collector.finish() 81 collector.finish()