diff options
author | Edwin Cheng <[email protected]> | 2020-03-26 02:49:23 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-26 02:49:23 +0000 |
commit | 72e68d0caf6e813a19a8d434fb650574b73dbc0a (patch) | |
tree | c532d82d002bc6964c4d59e20db7b085dfba247b /crates/ra_proc_macro/src | |
parent | d0b6ed4441469acfb6bc6555d78abf12637b6cf4 (diff) |
Refactoring a bit
Diffstat (limited to 'crates/ra_proc_macro/src')
-rw-r--r-- | crates/ra_proc_macro/src/lib.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/ra_proc_macro/src/lib.rs index a7a84249f..b7fb641c3 100644 --- a/crates/ra_proc_macro/src/lib.rs +++ b/crates/ra_proc_macro/src/lib.rs | |||
@@ -2,8 +2,8 @@ | |||
2 | //! | 2 | //! |
3 | //! We separate proc-macro expanding logic to an extern program to allow | 3 | //! We separate proc-macro expanding logic to an extern program to allow |
4 | //! different implementations (e.g. wasm or dylib loading). And this crate | 4 | //! different implementations (e.g. wasm or dylib loading). And this crate |
5 | //! is used for provide basic infra-structure for commnicate between two | 5 | //! is used to provide basic infrastructure for communication between two |
6 | //! process: Client (RA itself), Server (the external program) | 6 | //! processes: Client (RA itself), Server (the external program) |
7 | 7 | ||
8 | use ra_mbe::ExpandError; | 8 | use ra_mbe::ExpandError; |
9 | use ra_tt::Subtree; | 9 | use ra_tt::Subtree; |
@@ -18,7 +18,7 @@ trait ProcMacroExpander: std::fmt::Debug + Send + Sync + std::panic::RefUnwindSa | |||
18 | 18 | ||
19 | #[derive(Debug, Clone, PartialEq, Eq)] | 19 | #[derive(Debug, Clone, PartialEq, Eq)] |
20 | pub struct ProcMacroProcessExpander { | 20 | pub struct ProcMacroProcessExpander { |
21 | process_path: PathBuf, | 21 | process: Arc<ProcMacroProcessSrv>, |
22 | } | 22 | } |
23 | 23 | ||
24 | impl ProcMacroExpander for ProcMacroProcessExpander { | 24 | impl ProcMacroExpander for ProcMacroProcessExpander { |
@@ -34,7 +34,7 @@ impl ProcMacroExpander for ProcMacroProcessExpander { | |||
34 | 34 | ||
35 | #[derive(Debug, Clone)] | 35 | #[derive(Debug, Clone)] |
36 | pub struct ProcMacro { | 36 | pub struct ProcMacro { |
37 | expander: Arc<Box<dyn ProcMacroExpander>>, | 37 | expander: Arc<dyn ProcMacroExpander>, |
38 | name: String, | 38 | name: String, |
39 | } | 39 | } |
40 | 40 | ||
@@ -56,15 +56,20 @@ impl ProcMacro { | |||
56 | } | 56 | } |
57 | 57 | ||
58 | #[derive(Debug, Clone, PartialEq, Eq)] | 58 | #[derive(Debug, Clone, PartialEq, Eq)] |
59 | pub struct ProcMacroProcessSrv { | ||
60 | path: PathBuf, | ||
61 | } | ||
62 | |||
63 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
59 | pub enum ProcMacroClient { | 64 | pub enum ProcMacroClient { |
60 | Process { expander: Arc<ProcMacroProcessExpander> }, | 65 | Process { process: Arc<ProcMacroProcessSrv> }, |
61 | Dummy, | 66 | Dummy, |
62 | } | 67 | } |
63 | 68 | ||
64 | impl ProcMacroClient { | 69 | impl ProcMacroClient { |
65 | pub fn extern_process(process_path: &Path) -> ProcMacroClient { | 70 | pub fn extern_process(process_path: &Path) -> ProcMacroClient { |
66 | let expander = ProcMacroProcessExpander { process_path: process_path.into() }; | 71 | let process = ProcMacroProcessSrv { path: process_path.into() }; |
67 | ProcMacroClient::Process { expander: Arc::new(expander) } | 72 | ProcMacroClient::Process { process: Arc::new(process) } |
68 | } | 73 | } |
69 | 74 | ||
70 | pub fn dummy() -> ProcMacroClient { | 75 | pub fn dummy() -> ProcMacroClient { |