aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_api/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-07 16:06:14 +0000
committerJonas Schievink <[email protected]>2020-12-07 16:06:14 +0000
commitfb21a215be0968d1102aba842c0fdedcd401cb15 (patch)
treebb81f3307fc8abfbb5c217b043df6ed3099edc10 /crates/proc_macro_api/src
parente8a19e24eaa214d982fa8316a21dacb08ce50ec5 (diff)
Retain types of proc macros and allow attr. macros
Diffstat (limited to 'crates/proc_macro_api/src')
-rw-r--r--crates/proc_macro_api/src/lib.rs33
-rw-r--r--crates/proc_macro_api/src/rpc.rs2
2 files changed, 18 insertions, 17 deletions
diff --git a/crates/proc_macro_api/src/lib.rs b/crates/proc_macro_api/src/lib.rs
index 40fdbfd5a..bf1f90879 100644
--- a/crates/proc_macro_api/src/lib.rs
+++ b/crates/proc_macro_api/src/lib.rs
@@ -16,6 +16,7 @@ use std::{
16 sync::Arc, 16 sync::Arc,
17}; 17};
18 18
19use base_db::ProcMacro;
19use tt::{SmolStr, Subtree}; 20use tt::{SmolStr, Subtree};
20 21
21use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; 22use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread};
@@ -82,7 +83,7 @@ impl ProcMacroClient {
82 ProcMacroClient { kind: ProcMacroClientKind::Dummy } 83 ProcMacroClient { kind: ProcMacroClientKind::Dummy }
83 } 84 }
84 85
85 pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc<dyn tt::TokenExpander>)> { 86 pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<ProcMacro> {
86 match &self.kind { 87 match &self.kind {
87 ProcMacroClientKind::Dummy => vec![], 88 ProcMacroClientKind::Dummy => vec![],
88 ProcMacroClientKind::Process { process, .. } => { 89 ProcMacroClientKind::Process { process, .. } => {
@@ -96,21 +97,21 @@ impl ProcMacroClient {
96 97
97 macros 98 macros
98 .into_iter() 99 .into_iter()
99 .filter_map(|(name, kind)| { 100 .map(|(name, kind)| {
100 match kind { 101 let name = SmolStr::new(&name);
101 ProcMacroKind::CustomDerive | ProcMacroKind::FuncLike => { 102 let kind = match kind {
102 let name = SmolStr::new(&name); 103 ProcMacroKind::CustomDerive => base_db::ProcMacroKind::CustomDerive,
103 let expander: Arc<dyn tt::TokenExpander> = 104 ProcMacroKind::FuncLike => base_db::ProcMacroKind::FuncLike,
104 Arc::new(ProcMacroProcessExpander { 105 ProcMacroKind::Attr => base_db::ProcMacroKind::Attr,
105 process: process.clone(), 106 };
106 name: name.clone(), 107 let expander: Arc<dyn tt::TokenExpander> =
107 dylib_path: dylib_path.into(), 108 Arc::new(ProcMacroProcessExpander {
108 }); 109 process: process.clone(),
109 Some((name, expander)) 110 name: name.clone(),
110 } 111 dylib_path: dylib_path.into(),
111 // FIXME: Attribute macro are currently unsupported. 112 });
112 ProcMacroKind::Attr => None, 113
113 } 114 ProcMacro { name, kind, expander }
114 }) 115 })
115 .collect() 116 .collect()
116 } 117 }
diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs
index 203109ca4..b85f92eea 100644
--- a/crates/proc_macro_api/src/rpc.rs
+++ b/crates/proc_macro_api/src/rpc.rs
@@ -19,7 +19,7 @@ pub struct ListMacrosTask {
19 pub lib: PathBuf, 19 pub lib: PathBuf,
20} 20}
21 21
22#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] 22#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
23pub enum ProcMacroKind { 23pub enum ProcMacroKind {
24 CustomDerive, 24 CustomDerive,
25 FuncLike, 25 FuncLike,