From db162df264a222021dbc7f1f93af94029f3948d9 Mon Sep 17 00:00:00 2001
From: Edwin Cheng <edwin0cheng@gmail.com>
Date: Fri, 27 Mar 2020 00:41:44 +0800
Subject: Remove deps on tt_mbe

---
 crates/ra_proc_macro/src/lib.rs | 44 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 34 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 b7fb641c3..5e21dd487 100644
--- a/crates/ra_proc_macro/src/lib.rs
+++ b/crates/ra_proc_macro/src/lib.rs
@@ -5,56 +5,29 @@
 //! 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;
+use ra_tt::{SmolStr, Subtree};
 use std::{
     path::{Path, PathBuf},
     sync::Arc,
 };
 
-trait ProcMacroExpander: std::fmt::Debug + Send + Sync + std::panic::RefUnwindSafe {
-    fn custom_derive(&self, subtree: &Subtree, derive_name: &str) -> Result<Subtree, ExpandError>;
-}
-
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub struct ProcMacroProcessExpander {
     process: Arc<ProcMacroProcessSrv>,
+    name: SmolStr,
 }
 
-impl ProcMacroExpander for ProcMacroProcessExpander {
-    fn custom_derive(
+impl ra_tt::TokenExpander for ProcMacroProcessExpander {
+    fn expand(
         &self,
         _subtree: &Subtree,
-        _derive_name: &str,
-    ) -> Result<Subtree, ExpandError> {
+        _attr: Option<&Subtree>,
+    ) -> Result<Subtree, ra_tt::ExpansionError> {
         // FIXME: do nothing for now
         Ok(Subtree::default())
     }
 }
 
-#[derive(Debug, Clone)]
-pub struct ProcMacro {
-    expander: Arc<dyn ProcMacroExpander>,
-    name: String,
-}
-
-impl Eq for ProcMacro {}
-impl PartialEq for ProcMacro {
-    fn eq(&self, other: &ProcMacro) -> bool {
-        self.name == other.name && Arc::ptr_eq(&self.expander, &other.expander)
-    }
-}
-
-impl ProcMacro {
-    pub fn name(&self) -> String {
-        self.name.clone()
-    }
-
-    pub fn custom_derive(&self, subtree: &Subtree) -> Result<Subtree, ExpandError> {
-        self.expander.custom_derive(subtree, &self.name)
-    }
-}
-
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub struct ProcMacroProcessSrv {
     path: PathBuf,
@@ -76,7 +49,10 @@ impl ProcMacroClient {
         ProcMacroClient::Dummy
     }
 
-    pub fn by_dylib_path(&self, _dylib_path: &Path) -> Vec<ProcMacro> {
+    pub fn by_dylib_path(
+        &self,
+        _dylib_path: &Path,
+    ) -> Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)> {
         // FIXME: return empty for now
         vec![]
     }
-- 
cgit v1.2.3