From 72e68d0caf6e813a19a8d434fb650574b73dbc0a Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 26 Mar 2020 10:49:23 +0800 Subject: Refactoring a bit --- crates/ra_proc_macro/src/lib.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'crates/ra_proc_macro/src') 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 @@ //! //! We separate proc-macro expanding logic to an extern program to allow //! different implementations (e.g. wasm or dylib loading). And this crate -//! is used for provide basic infra-structure for commnicate between two -//! process: Client (RA itself), Server (the external program) +//! is used to provide basic infrastructure for communication between two +//! processes: Client (RA itself), Server (the external program) use ra_mbe::ExpandError; use ra_tt::Subtree; @@ -18,7 +18,7 @@ trait ProcMacroExpander: std::fmt::Debug + Send + Sync + std::panic::RefUnwindSa #[derive(Debug, Clone, PartialEq, Eq)] pub struct ProcMacroProcessExpander { - process_path: PathBuf, + process: Arc, } impl ProcMacroExpander for ProcMacroProcessExpander { @@ -34,7 +34,7 @@ impl ProcMacroExpander for ProcMacroProcessExpander { #[derive(Debug, Clone)] pub struct ProcMacro { - expander: Arc>, + expander: Arc, name: String, } @@ -55,16 +55,21 @@ impl ProcMacro { } } +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProcMacroProcessSrv { + path: PathBuf, +} + #[derive(Debug, Clone, PartialEq, Eq)] pub enum ProcMacroClient { - Process { expander: Arc }, + Process { process: Arc }, Dummy, } impl ProcMacroClient { pub fn extern_process(process_path: &Path) -> ProcMacroClient { - let expander = ProcMacroProcessExpander { process_path: process_path.into() }; - ProcMacroClient::Process { expander: Arc::new(expander) } + let process = ProcMacroProcessSrv { path: process_path.into() }; + ProcMacroClient::Process { process: Arc::new(process) } } pub fn dummy() -> ProcMacroClient { -- cgit v1.2.3