|
|
@ -186,12 +186,12 @@ impl Client {
|
|
|
|
&self,
|
|
|
|
&self,
|
|
|
|
arguments: R::Arguments,
|
|
|
|
arguments: R::Arguments,
|
|
|
|
) -> Result<R::Result> {
|
|
|
|
) -> Result<R::Result> {
|
|
|
|
let (callback_rx, mut callback_tx) = channel(1);
|
|
|
|
let (callback_tx, mut callback_rx) = channel(1);
|
|
|
|
|
|
|
|
|
|
|
|
let arguments = Some(serde_json::to_value(arguments)?);
|
|
|
|
let arguments = Some(serde_json::to_value(arguments)?);
|
|
|
|
|
|
|
|
|
|
|
|
let req = Request {
|
|
|
|
let req = Request {
|
|
|
|
back_ch: Some(callback_rx),
|
|
|
|
back_ch: Some(callback_tx),
|
|
|
|
seq: self.next_request_id(),
|
|
|
|
seq: self.next_request_id(),
|
|
|
|
command: R::COMMAND.to_string(),
|
|
|
|
command: R::COMMAND.to_string(),
|
|
|
|
arguments,
|
|
|
|
arguments,
|
|
|
@ -201,7 +201,7 @@ impl Client {
|
|
|
|
.send(req)
|
|
|
|
.send(req)
|
|
|
|
.expect("Failed to send request to debugger");
|
|
|
|
.expect("Failed to send request to debugger");
|
|
|
|
|
|
|
|
|
|
|
|
let response = callback_tx.recv().await.unwrap()?;
|
|
|
|
let response = callback_rx.recv().await.unwrap()?;
|
|
|
|
let response = serde_json::from_value(response.body.unwrap_or_default())?;
|
|
|
|
let response = serde_json::from_value(response.body.unwrap_or_default())?;
|
|
|
|
Ok(response)
|
|
|
|
Ok(response)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,7 +209,7 @@ impl Client {
|
|
|
|
pub fn capabilities(&self) -> &DebuggerCapabilities {
|
|
|
|
pub fn capabilities(&self) -> &DebuggerCapabilities {
|
|
|
|
self.capabilities
|
|
|
|
self.capabilities
|
|
|
|
.as_ref()
|
|
|
|
.as_ref()
|
|
|
|
.expect("language server not yet initialized!")
|
|
|
|
.expect("debugger not yet initialized!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn initialize(&mut self, adapter_id: String) -> Result<()> {
|
|
|
|
pub async fn initialize(&mut self, adapter_id: String) -> Result<()> {
|
|
|
@ -240,21 +240,19 @@ impl Client {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn launch(&mut self, args: serde_json::Value) -> Result<()> {
|
|
|
|
pub async fn launch(&mut self, args: serde_json::Value) -> Result<()> {
|
|
|
|
let mut initialized = self.listen_for_event("initialized".to_owned()).await;
|
|
|
|
// TODO: buffer these until initialized arrives
|
|
|
|
|
|
|
|
|
|
|
|
let res = self.request::<requests::Launch>(args);
|
|
|
|
let response = self.request::<requests::Launch>(args).await?;
|
|
|
|
let ev = initialized.recv();
|
|
|
|
log::error!("launch response {}", response);
|
|
|
|
join!(res, ev).0?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn attach(&mut self, args: serde_json::Value) -> Result<()> {
|
|
|
|
pub async fn attach(&mut self, args: serde_json::Value) -> Result<()> {
|
|
|
|
let mut initialized = self.listen_for_event("initialized".to_owned()).await;
|
|
|
|
// TODO: buffer these until initialized arrives
|
|
|
|
|
|
|
|
|
|
|
|
let res = self.request::<requests::Attach>(args);
|
|
|
|
let response = self.request::<requests::Attach>(args).await?;
|
|
|
|
let ev = initialized.recv();
|
|
|
|
log::error!("attach response {}", response);
|
|
|
|
join!(res, ev).0?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|