From fb21a215be0968d1102aba842c0fdedcd401cb15 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 7 Dec 2020 17:06:14 +0100 Subject: Retain types of proc macros and allow attr. macros --- crates/proc_macro_api/src/lib.rs | 33 +++++++++++++++++---------------- crates/proc_macro_api/src/rpc.rs | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'crates/proc_macro_api/src') 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::{ sync::Arc, }; +use base_db::ProcMacro; use tt::{SmolStr, Subtree}; use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; @@ -82,7 +83,7 @@ impl ProcMacroClient { ProcMacroClient { kind: ProcMacroClientKind::Dummy } } - pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc)> { + pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec { match &self.kind { ProcMacroClientKind::Dummy => vec![], ProcMacroClientKind::Process { process, .. } => { @@ -96,21 +97,21 @@ impl ProcMacroClient { macros .into_iter() - .filter_map(|(name, kind)| { - match kind { - ProcMacroKind::CustomDerive | ProcMacroKind::FuncLike => { - let name = SmolStr::new(&name); - let expander: Arc = - Arc::new(ProcMacroProcessExpander { - process: process.clone(), - name: name.clone(), - dylib_path: dylib_path.into(), - }); - Some((name, expander)) - } - // FIXME: Attribute macro are currently unsupported. - ProcMacroKind::Attr => None, - } + .map(|(name, kind)| { + let name = SmolStr::new(&name); + let kind = match kind { + ProcMacroKind::CustomDerive => base_db::ProcMacroKind::CustomDerive, + ProcMacroKind::FuncLike => base_db::ProcMacroKind::FuncLike, + ProcMacroKind::Attr => base_db::ProcMacroKind::Attr, + }; + let expander: Arc = + Arc::new(ProcMacroProcessExpander { + process: process.clone(), + name: name.clone(), + dylib_path: dylib_path.into(), + }); + + ProcMacro { name, kind, expander } }) .collect() } 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 { pub lib: PathBuf, } -#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] pub enum ProcMacroKind { CustomDerive, FuncLike, -- cgit v1.2.3