From 777a80917db01e658139da11a20ff08256667cfe Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 8 Jan 2021 16:31:19 +0900 Subject: Address clippy lints. --- helix-lsp/src/client.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'helix-lsp/src/client.rs') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index e3f72a56..0cb09d76 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -5,7 +5,7 @@ use crate::{ type Result = core::result::Result; -use helix_core::{ChangeSet, Rope, RopeSlice, Transaction}; +use helix_core::{ChangeSet, Rope}; // use std::collections::HashMap; use std::sync::atomic::{AtomicU64, Ordering}; @@ -18,13 +18,12 @@ use smol::{ channel::{Receiver, Sender}, io::{BufReader, BufWriter}, // prelude::*, - process::{Child, ChildStderr, Command, Stdio}, + process::{Child, Command, Stdio}, Executor, }; pub struct Client { _process: Child, - stderr: BufReader, outgoing: Sender, // pub incoming: Receiver, @@ -51,11 +50,10 @@ impl Client { let reader = BufReader::new(process.stdout.take().expect("Failed to open stdout")); let stderr = BufReader::new(process.stderr.take().expect("Failed to open stderr")); - let (incoming, outgoing) = Transport::start(ex, reader, writer); + let (incoming, outgoing) = Transport::start(ex, reader, writer, stderr); let client = Client { _process: process, - stderr, outgoing, // incoming, @@ -76,17 +74,15 @@ impl Client { jsonrpc::Id::Num(id) } - fn to_params(value: Value) -> Result { + fn value_into_params(value: Value) -> jsonrpc::Params { use jsonrpc::Params; - let params = match value { + match value { Value::Null => Params::None, Value::Bool(_) | Value::Number(_) | Value::String(_) => Params::Array(vec![value]), Value::Array(vec) => Params::Array(vec), Value::Object(map) => Params::Map(map), - }; - - Ok(params) + } } /// Execute a RPC request on the language server. @@ -101,7 +97,7 @@ impl Client { jsonrpc: Some(jsonrpc::Version::V2), id: self.next_request_id(), method: R::METHOD.to_string(), - params: Self::to_params(params)?, + params: Self::value_into_params(params), }; let (tx, rx) = smol::channel::bounded::>(1); @@ -143,7 +139,7 @@ impl Client { let notification = jsonrpc::Notification { jsonrpc: Some(jsonrpc::Version::V2), method: R::METHOD.to_string(), - params: Self::to_params(params)?, + params: Self::value_into_params(params), }; self.outgoing @@ -251,7 +247,7 @@ impl Client { .await } - fn to_changes( + fn changeset_to_changes( old_text: &Rope, changeset: &ChangeSet, ) -> Vec { @@ -346,7 +342,7 @@ impl Client { text: "".to_string(), }] // TODO: probably need old_state here too? } - lsp::TextDocumentSyncKind::Incremental => Self::to_changes(old_text, changes), + lsp::TextDocumentSyncKind::Incremental => Self::changeset_to_changes(old_text, changes), lsp::TextDocumentSyncKind::None => return Ok(()), }; -- cgit v1.2.3-70-g09d2