From 715e96de6ff9a6bb1b9bea9813a015c9f89508eb Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Thu, 24 Jul 2025 13:02:43 -0300 Subject: [PATCH] Remove dead code Co-authored-by: Ben Brandt Co-authored-by: Richard Feldman --- crates/context_server/src/client.rs | 75 --------------------------- crates/context_server/src/protocol.rs | 9 +--- 2 files changed, 1 insertion(+), 83 deletions(-) diff --git a/crates/context_server/src/client.rs b/crates/context_server/src/client.rs index f9a437cb12a482e0381831c5c6e149a73eb7c65e..8c5e7da0f12773b8f1551266c3cf69abe57c58e8 100644 --- a/crates/context_server/src/client.rs +++ b/crates/context_server/src/client.rs @@ -51,7 +51,6 @@ pub(crate) struct Client { outbound_tx: channel::Sender, name: Arc, notification_handlers: Arc>>, - request_handlers: Arc>>, response_handlers: Arc>>>, #[allow(clippy::type_complexity)] #[allow(dead_code)] @@ -234,7 +233,6 @@ impl Client { server_id, notification_handlers, response_handlers, - request_handlers, name: server_name, next_id: Default::default(), outbound_tx, @@ -452,79 +450,6 @@ impl Client { .lock() .insert(method, Box::new(f)); } - - pub fn on_request(&self, mut f: F) - where - F: 'static + Send + FnMut(R::Params, AsyncApp) -> Task>, - { - let outbound_tx = self.outbound_tx.clone(); - self.request_handlers.lock().insert( - R::METHOD, - Box::new(move |id, json, cx| { - let outbound_tx = outbound_tx.clone(); - match serde_json::from_str(json.get()) { - Ok(req) => { - let task = f(req, cx.clone()); - cx.foreground_executor() - .spawn(async move { - match task.await { - Ok(res) => { - outbound_tx - .send( - serde_json::to_string(&Response { - jsonrpc: JSON_RPC_VERSION, - id, - value: CspResult::Ok(Some(res)), - }) - .unwrap(), - ) - .await - .ok(); - } - Err(e) => { - outbound_tx - .send( - serde_json::to_string(&Response { - jsonrpc: JSON_RPC_VERSION, - id, - value: CspResult::<()>::Error(Some(Error { - code: -1, // todo!() - message: format!("{e}"), - })), - }) - .unwrap(), - ) - .await - .ok(); - } - } - }) - .detach(); - } - Err(e) => { - cx.foreground_executor() - .spawn(async move { - outbound_tx - .send( - serde_json::to_string(&Response { - jsonrpc: JSON_RPC_VERSION, - id, - value: CspResult::<()>::Error(Some(Error { - code: -1, // todo!() - message: format!("{e}"), - })), - }) - .unwrap(), - ) - .await - .ok(); - }) - .detach(); - } - } - }), - ); - } } impl fmt::Display for ContextServerId { diff --git a/crates/context_server/src/protocol.rs b/crates/context_server/src/protocol.rs index edaf7d6370545f0012f8453bbc026b888a2f715e..7263f502fa44b05b6bba72eda58c7ad84b52ebf7 100644 --- a/crates/context_server/src/protocol.rs +++ b/crates/context_server/src/protocol.rs @@ -7,7 +7,7 @@ use anyhow::Result; use futures::channel::oneshot; -use gpui::{AsyncApp, Task}; +use gpui::AsyncApp; use serde_json::Value; use crate::client::Client; @@ -118,11 +118,4 @@ impl InitializedContextServerProtocol { { self.inner.on_notification(method, f); } - - pub fn on_request(&self, f: F) - where - F: 'static + Send + FnMut(R::Params, AsyncApp) -> Task>, - { - self.inner.on_request::(f); - } }