mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Simplify
This commit is contained in:
parent
58c3370819
commit
acd7552698
1 changed files with 17 additions and 23 deletions
|
@ -78,6 +78,11 @@ fn main_inner() -> Result<()> {
|
||||||
fn initialize(io: &mut Io) -> Result<()> {
|
fn initialize(io: &mut Io) -> Result<()> {
|
||||||
loop {
|
loop {
|
||||||
match io.recv()? {
|
match io.recv()? {
|
||||||
|
RawMsg::Notification(n) =>
|
||||||
|
bail!("expected initialize request, got {:?}", n),
|
||||||
|
RawMsg::Response(res) =>
|
||||||
|
bail!("expected initialize request, got {:?}", res),
|
||||||
|
|
||||||
RawMsg::Request(req) => {
|
RawMsg::Request(req) => {
|
||||||
let mut req = Some(req);
|
let mut req = Some(req);
|
||||||
dispatch::handle_request::<req::Initialize, _>(&mut req, |_params, resp| {
|
dispatch::handle_request::<req::Initialize, _>(&mut req, |_params, resp| {
|
||||||
|
@ -86,33 +91,22 @@ fn initialize(io: &mut Io) -> Result<()> {
|
||||||
io.send(RawMsg::Response(resp));
|
io.send(RawMsg::Response(resp));
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
match req {
|
if let Some(req) = req {
|
||||||
None => {
|
bail!("expected initialize request, got {:?}", req)
|
||||||
match io.recv()? {
|
|
||||||
RawMsg::Notification(n) => {
|
|
||||||
if n.method != "initialized" {
|
|
||||||
bail!("expected initialized notification");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
bail!("expected initialized notification");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return initialized(io);
|
|
||||||
}
|
|
||||||
Some(req) => {
|
|
||||||
bail!("expected initialize request, got {:?}", req)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
match io.recv()? {
|
||||||
RawMsg::Notification(n) => {
|
RawMsg::Notification(n) => {
|
||||||
bail!("expected initialize request, got {:?}", n)
|
if n.method != "initialized" {
|
||||||
}
|
bail!("expected initialized notification");
|
||||||
RawMsg::Response(res) => {
|
}
|
||||||
bail!("expected initialize request, got {:?}", res)
|
}
|
||||||
|
_ => bail!("expected initialized notification"),
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
initialized(io)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Task {
|
enum Task {
|
||||||
|
|
Loading…
Reference in a new issue