mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Simplify
This commit is contained in:
parent
8dad14b5cd
commit
58c3370819
2 changed files with 18 additions and 23 deletions
|
@ -79,21 +79,30 @@ fn initialize(io: &mut Io) -> Result<()> {
|
|||
loop {
|
||||
match io.recv()? {
|
||||
RawMsg::Request(req) => {
|
||||
if let Some((_params, resp)) = dispatch::expect_request::<req::Initialize>(io, req)? {
|
||||
let mut req = Some(req);
|
||||
dispatch::handle_request::<req::Initialize, _>(&mut req, |_params, resp| {
|
||||
let res = req::InitializeResult { capabilities: caps::SERVER_CAPABILITIES };
|
||||
let resp = resp.into_response(Ok(res))?;
|
||||
io.send(RawMsg::Response(resp));
|
||||
match io.recv()? {
|
||||
RawMsg::Notification(n) => {
|
||||
if n.method != "initialized" {
|
||||
Ok(())
|
||||
})?;
|
||||
match req {
|
||||
None => {
|
||||
match io.recv()? {
|
||||
RawMsg::Notification(n) => {
|
||||
if n.method != "initialized" {
|
||||
bail!("expected initialized notification");
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bail!("expected initialized notification");
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bail!("expected initialized notification");
|
||||
}
|
||||
return initialized(io);
|
||||
}
|
||||
Some(req) => {
|
||||
bail!("expected initialize request, got {:?}", req)
|
||||
}
|
||||
return initialized(io);
|
||||
}
|
||||
}
|
||||
RawMsg::Notification(n) => {
|
||||
|
@ -106,7 +115,6 @@ fn initialize(io: &mut Io) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
enum Task {
|
||||
Respond(RawResponse),
|
||||
Notify(RawNotification),
|
||||
|
@ -301,7 +309,7 @@ fn update_file_notifications_on_threadpool(
|
|||
}
|
||||
match publish_decorations(world, uri) {
|
||||
Err(e) => {
|
||||
error!("failed to compute decortions: {:?}", e)
|
||||
error!("failed to compute decorations: {:?}", e)
|
||||
}
|
||||
Ok(params) => {
|
||||
let not = dispatch::send_notification::<req::PublishDecorations>(params);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue