debugger: Add support for inline value hints (#28656)
This PR uses Tree Sitter to show inline values while a user is in a debug session. We went with Tree Sitter over the LSP Inline Values request because the LSP request isn't widely supported. Tree Sitter is easy for languages/extensions to add support to. Tree Sitter can compute the inline values locally, so there's no need to add extra RPC messages for Collab. Tree Sitter also gives Zed more control over how we want to show variables. There's still more work to be done after this PR, namely differentiating between global/local scoped variables, but it's a great starting point to start iteratively improving it. Release Notes: - N/A --------- Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com> Co-authored-by: Anthony Eid <hello@anthonyeid.me> Co-authored-by: Cole Miller <m@cole-miller.net> Co-authored-by: Anthony <anthony@zed.dev> Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
parent
d095bab8ad
commit
218496744c
30 changed files with 709 additions and 54 deletions
|
@ -20,7 +20,9 @@ use dap::{
|
|||
client::{DebugAdapterClient, SessionId},
|
||||
messages::{Events, Message},
|
||||
};
|
||||
use dap::{ExceptionBreakpointsFilter, ExceptionFilterOptions, OutputEventCategory};
|
||||
use dap::{
|
||||
EvaluateResponse, ExceptionBreakpointsFilter, ExceptionFilterOptions, OutputEventCategory,
|
||||
};
|
||||
use futures::channel::oneshot;
|
||||
use futures::{FutureExt, future::Shared};
|
||||
use gpui::{
|
||||
|
@ -649,6 +651,7 @@ pub enum SessionEvent {
|
|||
StackTrace,
|
||||
Variables,
|
||||
Threads,
|
||||
InvalidateInlineValue,
|
||||
CapabilitiesLoaded,
|
||||
}
|
||||
|
||||
|
@ -1060,6 +1063,7 @@ impl Session {
|
|||
.map(Into::into)
|
||||
.filter(|_| !event.preserve_focus_hint.unwrap_or(false)),
|
||||
));
|
||||
cx.emit(SessionEvent::InvalidateInlineValue);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
@ -1281,6 +1285,10 @@ impl Session {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn any_stopped_thread(&self) -> bool {
|
||||
self.thread_states.any_stopped_thread()
|
||||
}
|
||||
|
||||
pub fn thread_status(&self, thread_id: ThreadId) -> ThreadStatus {
|
||||
self.thread_states.thread_status(thread_id)
|
||||
}
|
||||
|
@ -1802,6 +1810,20 @@ impl Session {
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn variables_by_stack_frame_id(&self, stack_frame_id: StackFrameId) -> Vec<dap::Variable> {
|
||||
let Some(stack_frame) = self.stack_frames.get(&stack_frame_id) else {
|
||||
return Vec::new();
|
||||
};
|
||||
|
||||
stack_frame
|
||||
.scopes
|
||||
.iter()
|
||||
.filter_map(|scope| self.variables.get(&scope.variables_reference))
|
||||
.flatten()
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn variables(
|
||||
&mut self,
|
||||
variables_reference: VariableReference,
|
||||
|
@ -1867,7 +1889,7 @@ impl Session {
|
|||
frame_id: Option<u64>,
|
||||
source: Option<Source>,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
) -> Task<Option<EvaluateResponse>> {
|
||||
self.request(
|
||||
EvaluateCommand {
|
||||
expression,
|
||||
|
@ -1896,7 +1918,6 @@ impl Session {
|
|||
},
|
||||
cx,
|
||||
)
|
||||
.detach();
|
||||
}
|
||||
|
||||
pub fn location(
|
||||
|
@ -1915,6 +1936,7 @@ impl Session {
|
|||
);
|
||||
self.locations.get(&reference).cloned()
|
||||
}
|
||||
|
||||
pub fn disconnect_client(&mut self, cx: &mut Context<Self>) {
|
||||
let command = DisconnectCommand {
|
||||
restart: Some(false),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue