Skip to content

Commit 841539f

Browse files
committed
Rename to DapHandlerOutput
1 parent bca5192 commit 841539f

1 file changed

Lines changed: 41 additions & 39 deletions

File tree

crates/ark/src/dap/dap_server.rs

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ impl DapOutput {
9696
/// The result of a handler method. Contains a `ResponseBody` (not a full
9797
/// `Response`) plus any events. The dispatcher wraps the body with
9898
/// `req.success()` or `req.error()` to produce a transport-ready `DapOutput`.
99-
pub(crate) struct HandlerOutput {
99+
pub(crate) struct DapHandlerOutput {
100100
pub body: ResponseBody,
101101
pub dap_events: Vec<Event>,
102102
pub console_events: Vec<DapConsoleEvent>,
103103
}
104104

105-
impl HandlerOutput {
105+
impl DapHandlerOutput {
106106
fn new(body: ResponseBody) -> Self {
107107
Self {
108108
body,
@@ -177,7 +177,7 @@ impl DapHandler {
177177
}
178178
}
179179

180-
fn handle_initialize(&self, _args: InitializeArguments) -> anyhow::Result<HandlerOutput> {
180+
fn handle_initialize(&self, _args: InitializeArguments) -> anyhow::Result<DapHandlerOutput> {
181181
let body = ResponseBody::Initialize(types::Capabilities {
182182
supports_restart_request: Some(true),
183183
supports_exception_info_request: Some(false),
@@ -213,7 +213,7 @@ impl DapHandler {
213213
supports_log_points: Some(true),
214214
..Default::default()
215215
});
216-
Ok(HandlerOutput {
216+
Ok(DapHandlerOutput {
217217
body,
218218
dap_events: vec![Event::Initialized],
219219
console_events: vec![],
@@ -238,7 +238,7 @@ impl DapHandler {
238238
fn handle_set_breakpoints(
239239
&self,
240240
args: SetBreakpointsArguments,
241-
) -> anyhow::Result<HandlerOutput> {
241+
) -> anyhow::Result<DapHandlerOutput> {
242242
let Some(path) = args.source.path.as_ref() else {
243243
return Err(anyhow::anyhow!("Missing a path to set breakpoints for"));
244244
};
@@ -250,7 +250,7 @@ impl DapHandler {
250250
Ok(uri) => uri,
251251
Err(err) => {
252252
log::warn!("Can't set breakpoints for non-file path: '{path}': {err}");
253-
return Ok(HandlerOutput::new(ResponseBody::SetBreakpoints(
253+
return Ok(DapHandlerOutput::new(ResponseBody::SetBreakpoints(
254254
SetBreakpointsResponse {
255255
breakpoints: vec![],
256256
},
@@ -280,7 +280,7 @@ impl DapHandler {
280280
})
281281
.collect();
282282

283-
return Ok(HandlerOutput::new(ResponseBody::SetBreakpoints(
283+
return Ok(DapHandlerOutput::new(ResponseBody::SetBreakpoints(
284284
SetBreakpointsResponse { breakpoints },
285285
)));
286286
},
@@ -432,15 +432,15 @@ impl DapHandler {
432432

433433
drop(state);
434434

435-
Ok(HandlerOutput::new(ResponseBody::SetBreakpoints(
435+
Ok(DapHandlerOutput::new(ResponseBody::SetBreakpoints(
436436
SetBreakpointsResponse {
437437
breakpoints: response_breakpoints,
438438
},
439439
)))
440440
}
441441

442-
fn handle_attach(&self, _args: AttachRequestArguments) -> anyhow::Result<HandlerOutput> {
443-
Ok(HandlerOutput {
442+
fn handle_attach(&self, _args: AttachRequestArguments) -> anyhow::Result<DapHandlerOutput> {
443+
Ok(DapHandlerOutput {
444444
body: ResponseBody::Attach,
445445
dap_events: vec![Event::Thread(ThreadEventBody {
446446
reason: ThreadEventReason::Started,
@@ -450,7 +450,7 @@ impl DapHandler {
450450
})
451451
}
452452

453-
fn handle_disconnect(&self, _args: DisconnectArguments) -> anyhow::Result<HandlerOutput> {
453+
fn handle_disconnect(&self, _args: DisconnectArguments) -> anyhow::Result<DapHandlerOutput> {
454454
// Only send `Q` if currently in a debugging session.
455455
let is_debugging = { self.state.lock().unwrap().is_debugging };
456456
let console_events = if is_debugging {
@@ -459,15 +459,15 @@ impl DapHandler {
459459
vec![]
460460
};
461461

462-
Ok(HandlerOutput {
462+
Ok(DapHandlerOutput {
463463
body: ResponseBody::Disconnect,
464464
dap_events: vec![],
465465
console_events,
466466
})
467467
}
468468

469-
fn handle_restart<T>(&self, _args: T) -> anyhow::Result<HandlerOutput> {
470-
Ok(HandlerOutput {
469+
fn handle_restart<T>(&self, _args: T) -> anyhow::Result<DapHandlerOutput> {
470+
Ok(DapHandlerOutput {
471471
body: ResponseBody::Restart,
472472
dap_events: vec![],
473473
console_events: vec![DapConsoleEvent::Restart],
@@ -476,34 +476,36 @@ impl DapHandler {
476476

477477
// All servers must respond to `Threads` requests, possibly with
478478
// a dummy thread as is the case here
479-
fn handle_threads(&self) -> anyhow::Result<HandlerOutput> {
480-
Ok(HandlerOutput::new(ResponseBody::Threads(ThreadsResponse {
481-
threads: vec![Thread {
482-
id: THREAD_ID,
483-
name: String::from("R console"),
484-
}],
485-
})))
479+
fn handle_threads(&self) -> anyhow::Result<DapHandlerOutput> {
480+
Ok(DapHandlerOutput::new(ResponseBody::Threads(
481+
ThreadsResponse {
482+
threads: vec![Thread {
483+
id: THREAD_ID,
484+
name: String::from("R console"),
485+
}],
486+
},
487+
)))
486488
}
487489

488490
fn handle_set_exception_breakpoints(
489491
&self,
490492
args: SetExceptionBreakpointsArguments,
491-
) -> anyhow::Result<HandlerOutput> {
493+
) -> anyhow::Result<DapHandlerOutput> {
492494
{
493495
let mut state = self.state.lock().unwrap();
494496
state.exception_breakpoint_filters = args.filters;
495497
}
496-
Ok(HandlerOutput::new(ResponseBody::SetExceptionBreakpoints(
497-
SetExceptionBreakpointsResponse {
498+
Ok(DapHandlerOutput::new(
499+
ResponseBody::SetExceptionBreakpoints(SetExceptionBreakpointsResponse {
498500
// This field is only useful for reporting problems with
499501
// individual filters. Since we always accept all filters,
500502
// `None` is fine here.
501503
breakpoints: None,
502-
},
503-
)))
504+
}),
505+
))
504506
}
505507

506-
fn handle_stacktrace(&self, args: StackTraceArguments) -> anyhow::Result<HandlerOutput> {
508+
fn handle_stacktrace(&self, args: StackTraceArguments) -> anyhow::Result<DapHandlerOutput> {
507509
let stack = {
508510
let state = self.state.lock().unwrap();
509511
let fallback_sources = &state.fallback_sources;
@@ -541,19 +543,19 @@ impl DapHandler {
541543
};
542544
let stack = stack[start..end].to_vec();
543545

544-
Ok(HandlerOutput::new(ResponseBody::StackTrace(
546+
Ok(DapHandlerOutput::new(ResponseBody::StackTrace(
545547
StackTraceResponse {
546548
stack_frames: stack,
547549
total_frames: Some(total_frames),
548550
},
549551
)))
550552
}
551553

552-
fn handle_source(&self, _args: SourceArguments) -> anyhow::Result<HandlerOutput> {
554+
fn handle_source(&self, _args: SourceArguments) -> anyhow::Result<DapHandlerOutput> {
553555
Err(anyhow::anyhow!("Unsupported `source` request"))
554556
}
555557

556-
fn handle_scopes(&self, args: ScopesArguments) -> anyhow::Result<HandlerOutput> {
558+
fn handle_scopes(&self, args: ScopesArguments) -> anyhow::Result<DapHandlerOutput> {
557559
let state = self.state.lock().unwrap();
558560
let frame_id_to_variables_reference = &state.frame_id_to_variables_reference;
559561

@@ -581,16 +583,16 @@ impl DapHandler {
581583
}];
582584

583585
drop(state);
584-
Ok(HandlerOutput::new(ResponseBody::Scopes(ScopesResponse {
585-
scopes,
586-
})))
586+
Ok(DapHandlerOutput::new(ResponseBody::Scopes(
587+
ScopesResponse { scopes },
588+
)))
587589
}
588590

589-
fn handle_variables(&self, args: VariablesArguments) -> anyhow::Result<HandlerOutput> {
591+
fn handle_variables(&self, args: VariablesArguments) -> anyhow::Result<DapHandlerOutput> {
590592
let variables_reference = args.variables_reference;
591593
let variables = self.collect_r_variables(variables_reference);
592594
let variables = self.make_variables(variables);
593-
Ok(HandlerOutput::new(ResponseBody::Variables(
595+
Ok(DapHandlerOutput::new(ResponseBody::Variables(
594596
VariablesResponse { variables },
595597
)))
596598
}
@@ -627,20 +629,20 @@ impl DapHandler {
627629
_args: A,
628630
cmd: DebugRequest,
629631
resp: ResponseBody,
630-
) -> anyhow::Result<HandlerOutput> {
631-
Ok(HandlerOutput {
632+
) -> anyhow::Result<DapHandlerOutput> {
633+
Ok(DapHandlerOutput {
632634
body: resp,
633635
dap_events: vec![],
634636
console_events: vec![DapConsoleEvent::DebugCommand(cmd)],
635637
})
636638
}
637639

638-
fn handle_pause(&self, _args: PauseArguments) -> anyhow::Result<HandlerOutput> {
640+
fn handle_pause(&self, _args: PauseArguments) -> anyhow::Result<DapHandlerOutput> {
639641
self.state.lock().unwrap().is_interrupting_for_debugger = true;
640642

641643
log::info!("DAP: Received request to pause R, sending interrupt");
642644

643-
Ok(HandlerOutput {
645+
Ok(DapHandlerOutput {
644646
body: ResponseBody::Pause,
645647
dap_events: vec![],
646648
console_events: vec![DapConsoleEvent::Interrupt],

0 commit comments

Comments
 (0)