diff options
Diffstat (limited to 'crates/server/src')
-rw-r--r-- | crates/server/src/main.rs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 345bb6ac4..fe94e901e 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs | |||
@@ -78,6 +78,11 @@ fn main_inner() -> Result<()> { | |||
78 | fn initialize(io: &mut Io) -> Result<()> { | 78 | fn initialize(io: &mut Io) -> Result<()> { |
79 | loop { | 79 | loop { |
80 | match io.recv()? { | 80 | match io.recv()? { |
81 | RawMsg::Notification(n) => | ||
82 | bail!("expected initialize request, got {:?}", n), | ||
83 | RawMsg::Response(res) => | ||
84 | bail!("expected initialize request, got {:?}", res), | ||
85 | |||
81 | RawMsg::Request(req) => { | 86 | RawMsg::Request(req) => { |
82 | let mut req = Some(req); | 87 | let mut req = Some(req); |
83 | dispatch::handle_request::<req::Initialize, _>(&mut req, |_params, resp| { | 88 | dispatch::handle_request::<req::Initialize, _>(&mut req, |_params, resp| { |
@@ -86,33 +91,22 @@ fn initialize(io: &mut Io) -> Result<()> { | |||
86 | io.send(RawMsg::Response(resp)); | 91 | io.send(RawMsg::Response(resp)); |
87 | Ok(()) | 92 | Ok(()) |
88 | })?; | 93 | })?; |
89 | match req { | 94 | if let Some(req) = req { |
90 | None => { | 95 | bail!("expected initialize request, got {:?}", req) |
91 | match io.recv()? { | 96 | } |
92 | RawMsg::Notification(n) => { | 97 | match io.recv()? { |
93 | if n.method != "initialized" { | 98 | RawMsg::Notification(n) => { |
94 | bail!("expected initialized notification"); | 99 | if n.method != "initialized" { |
95 | } | 100 | bail!("expected initialized notification"); |
96 | } | ||
97 | _ => { | ||
98 | bail!("expected initialized notification"); | ||
99 | } | ||
100 | } | 101 | } |
101 | return initialized(io); | ||
102 | } | ||
103 | Some(req) => { | ||
104 | bail!("expected initialize request, got {:?}", req) | ||
105 | } | 102 | } |
103 | _ => bail!("expected initialized notification"), | ||
106 | } | 104 | } |
107 | } | 105 | break; |
108 | RawMsg::Notification(n) => { | ||
109 | bail!("expected initialize request, got {:?}", n) | ||
110 | } | ||
111 | RawMsg::Response(res) => { | ||
112 | bail!("expected initialize request, got {:?}", res) | ||
113 | } | 106 | } |
114 | } | 107 | } |
115 | } | 108 | } |
109 | initialized(io) | ||
116 | } | 110 | } |
117 | 111 | ||
118 | enum Task { | 112 | enum Task { |