55//! is used to provide basic infrastructure for communication between two
66//! processes: Client (RA itself), Server (the external program)
77
8- use ra_mbe:: ExpandError ;
9- use ra_tt:: Subtree ;
8+ use ra_tt:: { SmolStr , Subtree } ;
109use std:: {
1110 path:: { Path , PathBuf } ,
1211 sync:: Arc ,
1312} ;
1413
15- trait ProcMacroExpander : std:: fmt:: Debug + Send + Sync + std:: panic:: RefUnwindSafe {
16- fn custom_derive ( & self , subtree : & Subtree , derive_name : & str ) -> Result < Subtree , ExpandError > ;
17- }
18-
1914#[ derive( Debug , Clone , PartialEq , Eq ) ]
2015pub struct ProcMacroProcessExpander {
2116 process : Arc < ProcMacroProcessSrv > ,
17+ name : SmolStr ,
2218}
2319
24- impl ProcMacroExpander for ProcMacroProcessExpander {
25- fn custom_derive (
20+ impl ra_tt :: TokenExpander for ProcMacroProcessExpander {
21+ fn expand (
2622 & self ,
2723 _subtree : & Subtree ,
28- _derive_name : & str ,
29- ) -> Result < Subtree , ExpandError > {
24+ _attr : Option < & Subtree > ,
25+ ) -> Result < Subtree , ra_tt :: ExpansionError > {
3026 // FIXME: do nothing for now
3127 Ok ( Subtree :: default ( ) )
3228 }
3329}
3430
35- #[ derive( Debug , Clone ) ]
36- pub struct ProcMacro {
37- expander : Arc < dyn ProcMacroExpander > ,
38- name : String ,
39- }
40-
41- impl Eq for ProcMacro { }
42- impl PartialEq for ProcMacro {
43- fn eq ( & self , other : & ProcMacro ) -> bool {
44- self . name == other. name && Arc :: ptr_eq ( & self . expander , & other. expander )
45- }
46- }
47-
48- impl ProcMacro {
49- pub fn name ( & self ) -> String {
50- self . name . clone ( )
51- }
52-
53- pub fn custom_derive ( & self , subtree : & Subtree ) -> Result < Subtree , ExpandError > {
54- self . expander . custom_derive ( subtree, & self . name )
55- }
56- }
57-
5831#[ derive( Debug , Clone , PartialEq , Eq ) ]
5932pub struct ProcMacroProcessSrv {
6033 path : PathBuf ,
@@ -76,7 +49,10 @@ impl ProcMacroClient {
7649 ProcMacroClient :: Dummy
7750 }
7851
79- pub fn by_dylib_path ( & self , _dylib_path : & Path ) -> Vec < ProcMacro > {
52+ pub fn by_dylib_path (
53+ & self ,
54+ _dylib_path : & Path ,
55+ ) -> Vec < ( SmolStr , Arc < dyn ra_tt:: TokenExpander > ) > {
8056 // FIXME: return empty for now
8157 vec ! [ ]
8258 }
0 commit comments