Skip to content

Commit

Permalink
Implement has_adapter_logs for each transport impl
Browse files Browse the repository at this point in the history
  • Loading branch information
RemcoSmitsDev committed Oct 21, 2024
1 parent e1aff3a commit 0387182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/dap/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ impl DebugAdapterClient {
self.transport_delegate.send_message(message).await
}

pub fn has_adapter_logs(&self) -> bool {
true // TODO debugger: fix this when we move code to the transport layer
}

pub fn id(&self) -> DebugAdapterClientId {
self.id
}
Expand Down Expand Up @@ -169,6 +165,10 @@ impl DebugAdapterClient {
self.transport_delegate.shutdown().await
}

pub fn has_adapter_logs(&self) -> bool {
self.transport_delegate.has_adapter_logs()
}

pub fn add_log_handler<F>(&self, f: F, kind: LogKind)
where
F: 'static + Send + FnMut(IoKind, &str),
Expand Down
14 changes: 14 additions & 0 deletions crates/dap/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ impl TransportDelegate {
anyhow::Ok(())
}

pub fn has_adapter_logs(&self) -> bool {
self.transport.has_adapter_logs()
}

pub fn add_log_handler<F>(&self, f: F, kind: LogKind)
where
F: 'static + Send + FnMut(IoKind, &str),
Expand All @@ -336,6 +340,8 @@ pub trait Transport: 'static + Send + Sync {
binary: &DebugAdapterBinary,
cx: &mut AsyncAppContext,
) -> Result<TransportParams>;

fn has_adapter_logs(&self) -> bool;
}

pub struct TcpTransport {
Expand Down Expand Up @@ -433,6 +439,10 @@ impl Transport for TcpTransport {
process,
))
}

fn has_adapter_logs(&self) -> bool {
true
}
}

pub struct StdioTransport {}
Expand Down Expand Up @@ -492,4 +502,8 @@ impl Transport for StdioTransport {
process,
))
}

fn has_adapter_logs(&self) -> bool {
false
}
}

0 comments on commit 0387182

Please sign in to comment.