diff options
Diffstat (limited to 'crates/proc_macro_api')
-rw-r--r-- | crates/proc_macro_api/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/proc_macro_api/src/lib.rs | 33 | ||||
-rw-r--r-- | crates/proc_macro_api/src/rpc.rs | 2 |
3 files changed, 19 insertions, 17 deletions
diff --git a/crates/proc_macro_api/Cargo.toml b/crates/proc_macro_api/Cargo.toml index 3863e5189..1af2bbca7 100644 --- a/crates/proc_macro_api/Cargo.toml +++ b/crates/proc_macro_api/Cargo.toml | |||
@@ -17,3 +17,4 @@ crossbeam-channel = "0.5.0" | |||
17 | jod-thread = "0.1.1" | 17 | jod-thread = "0.1.1" |
18 | 18 | ||
19 | tt = { path = "../tt", version = "0.0.0" } | 19 | tt = { path = "../tt", version = "0.0.0" } |
20 | base_db = { path = "../base_db", version = "0.0.0" } | ||
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 | ||
19 | use base_db::ProcMacro; | ||
19 | use tt::{SmolStr, Subtree}; | 20 | use tt::{SmolStr, Subtree}; |
20 | 21 | ||
21 | use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; | 22 | use 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)] |
23 | pub enum ProcMacroKind { | 23 | pub enum ProcMacroKind { |
24 | CustomDerive, | 24 | CustomDerive, |
25 | FuncLike, | 25 | FuncLike, |