5
5
//! is used to provide basic infrastructure for communication between two
6
6
//! processes: Client (RA itself), Server (the external program)
7
7
8
- use ra_mbe:: ExpandError ;
9
- use ra_tt:: Subtree ;
8
+ use ra_tt:: { SmolStr , Subtree } ;
10
9
use std:: {
11
10
path:: { Path , PathBuf } ,
12
11
sync:: Arc ,
13
12
} ;
14
13
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
-
19
14
#[ derive( Debug , Clone , PartialEq , Eq ) ]
20
15
pub struct ProcMacroProcessExpander {
21
16
process : Arc < ProcMacroProcessSrv > ,
17
+ name : SmolStr ,
22
18
}
23
19
24
- impl ProcMacroExpander for ProcMacroProcessExpander {
25
- fn custom_derive (
20
+ impl ra_tt :: TokenExpander for ProcMacroProcessExpander {
21
+ fn expand (
26
22
& self ,
27
23
_subtree : & Subtree ,
28
- _derive_name : & str ,
29
- ) -> Result < Subtree , ExpandError > {
24
+ _attr : Option < & Subtree > ,
25
+ ) -> Result < Subtree , ra_tt :: ExpansionError > {
30
26
// FIXME: do nothing for now
31
27
Ok ( Subtree :: default ( ) )
32
28
}
33
29
}
34
30
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
-
58
31
#[ derive( Debug , Clone , PartialEq , Eq ) ]
59
32
pub struct ProcMacroProcessSrv {
60
33
path : PathBuf ,
@@ -76,7 +49,10 @@ impl ProcMacroClient {
76
49
ProcMacroClient :: Dummy
77
50
}
78
51
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 > ) > {
80
56
// FIXME: return empty for now
81
57
vec ! [ ]
82
58
}
0 commit comments