mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
More general server config message for proc-macro-api
This commit is contained in:
parent
9e8e124269
commit
5761b50ed8
@ -33,7 +33,7 @@ pub enum Request {
|
|||||||
/// Since [`VERSION_CHECK_VERSION`]
|
/// Since [`VERSION_CHECK_VERSION`]
|
||||||
ApiVersionCheck {},
|
ApiVersionCheck {},
|
||||||
/// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
|
/// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
|
||||||
SetSpanMode(SpanMode),
|
SetConfig(ServerConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)]
|
||||||
@ -52,11 +52,17 @@ pub enum Response {
|
|||||||
/// Since [`NO_VERSION_CHECK_VERSION`]
|
/// Since [`NO_VERSION_CHECK_VERSION`]
|
||||||
ApiVersionCheck(u32),
|
ApiVersionCheck(u32),
|
||||||
/// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
|
/// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
|
||||||
SetSpanMode(SpanMode),
|
SetConfig(ServerConfig),
|
||||||
/// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
|
/// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
|
||||||
ExpandMacroExtended(Result<ExpandMacroExtended, PanicMessage>),
|
ExpandMacroExtended(Result<ExpandMacroExtended, PanicMessage>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct ServerConfig {
|
||||||
|
pub span_mode: SpanMode,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct ExpandMacroExtended {
|
pub struct ExpandMacroExtended {
|
||||||
pub tree: FlatTree,
|
pub tree: FlatTree,
|
||||||
|
@ -79,11 +79,13 @@ impl ProcMacroProcessSrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn enable_rust_analyzer_spans(&mut self) -> Result<SpanMode, ServerError> {
|
fn enable_rust_analyzer_spans(&mut self) -> Result<SpanMode, ServerError> {
|
||||||
let request = Request::SetSpanMode(crate::msg::SpanMode::RustAnalyzer);
|
let request = Request::SetConfig(crate::msg::ServerConfig {
|
||||||
|
span_mode: crate::msg::SpanMode::RustAnalyzer,
|
||||||
|
});
|
||||||
let response = self.send_task(request)?;
|
let response = self.send_task(request)?;
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
Response::SetSpanMode(span_mode) => Ok(span_mode),
|
Response::SetConfig(crate::msg::ServerConfig { span_mode }) => Ok(span_mode),
|
||||||
_ => Err(ServerError { message: "unexpected response".to_string(), io: None }),
|
_ => Err(ServerError { message: "unexpected response".to_string(), io: None }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ fn run() -> io::Result<()> {
|
|||||||
msg::Request::ApiVersionCheck {} => {
|
msg::Request::ApiVersionCheck {} => {
|
||||||
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
|
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
|
||||||
}
|
}
|
||||||
msg::Request::SetSpanMode(span_mode) => {
|
msg::Request::SetConfig(config) => {
|
||||||
srv.set_span_mode(span_mode);
|
srv.set_span_mode(config.span_mode);
|
||||||
msg::Response::SetSpanMode(span_mode)
|
msg::Response::SetConfig(config)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
write_response(res)?
|
write_response(res)?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user