Remove dead code

Agus Zubiaga , Ben Brandt , and Richard Feldman created

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>

Change summary

crates/context_server/src/client.rs   | 75 -----------------------------
crates/context_server/src/protocol.rs |  9 ---
2 files changed, 1 insertion(+), 83 deletions(-)

Detailed changes

crates/context_server/src/client.rs 🔗

@@ -51,7 +51,6 @@ pub(crate) struct Client {
     outbound_tx: channel::Sender<String>,
     name: Arc<str>,
     notification_handlers: Arc<Mutex<HashMap<&'static str, NotificationHandler>>>,
-    request_handlers: Arc<Mutex<HashMap<&'static str, RequestHandler>>>,
     response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>,
     #[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<R: crate::types::Request, F>(&self, mut f: F)
-    where
-        F: 'static + Send + FnMut(R::Params, AsyncApp) -> Task<Result<R::Response>>,
-    {
-        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 {

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<R: crate::types::Request, F>(&self, f: F)
-    where
-        F: 'static + Send + FnMut(R::Params, AsyncApp) -> Task<Result<R::Response>>,
-    {
-        self.inner.on_request::<R, F>(f);
-    }
 }