1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
//! Client-side Proc-Macro crate
//!
//! 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 to provide basic infrastructure for communication between two
//! processes: Client (RA itself), Server (the external program)
use ra_tt::{SmolStr, Subtree};
use std::{
path::{Path, PathBuf},
sync::Arc,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProcMacroProcessExpander {
process: Arc<ProcMacroProcessSrv>,
name: SmolStr,
}
impl ra_tt::TokenExpander for ProcMacroProcessExpander {
fn expand(
&self,
_subtree: &Subtree,
_attr: Option<&Subtree>,
) -> Result<Subtree, ra_tt::ExpansionError> {
// FIXME: do nothing for now
Ok(Subtree::default())
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProcMacroProcessSrv {
path: PathBuf,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ProcMacroClient {
Process { process: Arc<ProcMacroProcessSrv> },
Dummy,
}
impl ProcMacroClient {
pub fn extern_process(process_path: &Path) -> ProcMacroClient {
let process = ProcMacroProcessSrv { path: process_path.into() };
ProcMacroClient::Process { process: Arc::new(process) }
}
pub fn dummy() -> ProcMacroClient {
ProcMacroClient::Dummy
}
pub fn by_dylib_path(
&self,
_dylib_path: &Path,
) -> Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)> {
// FIXME: return empty for now
vec![]
}
}
|