diff options
Diffstat (limited to 'crates/ra_proc_macro_srv/src/cli.rs')
-rw-r--r-- | crates/ra_proc_macro_srv/src/cli.rs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/crates/ra_proc_macro_srv/src/cli.rs b/crates/ra_proc_macro_srv/src/cli.rs deleted file mode 100644 index 1437794c9..000000000 --- a/crates/ra_proc_macro_srv/src/cli.rs +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | //! Driver for proc macro server | ||
2 | |||
3 | use crate::ProcMacroSrv; | ||
4 | use ra_proc_macro::msg::{self, Message}; | ||
5 | use std::io; | ||
6 | |||
7 | pub fn run() -> io::Result<()> { | ||
8 | let mut srv = ProcMacroSrv::default(); | ||
9 | |||
10 | while let Some(req) = read_request()? { | ||
11 | let res = match req { | ||
12 | msg::Request::ListMacro(task) => srv.list_macros(&task).map(msg::Response::ListMacro), | ||
13 | msg::Request::ExpansionMacro(task) => { | ||
14 | srv.expand(&task).map(msg::Response::ExpansionMacro) | ||
15 | } | ||
16 | }; | ||
17 | |||
18 | let msg = res.unwrap_or_else(|err| { | ||
19 | msg::Response::Error(msg::ResponseError { | ||
20 | code: msg::ErrorCode::ExpansionError, | ||
21 | message: err, | ||
22 | }) | ||
23 | }); | ||
24 | |||
25 | if let Err(err) = write_response(msg) { | ||
26 | eprintln!("Write message error: {}", err); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | Ok(()) | ||
31 | } | ||
32 | |||
33 | fn read_request() -> io::Result<Option<msg::Request>> { | ||
34 | msg::Request::read(&mut io::stdin().lock()) | ||
35 | } | ||
36 | |||
37 | fn write_response(msg: msg::Response) -> io::Result<()> { | ||
38 | msg.write(&mut io::stdout().lock()) | ||
39 | } | ||