@@ -72,6 +72,8 @@ module DAP.Types
7272 , PathFormat (.. )
7373 -- * Command
7474 , Command (.. )
75+ -- * Reverse Command
76+ , ReverseCommand (.. )
7577 -- * Event
7678 , EventType (.. )
7779 -- ** Events
@@ -99,13 +101,14 @@ module DAP.Types
99101 , AdaptorState (.. )
100102 , AdaptorLocal (.. )
101103 , AppStore
102- , MonadIO ( .. )
104+ , MonadIO
103105 -- * Errors
104106 , AdaptorException (.. )
105107 , ErrorMessage (.. )
106108 , ErrorResponse (.. )
107109 -- * Request
108110 , Request (.. )
111+ , ReverseRequestResponse (.. )
109112 -- * Misc.
110113 , PayloadSize
111114 , Seq
@@ -121,6 +124,7 @@ module DAP.Types
121124 , LoadedSourcesResponse (.. )
122125 , ModulesResponse (.. )
123126 , ReadMemoryResponse (.. )
127+ , RunInTerminalResponse (.. )
124128 , ScopesResponse (.. )
125129 , SetExpressionResponse (.. )
126130 , SetVariableResponse (.. )
@@ -153,6 +157,8 @@ module DAP.Types
153157 , RestartArguments (.. )
154158 , RestartFrameArguments (.. )
155159 , ReverseContinueArguments (.. )
160+ , RunInTerminalRequestArguments (.. )
161+ , RunInTerminalRequestArgumentsKind (.. )
156162 , ScopesArguments (.. )
157163 , SetBreakpointsArguments (.. )
158164 , SetDataBreakpointsArguments (.. )
@@ -172,7 +178,6 @@ module DAP.Types
172178 , ThreadsArguments (.. )
173179 , VariablesArguments (.. )
174180 , WriteMemoryArguments (.. )
175- , RunInTerminalResponse (.. )
176181 -- * defaults
177182 , defaultBreakpoint
178183 , defaultBreakpointLocation
@@ -219,7 +224,7 @@ import Data.Aeson ( (.:), (.:?), withObject, with
219224 , FromJSON (parseJSON ), Value , KeyValue ((.=) )
220225 , ToJSON (toJSON ), genericParseJSON , defaultOptions
221226 )
222- import Data.Aeson.Types ( Pair , typeMismatch )
227+ import Data.Aeson.Types ( Pair , typeMismatch , Parser )
223228import Data.Proxy ( Proxy (Proxy ) )
224229import Data.String ( IsString (.. ) )
225230import Data.Time ( UTCTime )
@@ -361,11 +366,36 @@ data Request
361366----------------------------------------------------------------------------
362367instance FromJSON Request where
363368 parseJSON = withObject " Request" $ \ o -> do
369+ " request" <- (o .: " type" ) :: Parser String
364370 Request
365371 <$> o .:? " arguments"
366372 <*> o .: " seq"
367373 <*> o .: " command"
368374----------------------------------------------------------------------------
375+ data ReverseRequestResponse
376+ = ReverseRequestResponse
377+ { body :: Maybe Value
378+ -- ^ Request arguments
379+ --
380+ , reverseRequestResponseSeqNum :: Seq
381+ -- ^ Request sequence number
382+ --
383+ , reverseRequestCommand :: ReverseCommand
384+ -- ^ Command of Request
385+ --
386+ , success :: Bool
387+ -- ^ Whether the reverse request was successful
388+ } deriving stock (Show )
389+ ----------------------------------------------------------------------------
390+ instance FromJSON ReverseRequestResponse where
391+ parseJSON = withObject " ReverseRequestResponse" $ \ o -> do
392+ " response" <- (o .: " type" ) :: Parser String
393+ ReverseRequestResponse
394+ <$> o .:? " body"
395+ <*> o .: " seq"
396+ <*> o .: " command"
397+ <*> o .: " success"
398+ ----------------------------------------------------------------------------
369399data Breakpoint
370400 = Breakpoint
371401 { breakpointId :: Maybe Int
@@ -894,8 +924,6 @@ instance ToJSON EventType where
894924----------------------------------------------------------------------------
895925data Command
896926 = CommandCancel
897- | CommandRunInTerminal
898- | CommandStartDebugging
899927 | CommandInitialize
900928 | CommandConfigurationDone
901929 | CommandLaunch
@@ -954,6 +982,24 @@ instance ToJSON Command where
954982 toJSON (CustomCommand x) = toJSON x
955983 toJSON cmd = genericToJSONWithModifier cmd
956984----------------------------------------------------------------------------
985+ data ReverseCommand
986+ = ReverseCommandRunInTerminal
987+ | ReverseCommandStartDebugging
988+ deriving stock (Show , Eq , Read , Generic )
989+ ----------------------------------------------------------------------------
990+ instance FromJSON ReverseCommand where
991+ parseJSON = withText name $ \ command ->
992+ case readMaybe (name <> capitalize (T. unpack command)) of
993+ Just cmd ->
994+ pure cmd
995+ Nothing ->
996+ fail $ " Unknown reverse command: " ++ show command
997+ where
998+ name = show (typeRep (Proxy @ ReverseCommand ))
999+ ----------------------------------------------------------------------------
1000+ instance ToJSON ReverseCommand where
1001+ toJSON cmd = genericToJSONWithModifier cmd
1002+ ----------------------------------------------------------------------------
9571003data ErrorMessage
9581004 = ErrorMessageCancelled
9591005 | ErrorMessageNotStopped
@@ -1095,6 +1141,8 @@ data RunInTerminalResponse
10951141----------------------------------------------------------------------------
10961142instance ToJSON RunInTerminalResponse where
10971143 toJSON = genericToJSONWithModifier
1144+ instance FromJSON RunInTerminalResponse where
1145+ parseJSON = genericParseJSONWithModifier
10981146----------------------------------------------------------------------------
10991147data ModulesResponse
11001148 = ModulesResponse
@@ -2688,6 +2736,9 @@ data RunInTerminalRequestArgumentsKind
26882736 | RunInTerminalRequestArgumentsKindExternal
26892737 deriving stock (Show , Eq , Generic )
26902738----------------------------------------------------------------------------
2739+ instance ToJSON RunInTerminalRequestArgumentsKind where
2740+ toJSON = genericToJSONWithModifier
2741+ ----------------------------------------------------------------------------
26912742instance FromJSON RunInTerminalRequestArgumentsKind where
26922743 parseJSON = genericParseJSONWithModifier
26932744----------------------------------------------------------------------------
@@ -2728,6 +2779,9 @@ data RunInTerminalRequestArguments
27282779 --
27292780 } deriving stock (Show , Eq , Generic )
27302781----------------------------------------------------------------------------
2782+ instance ToJSON RunInTerminalRequestArguments where
2783+ toJSON = genericToJSONWithModifier
2784+ ----------------------------------------------------------------------------
27312785instance FromJSON RunInTerminalRequestArguments where
27322786 parseJSON = genericParseJSONWithModifier
27332787----------------------------------------------------------------------------
0 commit comments