Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8f527b2

Browse files
committed
- Added ObjectLifetime map and Var/Scope/Frame ID variables
- Added defaults for Events and Types - Moved JSON serialization logic to use Generic - Refactored and simplified Server.hs code - Removed IORefs - Added 'send' and 'sendWait' - Added ThreadState helpers - Added ExceptT - 'AdaptorClient' -> 'Adaptor' - Removed some "adaptor" prefixes in AdaptorState - Fixed some JSON serialization bugs
1 parent 6927d5d commit 8f527b2

File tree

8 files changed

+1446
-941
lines changed

8 files changed

+1446
-941
lines changed

‎dap/dap.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ library
5858
aeson
5959
, aeson-pretty
6060
, base < 5
61+
, containers
6162
, bytestring
6263
, lifted-base
6364
, mtl

‎dap/exe/Main.hs

Lines changed: 476 additions & 346 deletions
Large diffs are not rendered by default.

‎dap/src/DAP/Adaptor.hs

Lines changed: 227 additions & 109 deletions
Large diffs are not rendered by default.

‎dap/src/DAP/Event.hs

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,59 +33,109 @@ module DAP.Event
3333
, sendStoppedEvent
3434
, sendTerminatedEvent
3535
, sendThreadEvent
36+
-- * Defaults
37+
, defaultContinuedEvent
38+
, defaultExitedEvent
39+
, defaultInvalidatedEvent
40+
, defaultMemoryEvent
41+
, defaultOutputEvent
42+
, defaultProcessEvent
43+
, defaultProgressEndEvent
44+
, defaultProgressStartEvent
45+
, defaultProgressUpdateEvent
46+
, defaultStoppedEvent
47+
, defaultTerminatedEvent
48+
, defaultThreadEvent
3649
) where
3750
----------------------------------------------------------------------------
3851
import DAP.Types
3952
import DAP.Adaptor
4053
----------------------------------------------------------------------------
41-
sendBreakpointEvent :: AdaptorClient app ()
42-
sendBreakpointEvent = sendSuccesfulEvent EventTypeBreakpoint (pure())
54+
sendBreakpointEvent :: BreakpointEvent->Adaptor app ()
55+
sendBreakpointEvent = sendSuccesfulEvent EventTypeBreakpoint . setBody
4356
----------------------------------------------------------------------------
44-
sendCapabilitiesEvent :: AdaptorClient app ()
45-
sendCapabilitiesEvent = sendSuccesfulEvent EventTypeCapabilities (pure())
57+
sendCapabilitiesEvent :: CapabilitiesEvent->Adaptor app ()
58+
sendCapabilitiesEvent = sendSuccesfulEvent EventTypeCapabilities . setBody
4659
----------------------------------------------------------------------------
47-
sendContinuedEvent :: ContinuedEvent -> AdaptorClient app ()
60+
sendContinuedEvent :: ContinuedEvent -> Adaptor app ()
4861
sendContinuedEvent = sendSuccesfulEvent EventTypeContinued . setBody
4962
----------------------------------------------------------------------------
50-
sendExitedEvent :: ExitedEvent -> AdaptorClient app ()
63+
defaultContinuedEvent :: ContinuedEvent
64+
defaultContinuedEvent = ContinuedEvent 0 False
65+
----------------------------------------------------------------------------
66+
sendExitedEvent :: ExitedEvent -> Adaptor app ()
5167
sendExitedEvent = sendSuccesfulEvent EventTypeExited . setBody
5268
----------------------------------------------------------------------------
53-
sendInitializedEvent :: AdaptorClient app ()
69+
defaultExitedEvent :: ExitedEvent
70+
defaultExitedEvent = ExitedEvent 0
71+
----------------------------------------------------------------------------
72+
sendInitializedEvent :: Adaptor app ()
5473
sendInitializedEvent = sendSuccesfulEvent EventTypeInitialized (pure ())
5574
----------------------------------------------------------------------------
56-
sendInvalidatedEvent :: InvalidatedEvent -> AdaptorClient app ()
75+
sendInvalidatedEvent :: InvalidatedEvent -> Adaptor app ()
5776
sendInvalidatedEvent = sendSuccesfulEvent EventTypeInvalidated . setBody
5877
----------------------------------------------------------------------------
59-
sendLoadedSourceEvent :: LoadedSourceEvent -> AdaptorClient app ()
78+
defaultInvalidatedEvent :: InvalidatedEvent
79+
defaultInvalidatedEvent = InvalidatedEvent [] Nothing Nothing
80+
----------------------------------------------------------------------------
81+
sendLoadedSourceEvent :: LoadedSourceEvent -> Adaptor app ()
6082
sendLoadedSourceEvent = sendSuccesfulEvent EventTypeLoadedSource . setBody
6183
----------------------------------------------------------------------------
62-
sendMemoryEvent :: MemoryEvent -> AdaptorClient app ()
84+
sendMemoryEvent :: MemoryEvent -> Adaptor app ()
6385
sendMemoryEvent = sendSuccesfulEvent EventTypeMemory . setBody
6486
----------------------------------------------------------------------------
65-
sendModuleEvent :: ModuleEvent -> AdaptorClient app ()
87+
defaultMemoryEvent :: MemoryEvent
88+
defaultMemoryEvent = MemoryEvent mempty 0 0
89+
----------------------------------------------------------------------------
90+
sendModuleEvent :: ModuleEvent -> Adaptor app ()
6691
sendModuleEvent = sendSuccesfulEvent EventTypeModule . setBody
6792
----------------------------------------------------------------------------
68-
sendOutputEvent :: OutputEvent -> AdaptorClient app ()
93+
sendOutputEvent :: OutputEvent -> Adaptor app ()
6994
sendOutputEvent = sendSuccesfulEvent EventTypeOutput . setBody
7095
----------------------------------------------------------------------------
71-
sendProcessEvent :: ProcessEvent -> AdaptorClient app ()
96+
defaultOutputEvent :: OutputEvent
97+
defaultOutputEvent = OutputEvent Nothing mempty Nothing Nothing Nothing Nothing Nothing Nothing
98+
----------------------------------------------------------------------------
99+
sendProcessEvent :: ProcessEvent -> Adaptor app ()
72100
sendProcessEvent = sendSuccesfulEvent EventTypeProcess . setBody
73101
----------------------------------------------------------------------------
74-
sendProgressEndEvent :: ProgressEndEvent -> AdaptorClient app ()
102+
defaultProcessEvent :: ProcessEvent
103+
defaultProcessEvent = ProcessEvent mempty Nothing True Nothing Nothing
104+
----------------------------------------------------------------------------
105+
sendProgressEndEvent :: ProgressEndEvent -> Adaptor app ()
75106
sendProgressEndEvent = sendSuccesfulEvent EventTypeProgressEnd . setBody
76107
----------------------------------------------------------------------------
77-
sendProgressStartEvent :: ProgressStartEvent -> AdaptorClient app ()
108+
defaultProgressEndEvent :: ProgressEndEvent
109+
defaultProgressEndEvent = ProgressEndEvent mempty Nothing
110+
----------------------------------------------------------------------------
111+
sendProgressStartEvent :: ProgressStartEvent -> Adaptor app ()
78112
sendProgressStartEvent = sendSuccesfulEvent EventTypeProgressStart . setBody
79113
----------------------------------------------------------------------------
80-
sendProgressUpdateEvent :: ProgressUpdateEvent -> AdaptorClient app ()
114+
defaultProgressStartEvent :: ProgressStartEvent
115+
defaultProgressStartEvent = ProgressStartEvent mempty mempty Nothing False Nothing Nothing
116+
----------------------------------------------------------------------------
117+
sendProgressUpdateEvent :: ProgressUpdateEvent -> Adaptor app ()
81118
sendProgressUpdateEvent = sendSuccesfulEvent EventTypeProgressUpdate . setBody
82119
----------------------------------------------------------------------------
83-
sendStoppedEvent :: StoppedEvent -> AdaptorClient app ()
120+
defaultProgressUpdateEvent :: ProgressUpdateEvent
121+
defaultProgressUpdateEvent = ProgressUpdateEvent mempty Nothing Nothing
122+
----------------------------------------------------------------------------
123+
sendStoppedEvent :: StoppedEvent -> Adaptor app ()
84124
sendStoppedEvent = sendSuccesfulEvent EventTypeStopped . setBody
85125
----------------------------------------------------------------------------
86-
sendTerminatedEvent :: TerminatedEvent -> AdaptorClient app ()
126+
defaultStoppedEvent :: StoppedEvent
127+
defaultStoppedEvent = StoppedEvent StoppedEventReasonStep Nothing (Just 0) False Nothing False []
128+
----------------------------------------------------------------------------
129+
sendTerminatedEvent :: TerminatedEvent -> Adaptor app ()
87130
sendTerminatedEvent = sendSuccesfulEvent EventTypeTerminated . setBody
88131
----------------------------------------------------------------------------
89-
sendThreadEvent :: ThreadEvent -> AdaptorClient app ()
132+
defaultTerminatedEvent :: TerminatedEvent
133+
defaultTerminatedEvent = TerminatedEvent False
134+
----------------------------------------------------------------------------
135+
sendThreadEvent :: ThreadEvent -> Adaptor app ()
90136
sendThreadEvent = sendSuccesfulEvent EventTypeThread . setBody
91137
----------------------------------------------------------------------------
138+
defaultThreadEvent :: ThreadEvent
139+
defaultThreadEvent = ThreadEvent ThreadEventReasonStarted 0
140+
----------------------------------------------------------------------------
141+

‎dap/src/DAP/Response.hs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ import DAP.Adaptor
6565
import DAP.Types
6666
----------------------------------------------------------------------------
6767
-- | AttachResponse has no body by default
68-
sendAttachResponse :: AdaptorClient app ()
68+
sendAttachResponse :: Adaptor app ()
6969
sendAttachResponse = sendSuccesfulEmptyResponse
7070
----------------------------------------------------------------------------
7171
-- | BreakpointLocationResponse has no body by default
7272
sendBreakpointLocationsResponse
7373
:: [BreakpointLocation]
74-
-> AdaptorClient app ()
74+
-> Adaptor app ()
7575
sendBreakpointLocationsResponse
7676
= sendSuccesfulResponse
7777
. setBody
@@ -80,7 +80,7 @@ sendBreakpointLocationsResponse
8080
-- | 'SetDataBreakpointsResponse'
8181
sendSetDataBreakpointsResponse
8282
:: [Breakpoint]
83-
-> AdaptorClient app ()
83+
-> Adaptor app ()
8484
sendSetDataBreakpointsResponse
8585
= sendSuccesfulResponse
8686
. setBody
@@ -89,7 +89,7 @@ sendSetDataBreakpointsResponse
8989
-- | BreakpointResponse has no body by default
9090
sendSetBreakpointsResponse
9191
:: [Breakpoint]
92-
-> AdaptorClient app ()
92+
-> Adaptor app ()
9393
sendSetBreakpointsResponse
9494
= sendSuccesfulResponse
9595
. setBody
@@ -98,7 +98,7 @@ sendSetBreakpointsResponse
9898
-- | SetInstructionsBreakpointResponse has no body by default
9999
sendSetInstructionBreakpointsResponse
100100
:: [Breakpoint]
101-
-> AdaptorClient app ()
101+
-> Adaptor app ()
102102
sendSetInstructionBreakpointsResponse
103103
= sendSuccesfulResponse
104104
. setBody
@@ -107,7 +107,7 @@ sendSetInstructionBreakpointsResponse
107107
-- | SetFunctionBreakpointResponse has no body by default
108108
sendSetFunctionBreakpointsResponse
109109
:: [Breakpoint]
110-
-> AdaptorClient app ()
110+
-> Adaptor app ()
111111
sendSetFunctionBreakpointsResponse
112112
= sendSuccesfulResponse
113113
. setBody
@@ -116,7 +116,7 @@ sendSetFunctionBreakpointsResponse
116116
-- | SetExceptionBreakpointsResponse has no body by default
117117
sendSetExceptionBreakpointsResponse
118118
:: [Breakpoint]
119-
-> AdaptorClient app ()
119+
-> Adaptor app ()
120120
sendSetExceptionBreakpointsResponse
121121
= sendSuccesfulResponse
122122
. setBody
@@ -125,147 +125,147 @@ sendSetExceptionBreakpointsResponse
125125
-- | ContinueResponse
126126
sendContinueResponse
127127
:: ContinueResponse
128-
-> AdaptorClient app ()
128+
-> Adaptor app ()
129129
sendContinueResponse continueResponse = do
130130
sendSuccesfulResponse (setBody continueResponse)
131131
----------------------------------------------------------------------------
132132
-- | ConfigurationDoneResponse
133133
sendConfigurationDoneResponse
134-
:: AdaptorClient app ()
134+
:: Adaptor app ()
135135
sendConfigurationDoneResponse = do
136136
sendSuccesfulEmptyResponse
137137
----------------------------------------------------------------------------
138138
-- | LaunchResponse
139139
sendLaunchResponse
140-
:: AdaptorClient app ()
140+
:: Adaptor app ()
141141
sendLaunchResponse = sendSuccesfulEmptyResponse
142142
----------------------------------------------------------------------------
143143
-- | RestartResponse
144144
sendRestartResponse
145-
:: AdaptorClient app ()
145+
:: Adaptor app ()
146146
sendRestartResponse = sendSuccesfulEmptyResponse
147147
----------------------------------------------------------------------------
148148
-- | DisconnectResponse
149149
sendDisconnectResponse
150-
:: AdaptorClient app ()
150+
:: Adaptor app ()
151151
sendDisconnectResponse = sendSuccesfulEmptyResponse
152152
----------------------------------------------------------------------------
153153
-- | TerminateResponse
154154
sendTerminateResponse
155-
:: AdaptorClient app ()
155+
:: Adaptor app ()
156156
sendTerminateResponse = sendSuccesfulEmptyResponse
157157
----------------------------------------------------------------------------
158158
-- | NextResponse
159159
sendNextResponse
160-
:: AdaptorClient app ()
160+
:: Adaptor app ()
161161
sendNextResponse = sendSuccesfulEmptyResponse
162162
----------------------------------------------------------------------------
163163
-- | StepInResponse
164164
sendStepInResponse
165-
:: AdaptorClient app ()
165+
:: Adaptor app ()
166166
sendStepInResponse = sendSuccesfulEmptyResponse
167167
----------------------------------------------------------------------------
168168
-- | StepOutResponse
169169
sendStepOutResponse
170-
:: AdaptorClient app ()
170+
:: Adaptor app ()
171171
sendStepOutResponse = sendSuccesfulEmptyResponse
172172
----------------------------------------------------------------------------
173173
-- | StepBackResponse
174174
sendStepBackResponse
175-
:: AdaptorClient app ()
175+
:: Adaptor app ()
176176
sendStepBackResponse = sendSuccesfulEmptyResponse
177177
----------------------------------------------------------------------------
178178
-- | ReverseContinueResponse
179179
sendReverseContinueResponse
180-
:: AdaptorClient app ()
180+
:: Adaptor app ()
181181
sendReverseContinueResponse = sendSuccesfulEmptyResponse
182182
----------------------------------------------------------------------------
183183
-- | RestartFrameResponse
184184
sendRestartFrameResponse
185-
:: AdaptorClient app ()
185+
:: Adaptor app ()
186186
sendRestartFrameResponse = sendSuccesfulEmptyResponse
187187
----------------------------------------------------------------------------
188188
-- | InitializeReponse
189189
sendInitializeResponse
190-
:: AdaptorClient app ()
190+
:: Adaptor app ()
191191
sendInitializeResponse = do
192192
capabilities <- getServerCapabilities
193193
sendSuccesfulResponse (setBody capabilities)
194194
----------------------------------------------------------------------------
195195
-- | GotoResponse
196196
sendGotoResponse
197-
:: AdaptorClient app ()
197+
:: Adaptor app ()
198198
sendGotoResponse = sendSuccesfulEmptyResponse
199199
----------------------------------------------------------------------------
200200
-- | GotoTargetsResponse
201201
sendGotoTargetsResponse
202-
:: AdaptorClient app ()
202+
:: Adaptor app ()
203203
sendGotoTargetsResponse = sendSuccesfulEmptyResponse
204204
----------------------------------------------------------------------------
205205
-- | PauseResponse
206206
sendPauseResponse
207-
:: AdaptorClient app ()
207+
:: Adaptor app ()
208208
sendPauseResponse = sendSuccesfulEmptyResponse
209209
----------------------------------------------------------------------------
210210
-- | TerminateThreadsResponse
211211
sendTerminateThreadsResponse
212-
:: AdaptorClient app ()
212+
:: Adaptor app ()
213213
sendTerminateThreadsResponse = sendSuccesfulEmptyResponse
214214
----------------------------------------------------------------------------
215-
sendModulesResponse :: ModulesResponse -> AdaptorClient app ()
215+
sendModulesResponse :: ModulesResponse -> Adaptor app ()
216216
sendModulesResponse = sendSuccesfulResponse . setBody
217217
----------------------------------------------------------------------------
218-
sendStackTraceResponse :: StackTraceResponse -> AdaptorClient app ()
218+
sendStackTraceResponse :: StackTraceResponse -> Adaptor app ()
219219
sendStackTraceResponse = sendSuccesfulResponse . setBody
220220
----------------------------------------------------------------------------
221-
sendSourceResponse :: SourceResponse -> AdaptorClient app ()
221+
sendSourceResponse :: SourceResponse -> Adaptor app ()
222222
sendSourceResponse = sendSuccesfulResponse . setBody
223223
----------------------------------------------------------------------------
224-
sendThreadsResponse :: [Thread] -> AdaptorClient app ()
224+
sendThreadsResponse :: [Thread] -> Adaptor app ()
225225
sendThreadsResponse = sendSuccesfulResponse . setBody . ThreadsResponse
226226
----------------------------------------------------------------------------
227-
sendLoadedSourcesResponse :: [Source] -> AdaptorClient app ()
227+
sendLoadedSourcesResponse :: [Source] -> Adaptor app ()
228228
sendLoadedSourcesResponse = sendSuccesfulResponse . setBody . LoadedSourcesResponse
229229
----------------------------------------------------------------------------
230-
sendWriteMemoryResponse :: WriteMemoryResponse -> AdaptorClient app ()
230+
sendWriteMemoryResponse :: WriteMemoryResponse -> Adaptor app ()
231231
sendWriteMemoryResponse = sendSuccesfulResponse . setBody
232232
----------------------------------------------------------------------------
233-
sendReadMemoryResponse :: ReadMemoryResponse -> AdaptorClient app ()
233+
sendReadMemoryResponse :: ReadMemoryResponse -> Adaptor app ()
234234
sendReadMemoryResponse = sendSuccesfulResponse . setBody
235235
----------------------------------------------------------------------------
236-
sendCompletionsResponse :: CompletionsResponse -> AdaptorClient app ()
236+
sendCompletionsResponse :: CompletionsResponse -> Adaptor app ()
237237
sendCompletionsResponse = sendSuccesfulResponse . setBody
238238
----------------------------------------------------------------------------
239-
sendDataBreakpointInfoResponse :: DataBreakpointInfoResponse -> AdaptorClient app ()
239+
sendDataBreakpointInfoResponse :: DataBreakpointInfoResponse -> Adaptor app ()
240240
sendDataBreakpointInfoResponse = sendSuccesfulResponse . setBody
241241
----------------------------------------------------------------------------
242-
sendDisassembleResponse :: DisassembleResponse -> AdaptorClient app ()
242+
sendDisassembleResponse :: DisassembleResponse -> Adaptor app ()
243243
sendDisassembleResponse = sendSuccesfulResponse . setBody
244244
----------------------------------------------------------------------------
245-
sendEvaluateResponse :: EvaluateResponse -> AdaptorClient app ()
245+
sendEvaluateResponse :: EvaluateResponse -> Adaptor app ()
246246
sendEvaluateResponse = sendSuccesfulResponse . setBody
247247
----------------------------------------------------------------------------
248-
sendExceptionInfoResponse :: ExceptionInfoResponse -> AdaptorClient app ()
248+
sendExceptionInfoResponse :: ExceptionInfoResponse -> Adaptor app ()
249249
sendExceptionInfoResponse = sendSuccesfulResponse . setBody
250250
----------------------------------------------------------------------------
251-
sendScopesResponse :: ScopesResponse -> AdaptorClient app ()
251+
sendScopesResponse :: ScopesResponse -> Adaptor app ()
252252
sendScopesResponse = sendSuccesfulResponse . setBody
253253
----------------------------------------------------------------------------
254-
sendSetExpressionResponse :: SetExpressionResponse -> AdaptorClient app ()
254+
sendSetExpressionResponse :: SetExpressionResponse -> Adaptor app ()
255255
sendSetExpressionResponse = sendSuccesfulResponse . setBody
256256
----------------------------------------------------------------------------
257-
sendSetVariableResponse :: SetVariableResponse -> AdaptorClient app ()
257+
sendSetVariableResponse :: SetVariableResponse -> Adaptor app ()
258258
sendSetVariableResponse = sendSuccesfulResponse . setBody
259259
----------------------------------------------------------------------------
260-
sendStepInTargetsResponse :: StepInTargetsResponse -> AdaptorClient app ()
260+
sendStepInTargetsResponse :: StepInTargetsResponse -> Adaptor app ()
261261
sendStepInTargetsResponse = sendSuccesfulResponse . setBody
262262
----------------------------------------------------------------------------
263-
sendVariablesResponse :: VariablesResponse -> AdaptorClient app ()
263+
sendVariablesResponse :: VariablesResponse -> Adaptor app ()
264264
sendVariablesResponse = sendSuccesfulResponse . setBody
265265
----------------------------------------------------------------------------
266-
sendRunInTerminalResponse :: RunInTerminalResponse -> AdaptorClient app ()
266+
sendRunInTerminalResponse :: RunInTerminalResponse -> Adaptor app ()
267267
sendRunInTerminalResponse = sendSuccesfulResponse . setBody
268268
----------------------------------------------------------------------------
269-
sendStartDebuggingResponse :: AdaptorClient app ()
269+
sendStartDebuggingResponse :: Adaptor app ()
270270
sendStartDebuggingResponse = sendSuccesfulEmptyResponse
271271
----------------------------------------------------------------------------

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /