aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock14
-rw-r--r--crates/gen_lsp_server/Cargo.toml2
-rw-r--r--crates/gen_lsp_server/src/lib.rs10
-rw-r--r--crates/gen_lsp_server/src/stdio.rs10
4 files changed, 26 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8e962d352..7f3723f2e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -177,6 +177,17 @@ dependencies = [
177] 177]
178 178
179[[package]] 179[[package]]
180name = "crossbeam-channel"
181version = "0.3.6"
182source = "registry+https://github.com/rust-lang/crates.io-index"
183dependencies = [
184 "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
185 "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
186 "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
187 "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
188]
189
190[[package]]
180name = "crossbeam-deque" 191name = "crossbeam-deque"
181version = "0.2.0" 192version = "0.2.0"
182source = "registry+https://github.com/rust-lang/crates.io-index" 193source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -355,7 +366,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
355name = "gen_lsp_server" 366name = "gen_lsp_server"
356version = "0.1.0" 367version = "0.1.0"
357dependencies = [ 368dependencies = [
358 "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 369 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
359 "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 370 "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
360 "languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)", 371 "languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)",
361 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 372 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1544,6 +1555,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1544"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" 1555"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
1545"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 1556"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
1546"checksum crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827" 1557"checksum crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827"
1558"checksum crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "137bc235f622ffaa0428e3854e24acb53291fc0b3ff6fb2cb75a8be6fb02f06b"
1547"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" 1559"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
1548"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" 1560"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
1549"checksum crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8" 1561"checksum crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8"
diff --git a/crates/gen_lsp_server/Cargo.toml b/crates/gen_lsp_server/Cargo.toml
index afeeb1513..2aee4ea16 100644
--- a/crates/gen_lsp_server/Cargo.toml
+++ b/crates/gen_lsp_server/Cargo.toml
@@ -13,4 +13,4 @@ log = "0.4.3"
13failure = "0.1.2" 13failure = "0.1.2"
14serde_json = "1.0.24" 14serde_json = "1.0.24"
15serde = { version = "1.0.83", features = ["derive"] } 15serde = { version = "1.0.83", features = ["derive"] }
16crossbeam-channel = "0.2.4" 16crossbeam-channel = "0.3.5"
diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs
index 8779fbf0f..b20652928 100644
--- a/crates/gen_lsp_server/src/lib.rs
+++ b/crates/gen_lsp_server/src/lib.rs
@@ -95,7 +95,7 @@ pub fn run_server(
95 server(params, &receiver, &sender)?; 95 server(params, &receiver, &sender)?;
96 log::info!("lsp server waiting for exit notification"); 96 log::info!("lsp server waiting for exit notification");
97 match receiver.recv() { 97 match receiver.recv() {
98 Some(RawMessage::Notification(n)) => n 98 Ok(RawMessage::Notification(n)) => n
99 .cast::<Exit>() 99 .cast::<Exit>()
100 .map_err(|n| format_err!("unexpected notification during shutdown: {:?}", n))?, 100 .map_err(|n| format_err!("unexpected notification during shutdown: {:?}", n))?,
101 m => bail!("unexpected message during shutdown: {:?}", m), 101 m => bail!("unexpected message during shutdown: {:?}", m),
@@ -109,7 +109,7 @@ pub fn handle_shutdown(req: RawRequest, sender: &Sender<RawMessage>) -> Option<R
109 match req.cast::<Shutdown>() { 109 match req.cast::<Shutdown>() {
110 Ok((id, ())) => { 110 Ok((id, ())) => {
111 let resp = RawResponse::ok::<Shutdown>(id, &()); 111 let resp = RawResponse::ok::<Shutdown>(id, &());
112 sender.send(RawMessage::Response(resp)); 112 let _ = sender.send(RawMessage::Response(resp));
113 None 113 None
114 } 114 }
115 Err(req) => Some(req), 115 Err(req) => Some(req),
@@ -122,16 +122,16 @@ fn initialize(
122 caps: ServerCapabilities, 122 caps: ServerCapabilities,
123) -> Result<InitializeParams> { 123) -> Result<InitializeParams> {
124 let (id, params) = match receiver.recv() { 124 let (id, params) = match receiver.recv() {
125 Some(RawMessage::Request(req)) => match req.cast::<Initialize>() { 125 Ok(RawMessage::Request(req)) => match req.cast::<Initialize>() {
126 Err(req) => bail!("expected initialize request, got {:?}", req), 126 Err(req) => bail!("expected initialize request, got {:?}", req),
127 Ok(req) => req, 127 Ok(req) => req,
128 }, 128 },
129 msg => bail!("expected initialize request, got {:?}", msg), 129 msg => bail!("expected initialize request, got {:?}", msg),
130 }; 130 };
131 let resp = RawResponse::ok::<Initialize>(id, &InitializeResult { capabilities: caps }); 131 let resp = RawResponse::ok::<Initialize>(id, &InitializeResult { capabilities: caps });
132 sender.send(RawMessage::Response(resp)); 132 sender.send(RawMessage::Response(resp)).unwrap();
133 match receiver.recv() { 133 match receiver.recv() {
134 Some(RawMessage::Notification(n)) => { 134 Ok(RawMessage::Notification(n)) => {
135 n.cast::<Initialized>() 135 n.cast::<Initialized>()
136 .map_err(|_| format_err!("expected initialized notification"))?; 136 .map_err(|_| format_err!("expected initialized notification"))?;
137 } 137 }
diff --git a/crates/gen_lsp_server/src/stdio.rs b/crates/gen_lsp_server/src/stdio.rs
index 35d8e46d0..5c8e33854 100644
--- a/crates/gen_lsp_server/src/stdio.rs
+++ b/crates/gen_lsp_server/src/stdio.rs
@@ -9,11 +9,13 @@ use failure::bail;
9use crate::{RawMessage, Result}; 9use crate::{RawMessage, Result};
10 10
11pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads) { 11pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads) {
12 let (writer_sender, mut writer_receiver) = bounded::<RawMessage>(16); 12 let (writer_sender, writer_receiver) = bounded::<RawMessage>(16);
13 let writer = thread::spawn(move || { 13 let writer = thread::spawn(move || {
14 let stdout = stdout(); 14 let stdout = stdout();
15 let mut stdout = stdout.lock(); 15 let mut stdout = stdout.lock();
16 writer_receiver.try_for_each(|it| it.write(&mut stdout))?; 16 writer_receiver
17 .into_iter()
18 .try_for_each(|it| it.write(&mut stdout))?;
17 Ok(()) 19 Ok(())
18 }); 20 });
19 let (reader_sender, reader_receiver) = bounded::<RawMessage>(16); 21 let (reader_sender, reader_receiver) = bounded::<RawMessage>(16);
@@ -21,7 +23,9 @@ pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads)
21 let stdin = stdin(); 23 let stdin = stdin();
22 let mut stdin = stdin.lock(); 24 let mut stdin = stdin.lock();
23 while let Some(msg) = RawMessage::read(&mut stdin)? { 25 while let Some(msg) = RawMessage::read(&mut stdin)? {
24 reader_sender.send(msg); 26 if let Err(_) = reader_sender.send(msg) {
27 break;
28 }
25 } 29 }
26 Ok(()) 30 Ok(())
27 }); 31 });