forked from zed-industries/zed
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Remco Smits <djsmits12@gmail.com>
- Loading branch information
1 parent
448ffa0
commit d7ce1c3
Showing
4 changed files
with
80 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,78 @@ | ||
use async_trait::async_trait; | ||
use dap::{requests::Next, NextArguments}; | ||
use anyhow::Result; | ||
use dap::{client::DebugAdapterClientId, requests::Next, NextArguments}; | ||
use rpc::proto; | ||
|
||
pub trait DapCommand: 'static + Sized + Send + std::fmt::Debug { | ||
type Response: 'static + Send + std::fmt::Debug; | ||
type DapRequest: 'static + Send + dap::requests::Request; | ||
type ProtoRequest: 'static + Send + proto::RequestMessage; | ||
|
||
fn to_proto( | ||
&self, | ||
debug_client_id: &DebugAdapterClientId, | ||
upstream_project_id: u64, | ||
) -> Self::ProtoRequest; | ||
|
||
fn to_dap(&self) -> <Self::DapRequest as dap::requests::Request>::Arguments; | ||
|
||
fn response_from_dap( | ||
self, | ||
message: <Self::DapRequest as dap::requests::Request>::Response, | ||
) -> Self::Response; | ||
) -> Result<Self::Response>; | ||
|
||
fn response_from_proto( | ||
self, | ||
message: <Self::ProtoRequest as proto::RequestMessage>::Response, | ||
) -> Result<Self::Response>; | ||
} | ||
|
||
impl DapCommand for NextArguments { | ||
#[derive(Debug)] | ||
pub(crate) struct NextCommand { | ||
args: NextArguments, | ||
} | ||
|
||
impl DapCommand for NextCommand { | ||
type Response = <Next as dap::requests::Request>::Response; | ||
type DapRequest = Next; | ||
type ProtoRequest = proto::PrepareRename; | ||
type ProtoRequest = proto::DapNextRequest; | ||
|
||
fn to_proto( | ||
&self, | ||
debug_client_id: &DebugAdapterClientId, | ||
upstream_project_id: u64, | ||
) -> proto::DapNextRequest { | ||
proto::DapNextRequest { | ||
project_id: upstream_project_id, | ||
client_id: debug_client_id.to_proto(), | ||
thread_id: self.args.thread_id, | ||
single_thread: self.args.single_thread, | ||
granularity: Some(match self.args.granularity { | ||
Some(dap::SteppingGranularity::Line) => proto::SteppingGranularity::Line.into(), | ||
Some(dap::SteppingGranularity::Instruction) => { | ||
proto::SteppingGranularity::Instruction.into() | ||
} | ||
Some(dap::SteppingGranularity::Statement) | None => { | ||
proto::SteppingGranularity::Statement.into() | ||
} | ||
}), | ||
} | ||
} | ||
|
||
fn to_dap(&self) -> <Self::DapRequest as dap::requests::Request>::Arguments { | ||
todo!() | ||
self.args.clone() | ||
} | ||
|
||
fn response_from_dap( | ||
self, | ||
_message: <Self::DapRequest as dap::requests::Request>::Response, | ||
) -> Self::Response { | ||
todo!() | ||
message: <Self::DapRequest as dap::requests::Request>::Response, | ||
) -> Result<Self::Response> { | ||
todo!("") | ||
} | ||
|
||
fn response_from_proto( | ||
self, | ||
message: <Self::ProtoRequest as proto::RequestMessage>::Response, | ||
) -> Result<Self::Response> { | ||
todo!("") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters