mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Actual dummy server for the server cli
This commit is contained in:
parent
b0c4bc4972
commit
9d09bc0619
2 changed files with 29 additions and 3 deletions
|
@ -8,6 +8,8 @@ extern crate rustc_driver as _;
|
|||
|
||||
use std::io;
|
||||
|
||||
use proc_macro_api::msg::ServerConfig;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
|
||||
match v.as_deref() {
|
||||
|
@ -26,8 +28,32 @@ fn main() -> std::io::Result<()> {
|
|||
|
||||
#[cfg(not(any(feature = "sysroot-abi", rust_analyzer)))]
|
||||
fn run() -> io::Result<()> {
|
||||
eprintln!("proc-macro-srv-cli requires the `sysroot-abi` feature to be enabled");
|
||||
std::process::exit(70);
|
||||
let err = "proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function";
|
||||
eprintln!("{err}");
|
||||
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 buf = String::new();
|
||||
|
||||
while let Some(req) = read_request(&mut buf)? {
|
||||
let res = match req {
|
||||
msg::Request::ListMacros { .. } => msg::Response::ListMacros(Err(err.to_owned())),
|
||||
msg::Request::ExpandMacro(_) => {
|
||||
msg::Response::ExpandMacro(Err(msg::PanicMessage(err.to_owned())))
|
||||
}
|
||||
msg::Request::ApiVersionCheck {} => {
|
||||
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
|
||||
}
|
||||
msg::Request::SetConfig(_) => {
|
||||
msg::Response::SetConfig(ServerConfig { span_mode: msg::SpanMode::Id })
|
||||
}
|
||||
};
|
||||
write_response(res)?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "sysroot-abi", rust_analyzer))]
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//! 1.58) and future ABIs (stage1, nightly)
|
||||
|
||||
use std::{
|
||||
env, fs,
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue