debug-adapter-protocol 0.1.0

A Rust implementation of the Debug Adapter Protocol
Documentation
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
use crate::{
    types::{
        DataBreakpoint, ExceptionFilterOptions, ExceptionOptions, FunctionBreakpoint,
        InstructionBreakpoint, Source, SourceBreakpoint, StackFrameFormat, SteppingGranularity,
        ValueFormat,
    },
    utils::{eq_default, true_},
    ProtocolMessageContent,
};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use std::collections::HashMap;
use typed_builder::TypedBuilder;

/// A client or debug adapter initiated request.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase", tag = "command", content = "arguments")]
pub enum Request {
    /// The attach request is sent from the client to the debug adapter to attach to a debuggee that is already running.
    ///
    /// Since attaching is debugger/runtime specific, the arguments for this request are not part of this specification.
    Attach(AttachRequestArguments),

    /// The 'breakpointLocations' request returns all possible locations for source breakpoints in a given range.
    ///
    /// Clients should only call this request if the capability 'supportsBreakpointLocationsRequest' is true.
    BreakpointLocations(BreakpointLocationsRequestArguments),

    /// The 'cancel' request is used by the frontend in two situations:
    ///
    /// - to indicate that it is no longer interested in the result produced by a specific request issued earlier
    ///
    /// - to cancel a progress sequence. Clients should only call this request if the capability 'supportsCancelRequest' is true.
    ///
    /// This request has a hint characteristic: a debug adapter can only be expected to make a 'best effort' in honouring this request but there are no guarantees.
    ///
    /// The 'cancel' request may return an error if it could not cancel an operation but a frontend should refrain from presenting this error to end users.
    ///
    /// A frontend client should only call this request if the capability 'supportsCancelRequest' is true.
    ///
    /// The request that got canceled still needs to send a response back. This can either be a normal result ('success' attribute true)
    ///
    /// or an error response ('success' attribute false and the 'message' set to 'cancelled').
    ///
    /// Returning partial results from a cancelled request is possible but please note that a frontend client has no generic way for detecting that a response is partial or not.
    ///
    ///  The progress that got cancelled still needs to send a 'progressEnd' event back.
    ///
    ///  A client should not assume that progress just got cancelled after sending the 'cancel' request.
    Cancel(CancelRequestArguments),

    /// Returns a list of possible completions for a given caret position and text.
    ///
    /// Clients should only call this request if the capability 'supportsCompletionsRequest' is true.
    Completions(CompletionsRequestArguments),

    /// This optional request indicates that the client has finished initialization of the debug adapter.
    ///
    /// So it is the last request in the sequence of configuration requests (which was started by the 'initialized' event).
    ///
    /// Clients should only call this request if the capability 'supportsConfigurationDoneRequest' is true.
    ConfigurationDone,

    /// The request starts the debuggee to run again.
    Continue(ContinueRequestArguments),

    /// Obtains information on a possible data breakpoint that could be set on an expression or variable.
    ///
    /// Clients should only call this request if the capability 'supportsDataBreakpoints' is true.
    DataBreakpointInfo(DataBreakpointInfoRequestArguments),

    /// Disassembles code stored at the provided location.
    ///
    /// Clients should only call this request if the capability 'supportsDisassembleRequest' is true.
    Disassemble(DisassembleRequestArguments),

    /// The 'disconnect' request is sent from the client to the debug adapter in order to stop debugging.
    ///
    /// It asks the debug adapter to disconnect from the debuggee and to terminate the debug adapter.
    ///
    /// If the debuggee has been started with the 'launch' request, the 'disconnect' request terminates the debuggee.
    ///
    /// If the 'attach' request was used to connect to the debuggee, 'disconnect' does not terminate the debuggee.
    ///
    /// This behavior can be controlled with the 'terminateDebuggee' argument (if supported by the debug adapter).
    Disconnect(DisconnectRequestArguments),

    /// Evaluates the given expression in the context of the top most stack frame.
    ///
    /// The expression has access to any variables and arguments that are in scope.
    Evaluate(EvaluateRequestArguments),

    /// Retrieves the details of the exception that caused this event to be raised.
    ///
    /// Clients should only call this request if the capability 'supportsExceptionInfoRequest' is true.
    ExceptionInfo(ExceptionInfoRequestArguments),

    /// The request sets the location where the debuggee will continue to run.
    ///
    /// This makes it possible to skip the execution of code or to executed code again.
    ///
    /// The code between the current location and the goto target is not executed but skipped.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event with reason 'goto'.
    ///
    /// Clients should only call this request if the capability 'supportsGotoTargetsRequest' is true (because only then goto targets exist that can be passed as arguments).
    Goto(GotoRequestArguments),

    /// This request retrieves the possible goto targets for the specified source location.
    ///
    /// These targets can be used in the 'goto' request.
    ///
    /// Clients should only call this request if the capability 'supportsGotoTargetsRequest' is true.
    GotoTargets(GotoTargetsRequestArguments),

    /// The 'initialize' request is sent as the first request from the client to the debug adapter
    ///
    /// in order to configure it with client capabilities and to retrieve capabilities from the debug adapter.
    ///
    /// Until the debug adapter has responded to with an 'initialize' response, the client must not send any additional requests or events to the debug adapter.
    ///
    /// In addition the debug adapter is not allowed to send any requests or events to the client until it has responded with an 'initialize' response.
    ///
    /// The 'initialize' request may only be sent once.
    Initialize(InitializeRequestArguments),

    /// This launch request is sent from the client to the debug adapter to start the debuggee with or without debugging (if 'noDebug' is true).
    ///
    /// Since launching is debugger/runtime specific, the arguments for this request are not part of this specification.
    Launch(LaunchRequestArguments),

    /// Retrieves the set of all sources currently loaded by the debugged process.
    ///
    /// Clients should only call this request if the capability 'supportsLoadedSourcesRequest' is true.
    LoadedSources,

    /// Modules can be retrieved from the debug adapter with this request which can either return all modules or a range of modules to support paging.
    ///
    /// Clients should only call this request if the capability 'supportsModulesRequest' is true.
    Modules(ModulesRequestArguments),

    /// The request starts the debuggee to run again for one step.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed.
    Next(NextRequestArguments),

    /// The request suspends the debuggee.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event (with reason 'pause') after the thread has been paused successfully.
    Pause(PauseRequestArguments),

    /// Reads bytes from memory at the provided location.
    ///
    /// Clients should only call this request if the capability 'supportsReadMemoryRequest' is true.
    ReadMemory(ReadMemoryRequestArguments),

    /// The request restarts execution of the specified stackframe.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event (with reason 'restart') after the restart has completed.
    ///
    /// Clients should only call this request if the capability 'supportsRestartFrame' is true.
    RestartFrame(RestartFrameRequestArguments),

    // /// Restarts a debug session. Clients should only call this request if the capability 'supportsRestartRequest' is true.
    // ///
    // /// If the capability is missing or has the value false, a typical client will emulate 'restart' by terminating the debug adapter first and then launching it anew.
    // Restart(RestartRequestArguments), TODO
    /// The request starts the debuggee to run backward.
    ///
    /// Clients should only call this request if the capability 'supportsStepBack' is true.
    ReverseContinue(ReverseContinueRequestArguments),

    /// This optional request is sent from the debug adapter to the client to run a command in a terminal.
    ///
    /// This is typically used to launch the debuggee in a terminal provided by the client.
    ///
    /// This request should only be called if the client has passed the value true for the 'supportsRunInTerminalRequest' capability of the 'initialize' request.
    RunInTerminal(RunInTerminalRequestArguments),

    /// The request returns the variable scopes for a given stackframe ID.
    Scopes(ScopesRequestArguments),

    /// Sets multiple breakpoints for a single source and clears all previous breakpoints in that source.
    ///
    /// To clear all breakpoint for a source, specify an empty array.
    ///
    /// When a breakpoint is hit, a 'stopped' event (with reason 'breakpoint') is generated.
    SetBreakpoints(SetBreakpointsRequestArguments),

    /// Replaces all existing data breakpoints with new data breakpoints.
    ///
    /// To clear all data breakpoints, specify an empty array.
    ///
    /// When a data breakpoint is hit, a 'stopped' event (with reason 'data breakpoint') is generated.
    ///
    /// Clients should only call this request if the capability 'supportsDataBreakpoints' is true.
    SetDataBreakpoints(SetDataBreakpointsRequestArguments),

    /// The request configures the debuggers response to thrown exceptions.
    ///
    /// If an exception is configured to break, a 'stopped' event is fired (with reason 'exception').
    ///
    /// Clients should only call this request if the capability 'exceptionBreakpointFilters' returns one or more filters.
    SetExceptionBreakpoints(SetExceptionBreakpointsRequestArguments),

    /// Evaluates the given 'value' expression and assigns it to the 'expression' which must be a modifiable l-value.
    ///
    /// The expressions have access to any variables and arguments that are in scope of the specified frame.
    ///
    /// Clients should only call this request if the capability 'supportsSetExpression' is true.
    ///
    /// If a debug adapter implements both setExpression and setVariable, a client will only use setExpression if the variable has an evaluateName property.
    SetExpression(SetExpressionRequestArguments),

    /// Replaces all existing function breakpoints with new function breakpoints.
    ///
    /// To clear all function breakpoints, specify an empty array.
    ///
    /// When a function breakpoint is hit, a 'stopped' event (with reason 'function breakpoint') is generated.
    ///
    /// Clients should only call this request if the capability 'supportsFunctionBreakpoints' is true.
    SetFunctionBreakpoints(SetFunctionBreakpointsRequestArguments),

    /// Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a diassembly window.
    ///
    /// To clear all instruction breakpoints, specify an empty array.
    ///
    /// When an instruction breakpoint is hit, a 'stopped' event (with reason 'instruction breakpoint') is generated.
    ///
    /// Clients should only call this request if the capability 'supportsInstructionBreakpoints' is true.
    SetInstructionBreakpoints(SetInstructionBreakpointsRequestArguments),

    /// Set the variable with the given name in the variable container to a new value. Clients should only call this request if the capability 'supportsSetVariable' is true.
    ///
    /// If a debug adapter implements both setVariable and setExpression, a client will only use setExpression if the variable has an evaluateName property.
    SetVariable(SetVariableRequestArguments),

    /// The request retrieves the source code for a given source reference.
    Source(SourceRequestArguments),

    /// The request returns a stacktrace from the current execution state of a given thread.
    ///
    /// A client can request all stack frames by omitting the startFrame and levels arguments. For performance conscious clients and if the debug adapter's 'supportsDelayedStackTraceLoading' capability is true, stack frames can be retrieved in a piecemeal way with the startFrame and levels arguments. The response of the stackTrace request may contain a totalFrames property that hints at the total number of frames in the stack. If a client needs this total number upfront, it can issue a request for a single (first) frame and depending on the value of totalFrames decide how to proceed. In any case a client should be prepared to receive less frames than requested, which is an indication that the end of the stack has been reached.
    StackTrace(StackTraceRequestArguments),

    /// The request starts the debuggee to run one step backwards.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed.
    ///
    /// Clients should only call this request if the capability 'supportsStepBack' is true.
    StepBack(StepBackRequestArguments),

    /// The request starts the debuggee to step into a function/method if possible.
    ///
    /// If it cannot step into a target, 'stepIn' behaves like 'next'.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed.
    ///
    /// If there are multiple function/method calls (or other targets) on the source line,
    ///
    /// the optional argument 'targetId' can be used to control into which target the 'stepIn' should occur.
    ///
    /// The list of possible targets for a given source line can be retrieved via the 'stepInTargets' request.
    StepIn(StepInRequestArguments),

    /// This request retrieves the possible stepIn targets for the specified stack frame.
    ///
    /// These targets can be used in the 'stepIn' request.
    ///
    /// The StepInTargets may only be called if the 'supportsStepInTargetsRequest' capability exists and is true.
    ///
    /// Clients should only call this request if the capability 'supportsStepInTargetsRequest' is true.
    StepInTargets(StepInTargetsRequestArguments),

    /// The request starts the debuggee to run again for one step.
    ///
    /// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed.
    StepOut(StepOutRequestArguments),

    /// The 'terminate' request is sent from the client to the debug adapter in order to give the debuggee a chance for terminating itself.
    ///
    /// Clients should only call this request if the capability 'supportsTerminateRequest' is true.
    Terminate(TerminateRequestArguments),

    /// The request terminates the threads with the given ids.
    ///
    /// Clients should only call this request if the capability 'supportsTerminateThreadsRequest' is true.
    TerminateThreads(TerminateThreadsRequestArguments),

    /// The request retrieves a list of all threads.
    Threads,

    /// Retrieves all child variables for the given variable reference.
    ///
    /// An optional filter can be used to limit the fetched children to either named or indexed children.
    Variables(VariablesRequestArguments),
}
impl From<Request> for ProtocolMessageContent {
    fn from(request: Request) -> Self {
        Self::Request(request)
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct AttachRequestArguments {
    /// Optional data from the previous, restarted session.
    ///
    /// The data is sent as the 'restart' attribute of the 'terminated' event.
    ///
    /// The client should leave the data intact.
    #[serde(rename = "__restart", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub restart: Option<Value>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<AttachRequestArguments> for Request {
    fn from(args: AttachRequestArguments) -> Self {
        Self::Attach(args)
    }
}
impl From<AttachRequestArguments> for ProtocolMessageContent {
    fn from(args: AttachRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct BreakpointLocationsRequestArguments {
    /// The source location of the breakpoints; either 'source.path' or 'source.reference' must be specified.
    #[serde(rename = "source")]
    pub source: Source,

    /// Start line of range to search possible breakpoint locations in. If only the line is specified, the request returns all possible locations in that line.
    #[serde(rename = "line")]
    pub line: i32,

    /// Optional start column of range to search possible breakpoint locations in. If no start column is given, the first column in the start line is assumed.
    #[serde(rename = "column", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub column: Option<i32>,

    /// Optional end line of range to search possible breakpoint locations in. If no end line is given, then the end line is assumed to be the start line.
    #[serde(rename = "endLine", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub end_line: Option<i32>,

    /// Optional end column of range to search possible breakpoint locations in. If no end column is given, then it is assumed to be in the last column of the end line.
    #[serde(rename = "endColumn", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub end_column: Option<i32>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<BreakpointLocationsRequestArguments> for Request {
    fn from(args: BreakpointLocationsRequestArguments) -> Self {
        Self::BreakpointLocations(args)
    }
}
impl From<BreakpointLocationsRequestArguments> for ProtocolMessageContent {
    fn from(args: BreakpointLocationsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct CancelRequestArguments {
    /// The ID (attribute 'seq') of the request to cancel. If missing no request is cancelled.
    ///
    /// Both a 'requestId' and a 'progressId' can be specified in one request.
    #[serde(rename = "requestId", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub request_id: Option<i32>,

    /// The ID (attribute 'progressId') of the progress to cancel. If missing no progress is cancelled.
    ///
    /// Both a 'requestId' and a 'progressId' can be specified in one request.
    #[serde(rename = "progressId", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub progress_id: Option<String>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<CancelRequestArguments> for Request {
    fn from(args: CancelRequestArguments) -> Self {
        Self::Cancel(args)
    }
}
impl From<CancelRequestArguments> for ProtocolMessageContent {
    fn from(args: CancelRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct CompletionsRequestArguments {
    /// Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope.
    #[serde(rename = "frameId", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub frame_id: Option<i32>,

    /// One or more source lines. Typically this is the text a user has typed into the debug console before he asked for completion.
    #[serde(rename = "text")]
    pub text: String,

    /// The character position for which to determine the completion proposals.
    #[serde(rename = "column")]
    pub column: i32,

    /// An optional line for which to determine the completion proposals. If missing the first line of the text is assumed.
    #[serde(rename = "line", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub line: Option<i32>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<CompletionsRequestArguments> for Request {
    fn from(args: CompletionsRequestArguments) -> Self {
        Self::Completions(args)
    }
}
impl From<CompletionsRequestArguments> for ProtocolMessageContent {
    fn from(args: CompletionsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ContinueRequestArguments {
    /// Continue execution for the specified thread (if possible).
    ///
    /// If the backend cannot continue on a single thread but will continue on all threads, it should set the 'allThreadsContinued' attribute in the response to true.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<ContinueRequestArguments> for Request {
    fn from(args: ContinueRequestArguments) -> Self {
        Self::Continue(args)
    }
}
impl From<ContinueRequestArguments> for ProtocolMessageContent {
    fn from(args: ContinueRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct DataBreakpointInfoRequestArguments {
    /// Reference to the Variable container if the data breakpoint is requested for a child of the container.
    #[serde(rename = "variablesReference", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub variables_reference: Option<i32>,

    /// The name of the Variable's child to obtain data breakpoint information for.
    ///
    /// If variablesReference isn’t provided, this can be an expression.
    #[serde(rename = "name")]
    pub name: String,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<DataBreakpointInfoRequestArguments> for Request {
    fn from(args: DataBreakpointInfoRequestArguments) -> Self {
        Self::DataBreakpointInfo(args)
    }
}
impl From<DataBreakpointInfoRequestArguments> for ProtocolMessageContent {
    fn from(args: DataBreakpointInfoRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct DisassembleRequestArguments {
    /// Memory reference to the base location containing the instructions to disassemble.
    #[serde(rename = "memoryReference")]
    pub memory_reference: String,

    /// Optional offset (in bytes) to be applied to the reference location before disassembling. Can be negative.
    #[serde(rename = "offset", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub offset: i32,

    /// Optional offset (in instructions) to be applied after the byte offset (if any) before disassembling. Can be negative.
    #[serde(
        rename = "instructionOffset",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub instruction_offset: i32,

    /// Number of instructions to disassemble starting at the specified location and offset.
    ///
    /// An adapter must return exactly this number of instructions - any unavailable instructions should be replaced with an implementation-defined 'invalid instruction' value.
    #[serde(rename = "instructionCount")]
    pub instruction_count: i32,

    /// If true, the adapter should attempt to resolve memory addresses and other values to symbolic names.
    #[serde(rename = "resolveSymbols", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub resolve_symbols: bool,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<DisassembleRequestArguments> for Request {
    fn from(args: DisassembleRequestArguments) -> Self {
        Self::Disassemble(args)
    }
}
impl From<DisassembleRequestArguments> for ProtocolMessageContent {
    fn from(args: DisassembleRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct DisconnectRequestArguments {
    /// A value of true indicates that this 'disconnect' request is part of a restart sequence.
    #[serde(rename = "restart", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub restart: bool,

    /// Indicates whether the debuggee should be terminated when the debugger is disconnected.
    ///
    /// If unspecified, the debug adapter is free to do whatever it thinks is best.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportTerminateDebuggee' is true.
    #[serde(rename = "terminateDebuggee", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub terminate_debuggee: Option<bool>,

    /// Indicates whether the debuggee should stay suspended when the debugger is disconnected.
    ///
    /// If unspecified, the debuggee should resume execution.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportSuspendDebuggee' is true.
    #[serde(
        rename = "suspendDebuggee",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub suspend_debuggee: bool,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<DisconnectRequestArguments> for Request {
    fn from(args: DisconnectRequestArguments) -> Self {
        Self::Disconnect(args)
    }
}
impl From<DisconnectRequestArguments> for ProtocolMessageContent {
    fn from(args: DisconnectRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct EvaluateRequestArguments {
    /// The expression to evaluate.
    #[serde(rename = "expression")]
    pub expression: String,

    /// Evaluate the expression in the scope of this stack frame. If not specified, the expression is evaluated in the global scope.
    #[serde(rename = "frameId", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub frame_id: Option<i32>,

    /// The context in which the evaluate request is run.
    #[serde(rename = "context", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub context: Option<EvaluateRequestContext>,

    /// Specifies details on how to format the Evaluate result.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportsValueFormattingOptions' is true.
    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub format: Option<ValueFormat>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<EvaluateRequestArguments> for Request {
    fn from(args: EvaluateRequestArguments) -> Self {
        Self::Evaluate(args)
    }
}
impl From<EvaluateRequestArguments> for ProtocolMessageContent {
    fn from(args: EvaluateRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum EvaluateRequestContext {
    /// evaluate is run in a watch.
    Watch,

    /// evaluate is run from REPL console.
    REPL,

    /// evaluate is run from a data hover.
    Hover,

    /// evaluate is run to generate the value that will be stored in the clipboard.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportsClipboardContext' is true.
    Clipboard,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ExceptionInfoRequestArguments {
    /// Thread for which exception information should be retrieved.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<ExceptionInfoRequestArguments> for Request {
    fn from(args: ExceptionInfoRequestArguments) -> Self {
        Self::ExceptionInfo(args)
    }
}
impl From<ExceptionInfoRequestArguments> for ProtocolMessageContent {
    fn from(args: ExceptionInfoRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct GotoRequestArguments {
    /// Set the goto target for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    /// The location where the debuggee will continue to run.
    #[serde(rename = "targetId")]
    pub target_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<GotoRequestArguments> for Request {
    fn from(args: GotoRequestArguments) -> Self {
        Self::Goto(args)
    }
}
impl From<GotoRequestArguments> for ProtocolMessageContent {
    fn from(args: GotoRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct GotoTargetsRequestArguments {
    /// The source location for which the goto targets are determined.
    #[serde(rename = "source")]
    pub source: Source,

    /// The line location for which the goto targets are determined.
    #[serde(rename = "line")]
    pub line: i32,

    /// An optional column location for which the goto targets are determined.
    #[serde(rename = "column", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub column: Option<i32>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<GotoTargetsRequestArguments> for Request {
    fn from(args: GotoTargetsRequestArguments) -> Self {
        Self::GotoTargets(args)
    }
}
impl From<GotoTargetsRequestArguments> for ProtocolMessageContent {
    fn from(args: GotoTargetsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct InitializeRequestArguments {
    /// The ID of the (frontend) client using this adapter.
    #[serde(rename = "clientID", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub client_id: Option<String>,

    /// The human readable name of the (frontend) client using this adapter.
    #[serde(rename = "clientName", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub client_name: Option<String>,

    /// The ID of the debug adapter.
    #[serde(rename = "adapterID")]
    pub adapter_id: String,

    /// The ISO-639 locale of the (frontend) client using this adapter, e.g. en-US or de-CH.
    #[serde(rename = "locale", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub locale: Option<String>,

    /// If true all line numbers are 1-based (default).
    #[serde(rename = "linesStartAt1", default = "true_")]
    #[builder(default = true)]
    pub lines_start_at_1: bool,

    /// If true all column numbers are 1-based (default).
    #[serde(rename = "columnsStartAt1", default = "true_")]
    #[builder(default = true)]
    pub columns_start_at_1: bool,

    /// Determines in what format paths are specified. The default is 'path', which is the native format.
    #[serde(rename = "pathFormat", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub path_format: PathFormat,

    /// Client supports the optional type attribute for variables.
    #[serde(
        rename = "supportsVariableType",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub supports_variable_type: bool,

    /// Client supports the paging of variables.
    #[serde(
        rename = "supportsVariablePaging",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub supports_variable_paging: bool,

    /// Client supports the runInTerminal request.
    #[serde(
        rename = "supportsRunInTerminalRequest",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub supports_run_in_terminal_request: bool,

    /// Client supports memory references.
    #[serde(
        rename = "supportsMemoryReferences",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub supports_memory_references: bool,

    /// Client supports progress reporting.
    #[serde(
        rename = "supportsProgressReporting",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub supports_progress_reporting: bool,

    /// Client supports the invalidated event.
    #[serde(
        rename = "supportsInvalidatedEvent",
        default,
        skip_serializing_if = "eq_default"
    )]
    #[builder(default)]
    pub supports_invalidated_event: bool,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<InitializeRequestArguments> for Request {
    fn from(args: InitializeRequestArguments) -> Self {
        Self::Initialize(args)
    }
}
impl From<InitializeRequestArguments> for ProtocolMessageContent {
    fn from(args: InitializeRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum PathFormat {
    Path,
    URI,
}

impl Default for PathFormat {
    fn default() -> Self {
        PathFormat::Path
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct LaunchRequestArguments {
    /// If noDebug is true the launch request should launch the program without enabling debugging.
    #[serde(rename = "noDebug", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub no_debug: bool,

    /// Optional data from the previous, restarted session.
    ///
    /// The data is sent as the 'restart' attribute of the 'terminated' event.
    ///
    /// The client should leave the data intact.
    #[serde(rename = "__restart", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub restart: Option<Value>,

    /// Additional attributes are implementation specific.
    #[serde(flatten)]
    #[builder(default)]
    pub additional_attributes: Map<String, Value>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<LaunchRequestArguments> for Request {
    fn from(args: LaunchRequestArguments) -> Self {
        Self::Launch(args)
    }
}
impl From<LaunchRequestArguments> for ProtocolMessageContent {
    fn from(args: LaunchRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ModulesRequestArguments {
    /// The index of the first module to return; if omitted modules start at 0.
    #[serde(rename = "startModule", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub start_module: i32,

    /// The number of modules to return. If moduleCount is not specified or 0, all modules are returned.
    #[serde(rename = "moduleCount", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub module_count: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<ModulesRequestArguments> for Request {
    fn from(args: ModulesRequestArguments) -> Self {
        Self::Modules(args)
    }
}
impl From<ModulesRequestArguments> for ProtocolMessageContent {
    fn from(args: ModulesRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct NextRequestArguments {
    /// Execute 'next' for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    /// Optional granularity to step. If no granularity is specified, a granularity of 'statement' is assumed.
    #[serde(rename = "granularity", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub granularity: SteppingGranularity,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<NextRequestArguments> for Request {
    fn from(args: NextRequestArguments) -> Self {
        Self::Next(args)
    }
}
impl From<NextRequestArguments> for ProtocolMessageContent {
    fn from(args: NextRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct PauseRequestArguments {
    /// Pause execution for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<PauseRequestArguments> for Request {
    fn from(args: PauseRequestArguments) -> Self {
        Self::Pause(args)
    }
}
impl From<PauseRequestArguments> for ProtocolMessageContent {
    fn from(args: PauseRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ReadMemoryRequestArguments {
    /// Memory reference to the base location from which data should be read.
    #[serde(rename = "memoryReference")]
    pub memory_reference: String,

    /// Optional offset (in bytes) to be applied to the reference location before reading data. Can be negative.
    #[serde(rename = "offset", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub offset: i32,

    /// Number of bytes to read at the specified location and offset.
    #[serde(rename = "count")]
    pub count: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<ReadMemoryRequestArguments> for Request {
    fn from(args: ReadMemoryRequestArguments) -> Self {
        Self::ReadMemory(args)
    }
}
impl From<ReadMemoryRequestArguments> for ProtocolMessageContent {
    fn from(args: ReadMemoryRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct RestartFrameRequestArguments {
    /// Restart this stackframe.
    #[serde(rename = "frameId")]
    pub frame_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<RestartFrameRequestArguments> for Request {
    fn from(args: RestartFrameRequestArguments) -> Self {
        Self::RestartFrame(args)
    }
}
impl From<RestartFrameRequestArguments> for ProtocolMessageContent {
    fn from(args: RestartFrameRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

// #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
// pub struct RestartRequestArguments {
//   /// The latest version of the 'launch' or 'attach' configuration.
//   #[serde(rename="arguments", skip_serializing_if = "Option::is_none")]
//   pub arguments: Option<TODO oneOf>,
// }

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ReverseContinueRequestArguments {
    /// Execute 'reverseContinue' for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<ReverseContinueRequestArguments> for Request {
    fn from(args: ReverseContinueRequestArguments) -> Self {
        Self::ReverseContinue(args)
    }
}
impl From<ReverseContinueRequestArguments> for ProtocolMessageContent {
    fn from(args: ReverseContinueRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct RunInTerminalRequestArguments {
    /// What kind of terminal to launch.
    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub kind: Option<TerminalKind>,

    /// Optional title of the terminal.
    #[serde(rename = "title", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub title: Option<String>,

    /// Working directory for the command. For non-empty, valid paths this typically results in execution of a change directory command.
    #[serde(rename = "cwd")]
    pub cwd: String,

    /// List of arguments. The first argument is the command to run.
    #[serde(rename = "args")]
    pub args: Vec<String>,

    /// Environment key-value pairs that are added to or removed from the default environment.
    #[serde(rename = "env", default, skip_serializing_if = "HashMap::is_empty")]
    #[builder(default)]
    pub env: HashMap<String, Option<String>>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<RunInTerminalRequestArguments> for Request {
    fn from(args: RunInTerminalRequestArguments) -> Self {
        Self::RunInTerminal(args)
    }
}
impl From<RunInTerminalRequestArguments> for ProtocolMessageContent {
    fn from(args: RunInTerminalRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum TerminalKind {
    Integrated,

    External,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ScopesRequestArguments {
    /// Retrieve the scopes for this stackframe.
    #[serde(rename = "frameId")]
    pub frame_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<ScopesRequestArguments> for Request {
    fn from(args: ScopesRequestArguments) -> Self {
        Self::Scopes(args)
    }
}
impl From<ScopesRequestArguments> for ProtocolMessageContent {
    fn from(args: ScopesRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetBreakpointsRequestArguments {
    /// The source location of the breakpoints; either 'source.path' or 'source.reference' must be specified.
    #[serde(rename = "source")]
    pub source: Source,

    /// The code locations of the breakpoints.
    #[serde(rename = "breakpoints", default, skip_serializing_if = "Vec::is_empty")]
    #[builder(default)]
    pub breakpoints: Vec<SourceBreakpoint>,

    /// Deprecated: The code locations of the breakpoints.
    #[serde(rename = "lines", default, skip_serializing_if = "Vec::is_empty")]
    #[builder(default)]
    pub lines: Vec<i32>,

    /// A value of true indicates that the underlying source has been modified which results in new breakpoint locations.
    #[serde(rename = "sourceModified", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub source_modified: bool,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetBreakpointsRequestArguments> for Request {
    fn from(args: SetBreakpointsRequestArguments) -> Self {
        Self::SetBreakpoints(args)
    }
}
impl From<SetBreakpointsRequestArguments> for ProtocolMessageContent {
    fn from(args: SetBreakpointsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetDataBreakpointsRequestArguments {
    /// The contents of this array replaces all existing data breakpoints. An empty array clears all data breakpoints.
    #[serde(rename = "breakpoints")]
    pub breakpoints: Vec<DataBreakpoint>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetDataBreakpointsRequestArguments> for Request {
    fn from(args: SetDataBreakpointsRequestArguments) -> Self {
        Self::SetDataBreakpoints(args)
    }
}
impl From<SetDataBreakpointsRequestArguments> for ProtocolMessageContent {
    fn from(args: SetDataBreakpointsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetExceptionBreakpointsRequestArguments {
    /// Set of exception filters specified by their ID. The set of all possible exception filters is defined by the 'exceptionBreakpointFilters' capability. The 'filter' and 'filterOptions' sets are additive.
    #[serde(rename = "filters")]
    pub filters: Vec<String>,

    /// Set of exception filters and their options. The set of all possible exception filters is defined by the 'exceptionBreakpointFilters' capability. This attribute is only honored by a debug adapter if the capability 'supportsExceptionFilterOptions' is true. The 'filter' and 'filterOptions' sets are additive.
    #[serde(
        rename = "filterOptions",
        default,
        skip_serializing_if = "Vec::is_empty"
    )]
    #[builder(default)]
    pub filter_options: Vec<ExceptionFilterOptions>,

    /// Configuration options for selected exceptions.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportsExceptionOptions' is true.
    #[serde(
        rename = "exceptionOptions",
        default,
        skip_serializing_if = "Vec::is_empty"
    )]
    #[builder(default)]
    pub exception_options: Vec<ExceptionOptions>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetExceptionBreakpointsRequestArguments> for Request {
    fn from(args: SetExceptionBreakpointsRequestArguments) -> Self {
        Self::SetExceptionBreakpoints(args)
    }
}
impl From<SetExceptionBreakpointsRequestArguments> for ProtocolMessageContent {
    fn from(args: SetExceptionBreakpointsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetExpressionRequestArguments {
    /// The l-value expression to assign to.
    #[serde(rename = "expression")]
    pub expression: String,

    /// The value expression to assign to the l-value expression.
    #[serde(rename = "value")]
    pub value: String,

    /// Evaluate the expressions in the scope of this stack frame. If not specified, the expressions are evaluated in the global scope.
    #[serde(rename = "frameId", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub frame_id: Option<i32>,

    /// Specifies how the resulting value should be formatted.
    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub format: Option<ValueFormat>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetExpressionRequestArguments> for Request {
    fn from(args: SetExpressionRequestArguments) -> Self {
        Self::SetExpression(args)
    }
}
impl From<SetExpressionRequestArguments> for ProtocolMessageContent {
    fn from(args: SetExpressionRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetFunctionBreakpointsRequestArguments {
    /// The function names of the breakpoints.
    #[serde(rename = "breakpoints")]
    pub breakpoints: Vec<FunctionBreakpoint>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetFunctionBreakpointsRequestArguments> for Request {
    fn from(args: SetFunctionBreakpointsRequestArguments) -> Self {
        Self::SetFunctionBreakpoints(args)
    }
}
impl From<SetFunctionBreakpointsRequestArguments> for ProtocolMessageContent {
    fn from(args: SetFunctionBreakpointsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetInstructionBreakpointsRequestArguments {
    /// The instruction references of the breakpoints
    #[serde(rename = "breakpoints")]
    pub breakpoints: Vec<InstructionBreakpoint>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetInstructionBreakpointsRequestArguments> for Request {
    fn from(args: SetInstructionBreakpointsRequestArguments) -> Self {
        Self::SetInstructionBreakpoints(args)
    }
}
impl From<SetInstructionBreakpointsRequestArguments> for ProtocolMessageContent {
    fn from(args: SetInstructionBreakpointsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SetVariableRequestArguments {
    /// The reference of the variable container.
    #[serde(rename = "variablesReference")]
    pub variables_reference: i32,

    /// The name of the variable in the container.
    #[serde(rename = "name")]
    pub name: String,

    /// The value of the variable.
    #[serde(rename = "value")]
    pub value: String,

    /// Specifies details on how to format the response value.
    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub format: Option<ValueFormat>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SetVariableRequestArguments> for Request {
    fn from(args: SetVariableRequestArguments) -> Self {
        Self::SetVariable(args)
    }
}
impl From<SetVariableRequestArguments> for ProtocolMessageContent {
    fn from(args: SetVariableRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct SourceRequestArguments {
    /// Specifies the source content to load. Either source.path or source.sourceReference must be specified.
    #[serde(rename = "source", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub source: Option<Source>,

    /// The reference to the source. This is the same as source.sourceReference.
    ///
    /// This is provided for backward compatibility since old backends do not understand the 'source' attribute.
    #[serde(rename = "sourceReference")]
    pub source_reference: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<SourceRequestArguments> for Request {
    fn from(args: SourceRequestArguments) -> Self {
        Self::Source(args)
    }
}
impl From<SourceRequestArguments> for ProtocolMessageContent {
    fn from(args: SourceRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct StackTraceRequestArguments {
    /// Retrieve the stacktrace for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    /// The index of the first frame to return; if omitted frames start at 0.
    #[serde(rename = "startFrame", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub start_frame: i32,

    /// The maximum number of frames to return. If levels is not specified or 0, all frames are returned.
    #[serde(rename = "levels", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub levels: i32,

    /// Specifies details on how to format the stack frames.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportsValueFormattingOptions' is true.
    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub format: Option<StackFrameFormat>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<StackTraceRequestArguments> for Request {
    fn from(args: StackTraceRequestArguments) -> Self {
        Self::StackTrace(args)
    }
}
impl From<StackTraceRequestArguments> for ProtocolMessageContent {
    fn from(args: StackTraceRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct StepBackRequestArguments {
    /// Execute 'stepBack' for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    /// Optional granularity to step. If no granularity is specified, a granularity of 'statement' is assumed.
    #[serde(rename = "granularity", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub granularity: SteppingGranularity,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<StepBackRequestArguments> for Request {
    fn from(args: StepBackRequestArguments) -> Self {
        Self::StepBack(args)
    }
}
impl From<StepBackRequestArguments> for ProtocolMessageContent {
    fn from(args: StepBackRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct StepInRequestArguments {
    /// Execute 'stepIn' for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    /// Optional id of the target to step into.
    #[serde(rename = "targetId", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub target_id: Option<i32>,

    /// Optional granularity to step. If no granularity is specified, a granularity of 'statement' is assumed.
    #[serde(rename = "granularity", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub granularity: SteppingGranularity,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<StepInRequestArguments> for Request {
    fn from(args: StepInRequestArguments) -> Self {
        Self::StepIn(args)
    }
}
impl From<StepInRequestArguments> for ProtocolMessageContent {
    fn from(args: StepInRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct StepInTargetsRequestArguments {
    /// The stack frame for which to retrieve the possible stepIn targets.
    #[serde(rename = "frameId")]
    pub frame_id: i32,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<StepInTargetsRequestArguments> for Request {
    fn from(args: StepInTargetsRequestArguments) -> Self {
        Self::StepInTargets(args)
    }
}
impl From<StepInTargetsRequestArguments> for ProtocolMessageContent {
    fn from(args: StepInTargetsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct StepOutRequestArguments {
    /// Execute 'stepOut' for this thread.
    #[serde(rename = "threadId")]
    pub thread_id: i32,

    /// Optional granularity to step. If no granularity is specified, a granularity of 'statement' is assumed.
    #[serde(rename = "granularity", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub granularity: SteppingGranularity,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<StepOutRequestArguments> for Request {
    fn from(args: StepOutRequestArguments) -> Self {
        Self::StepOut(args)
    }
}
impl From<StepOutRequestArguments> for ProtocolMessageContent {
    fn from(args: StepOutRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct TerminateRequestArguments {
    /// A value of true indicates that this 'terminate' request is part of a restart sequence.
    #[serde(rename = "restart", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub restart: bool,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<TerminateRequestArguments> for Request {
    fn from(args: TerminateRequestArguments) -> Self {
        Self::Terminate(args)
    }
}
impl From<TerminateRequestArguments> for ProtocolMessageContent {
    fn from(args: TerminateRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct TerminateThreadsRequestArguments {
    /// Ids of threads to be terminated.
    #[serde(rename = "threadIds", default, skip_serializing_if = "Vec::is_empty")]
    #[builder(default)]
    pub thread_ids: Vec<i32>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<TerminateThreadsRequestArguments> for Request {
    fn from(args: TerminateThreadsRequestArguments) -> Self {
        Self::TerminateThreads(args)
    }
}
impl From<TerminateThreadsRequestArguments> for ProtocolMessageContent {
    fn from(args: TerminateThreadsRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct VariablesRequestArguments {
    /// The Variable reference.
    #[serde(rename = "variablesReference")]
    pub variables_reference: i32,

    /// Optional filter to limit the child variables to either named or indexed. If omitted, both types are fetched.
    #[serde(rename = "filter", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub filter: Option<VariablesFilter>,

    /// The index of the first variable to return; if omitted children start at 0.
    #[serde(rename = "start", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub start: i32,

    /// The number of variables to return. If count is missing or 0, all variables are returned.
    #[serde(rename = "count", default, skip_serializing_if = "eq_default")]
    #[builder(default)]
    pub count: i32,

    /// Specifies details on how to format the Variable values.
    ///
    /// The attribute is only honored by a debug adapter if the capability 'supportsValueFormattingOptions' is true.
    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
    #[builder(default)]
    pub format: Option<ValueFormat>,

    #[serde(skip)]
    #[builder(default, setter(skip))]
    private: (),
}
impl From<VariablesRequestArguments> for Request {
    fn from(args: VariablesRequestArguments) -> Self {
        Self::Variables(args)
    }
}
impl From<VariablesRequestArguments> for ProtocolMessageContent {
    fn from(args: VariablesRequestArguments) -> Self {
        Self::from(Request::from(args))
    }
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum VariablesFilter {
    Indexed,

    Named,
}