1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use crate::{
parser::command::resource_location::ResourceLocation,
partition::{Position, PositionInLine},
};
use multimap::MultiMap;
use std::{fmt::Display, str::FromStr};
pub struct AdapterConfig<'l> {
pub adapter_listener_name: &'l str,
pub breakpoints: &'l MultiMap<ResourceLocation, LocalBreakpoint>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LocalBreakpoint {
pub kind: BreakpointKind,
pub position: LocalBreakpointPosition,
}
impl LocalBreakpoint {
pub(crate) fn can_resume(&self) -> bool {
self.kind.can_resume()
}
pub(crate) fn get_position(&self) -> Position {
self.position.get_position()
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum BreakpointKind {
Normal,
Invalid,
Continue,
Step { condition: String },
}
impl BreakpointKind {
pub fn can_resume(&self) -> bool {
match self {
BreakpointKind::Normal => true,
BreakpointKind::Invalid => false,
BreakpointKind::Continue { .. } => true,
BreakpointKind::Step { .. } => true,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct LocalBreakpointPosition {
pub line_number: usize,
pub position_in_line: BreakpointPositionInLine,
}
impl LocalBreakpointPosition {
fn get_position(&self) -> Position {
Position {
line_number: self.line_number,
position_in_line: self.position_in_line.into(),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum BreakpointPositionInLine {
Breakpoint,
AfterFunction,
}
impl From<BreakpointPositionInLine> for PositionInLine {
fn from(value: BreakpointPositionInLine) -> Self {
match value {
BreakpointPositionInLine::Breakpoint => PositionInLine::Breakpoint,
BreakpointPositionInLine::AfterFunction => PositionInLine::AfterFunction,
}
}
}
impl FromStr for BreakpointPositionInLine {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"breakpoint" => Ok(BreakpointPositionInLine::Breakpoint),
"after_function" => Ok(BreakpointPositionInLine::AfterFunction),
_ => Err(()),
}
}
}
impl Display for BreakpointPositionInLine {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BreakpointPositionInLine::Breakpoint => write!(f, "breakpoint"),
BreakpointPositionInLine::AfterFunction => write!(f, "after_function"),
}
}
}