diff options
author | Aleksey Kladov <[email protected]> | 2018-08-12 19:45:03 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-12 19:45:03 +0100 |
commit | 58c3370819666b1caf23f6d06443d215be99e6d4 (patch) | |
tree | 13ace687fe99f464711d98bef580cb6b2cdc40b8 /crates/server/src/main.rs | |
parent | 8dad14b5cd63203d7ad9d86686b3c654ff353c83 (diff) |
Simplify
Diffstat (limited to 'crates/server/src/main.rs')
-rw-r--r-- | crates/server/src/main.rs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index be63fea93..345bb6ac4 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs | |||
@@ -79,21 +79,30 @@ fn initialize(io: &mut Io) -> Result<()> { | |||
79 | loop { | 79 | loop { |
80 | match io.recv()? { | 80 | match io.recv()? { |
81 | RawMsg::Request(req) => { | 81 | RawMsg::Request(req) => { |
82 | if let Some((_params, resp)) = dispatch::expect_request::<req::Initialize>(io, req)? { | 82 | let mut req = Some(req); |
83 | dispatch::handle_request::<req::Initialize, _>(&mut req, |_params, resp| { | ||
83 | let res = req::InitializeResult { capabilities: caps::SERVER_CAPABILITIES }; | 84 | let res = req::InitializeResult { capabilities: caps::SERVER_CAPABILITIES }; |
84 | let resp = resp.into_response(Ok(res))?; | 85 | let resp = resp.into_response(Ok(res))?; |
85 | io.send(RawMsg::Response(resp)); | 86 | io.send(RawMsg::Response(resp)); |
86 | match io.recv()? { | 87 | Ok(()) |
87 | RawMsg::Notification(n) => { | 88 | })?; |
88 | if n.method != "initialized" { | 89 | match req { |
90 | None => { | ||
91 | match io.recv()? { | ||
92 | RawMsg::Notification(n) => { | ||
93 | if n.method != "initialized" { | ||
94 | bail!("expected initialized notification"); | ||
95 | } | ||
96 | } | ||
97 | _ => { | ||
89 | bail!("expected initialized notification"); | 98 | bail!("expected initialized notification"); |
90 | } | 99 | } |
91 | } | 100 | } |
92 | _ => { | 101 | return initialized(io); |
93 | bail!("expected initialized notification"); | 102 | } |
94 | } | 103 | Some(req) => { |
104 | bail!("expected initialize request, got {:?}", req) | ||
95 | } | 105 | } |
96 | return initialized(io); | ||
97 | } | 106 | } |
98 | } | 107 | } |
99 | RawMsg::Notification(n) => { | 108 | RawMsg::Notification(n) => { |
@@ -106,7 +115,6 @@ fn initialize(io: &mut Io) -> Result<()> { | |||
106 | } | 115 | } |
107 | } | 116 | } |
108 | 117 | ||
109 | |||
110 | enum Task { | 118 | enum Task { |
111 | Respond(RawResponse), | 119 | Respond(RawResponse), |
112 | Notify(RawNotification), | 120 | Notify(RawNotification), |
@@ -301,7 +309,7 @@ fn update_file_notifications_on_threadpool( | |||
301 | } | 309 | } |
302 | match publish_decorations(world, uri) { | 310 | match publish_decorations(world, uri) { |
303 | Err(e) => { | 311 | Err(e) => { |
304 | error!("failed to compute decortions: {:?}", e) | 312 | error!("failed to compute decorations: {:?}", e) |
305 | } | 313 | } |
306 | Ok(params) => { | 314 | Ok(params) => { |
307 | let not = dispatch::send_notification::<req::PublishDecorations>(params); | 315 | let not = dispatch::send_notification::<req::PublishDecorations>(params); |