{-# 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
showList :: [ExecuteCommandClientCapabilities] -> ShowS
$cshowList :: [ExecuteCommandClientCapabilities] -> ShowS
show :: ExecuteCommandClientCapabilities -> String
$cshow :: ExecuteCommandClientCapabilities -> String
showsPrec :: Int -> ExecuteCommandClientCapabilities -> ShowS
$cshowsPrec :: Int -> 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
readListPrec :: ReadPrec [ExecuteCommandClientCapabilities]
$creadListPrec :: ReadPrec [ExecuteCommandClientCapabilities]
readPrec :: ReadPrec ExecuteCommandClientCapabilities
$creadPrec :: ReadPrec ExecuteCommandClientCapabilities
readList :: ReadS [ExecuteCommandClientCapabilities]
$creadList :: ReadS [ExecuteCommandClientCapabilities]
readsPrec :: Int -> ReadS ExecuteCommandClientCapabilities
$creadsPrec :: Int -> ReadS ExecuteCommandClientCapabilities
Read, ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
(ExecuteCommandClientCapabilities
 -> ExecuteCommandClientCapabilities -> Bool)
-> (ExecuteCommandClientCapabilities
    -> ExecuteCommandClientCapabilities -> Bool)
-> Eq ExecuteCommandClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
$c/= :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
== :: ExecuteCommandClientCapabilities
-> ExecuteCommandClientCapabilities -> Bool
$c== :: 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
showList :: [Command] -> ShowS
$cshowList :: [Command] -> ShowS
show :: Command -> String
$cshow :: Command -> String
showsPrec :: Int -> Command -> ShowS
$cshowsPrec :: Int -> 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
readListPrec :: ReadPrec [Command]
$creadListPrec :: ReadPrec [Command]
readPrec :: ReadPrec Command
$creadPrec :: ReadPrec Command
readList :: ReadS [Command]
$creadList :: ReadS [Command]
readsPrec :: Int -> ReadS Command
$creadsPrec :: Int -> ReadS Command
Read, Command -> Command -> Bool
(Command -> Command -> Bool)
-> (Command -> Command -> Bool) -> Eq Command
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Command -> Command -> Bool
$c/= :: Command -> Command -> Bool
== :: Command -> Command -> Bool
$c== :: Command -> Command -> Bool
Eq)

deriveJSON lspOptions ''Command