{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE DuplicateRecordFields      #-}

module Language.LSP.Types.Command where

import           Data.Aeson
import           Data.Aeson.TH
import           Data.Text
import           Language.LSP.Types.Common
import           Language.LSP.Types.Progress
import           Language.LSP.Types.Utils

-- -------------------------------------

data ExecuteCommandClientCapabilities =
  ExecuteCommandClientCapabilities
    { ExecuteCommandClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool -- ^Execute command supports dynamic
                                         -- registration.
    } deriving (Int -> ExecuteCommandClientCapabilities -> ShowS
[ExecuteCommandClientCapabilities] -> ShowS
ExecuteCommandClientCapabilities -> String
(Int -> ExecuteCommandClientCapabilities -> ShowS)
-> (ExecuteCommandClientCapabilities -> String)
-> ([ExecuteCommandClientCapabilities] -> ShowS)
-> Show ExecuteCommandClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExecuteCommandClientCapabilities -> ShowS
showsPrec :: Int -> ExecuteCommandClientCapabilities -> ShowS
$cshow :: ExecuteCommandClientCapabilities -> String
show :: ExecuteCommandClientCapabilities -> String
$cshowList :: [ExecuteCommandClientCapabilities] -> ShowS
showList :: [ExecuteCommandClientCapabilities] -> ShowS
Show, ReadPrec [ExecuteCommandClientCapabilities]
ReadPrec ExecuteCommandClientCapabilities
Int -> ReadS ExecuteCommandClientCapabilities
ReadS [ExecuteCommandClientCapabilities]
(Int -> ReadS ExecuteCommandClientCapabilities)
-> ReadS [ExecuteCommandClientCapabilities]
-> ReadPrec ExecuteCommandClientCapabilities
-> ReadPrec [ExecuteCommandClientCapabilities]
-> Read ExecuteCommandClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ExecuteCommandClientCapabilities
readsPrec :: Int -> ReadS ExecuteCommandClientCapabilities
$creadList :: ReadS [ExecuteCommandClientCapabilities]
readList :: ReadS [ExecuteCommandClientCapabilities]
$creadPrec :: ReadPrec ExecuteCommandClientCapabilities
readPrec :: ReadPrec ExecuteCommandClientCapabilities
$creadListPrec :: ReadPrec [ExecuteCommandClientCapabilities]
readListPrec :: ReadPrec [ExecuteCommandClientCapabilities]
Read, ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
(ExecuteCommandClientCapabilities
 -> ExecuteCommandClientCapabilities -> Bool)
-> (ExecuteCommandClientCapabilities
    -> ExecuteCommandClientCapabilities -> Bool)
-> Eq ExecuteCommandClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
== :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
$c/= :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
/= :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''ExecuteCommandClientCapabilities

-- -------------------------------------

makeExtendingDatatype "ExecuteCommandOptions" [''WorkDoneProgressOptions]
  [("_commands", [t| List Text |])]
deriveJSON lspOptions ''ExecuteCommandOptions

makeExtendingDatatype "ExecuteCommandRegistrationOptions" [''ExecuteCommandOptions] []
deriveJSON lspOptions ''ExecuteCommandRegistrationOptions

-- -------------------------------------

makeExtendingDatatype "ExecuteCommandParams" [''WorkDoneProgressParams]
  [ ("_command", [t| Text |])
  , ("_arguments", [t| Maybe (List Value) |])
  ]
deriveJSON lspOptions ''ExecuteCommandParams

data Command =
  Command
    { -- | Title of the command, like @save@.
      Command -> Text
_title     :: Text
    , -- | The identifier of the actual command handler.
      Command -> Text
_command   :: Text
    , -- | Arguments that the command handler should be invoked with.
      Command -> Maybe (List Value)
_arguments :: Maybe (List Value)
    } deriving (Int -> Command -> ShowS
[Command] -> ShowS
Command -> String
(Int -> Command -> ShowS)
-> (Command -> String) -> ([Command] -> ShowS) -> Show Command
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Command -> ShowS
showsPrec :: Int -> Command -> ShowS
$cshow :: Command -> String
show :: Command -> String
$cshowList :: [Command] -> ShowS
showList :: [Command] -> ShowS
Show, ReadPrec [Command]
ReadPrec Command
Int -> ReadS Command
ReadS [Command]
(Int -> ReadS Command)
-> ReadS [Command]
-> ReadPrec Command
-> ReadPrec [Command]
-> Read Command
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Command
readsPrec :: Int -> ReadS Command
$creadList :: ReadS [Command]
readList :: ReadS [Command]
$creadPrec :: ReadPrec Command
readPrec :: ReadPrec Command
$creadListPrec :: ReadPrec [Command]
readListPrec :: ReadPrec [Command]
Read, Command -> Command -> Bool
(Command -> Command -> Bool)
-> (Command -> Command -> Bool) -> Eq Command
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Command -> Command -> Bool
== :: Command -> Command -> Bool
$c/= :: Command -> Command -> Bool
/= :: Command -> Command -> Bool
Eq)

deriveJSON lspOptions ''Command