mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Remove proc-macro server command from the rust-analyzer binary
This commit is contained in:
parent
943d2a8a1c
commit
c21860bd6a
15 changed files with 109 additions and 162 deletions
|
@ -1,5 +1,6 @@
|
|||
//! A standalone binary for `proc-macro-srv`.
|
||||
//! Driver for proc macro server
|
||||
use std::io;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
|
||||
|
@ -14,5 +15,37 @@ fn main() -> std::io::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
proc_macro_srv_cli::run()
|
||||
run()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "sysroot-abi"))]
|
||||
fn run() -> io::Result<()> {
|
||||
panic!("proc-macro-srv-cli requires the `sysroot-abi` feature to be enabled");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sysroot-abi")]
|
||||
fn run() -> io::Result<()> {
|
||||
use proc_macro_api::msg::{self, Message};
|
||||
|
||||
let read_request = |buf: &mut String| msg::Request::read(&mut io::stdin().lock(), buf);
|
||||
|
||||
let write_response = |msg: msg::Response| msg.write(&mut io::stdout().lock());
|
||||
|
||||
let mut srv = proc_macro_srv::ProcMacroSrv::default();
|
||||
let mut buf = String::new();
|
||||
|
||||
while let Some(req) = read_request(&mut buf)? {
|
||||
let res = match req {
|
||||
msg::Request::ListMacros { dylib_path } => {
|
||||
msg::Response::ListMacros(srv.list_macros(&dylib_path))
|
||||
}
|
||||
msg::Request::ExpandMacro(task) => msg::Response::ExpandMacro(srv.expand(task)),
|
||||
msg::Request::ApiVersionCheck {} => {
|
||||
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
|
||||
}
|
||||
};
|
||||
write_response(res)?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue