{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE DuplicateRecordFields      #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE TemplateHaskell            #-}
module Language.Haskell.LSP.Types.Window where

import           Control.Monad (unless)
import qualified Data.Aeson                                 as A
import           Data.Aeson.TH
import           Data.Maybe (catMaybes)
import           Data.Text                                  (Text)
import           Language.Haskell.LSP.Types.Constants
import           Language.Haskell.LSP.Types.Message
import           Language.Haskell.LSP.Types.Progress

-- ---------------------------------------------------------------------
{-
ShowMessage Notification

https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#showmessage-notification

The show message notification is sent from a server to a client to ask the
client to display a particular message in the user interface.

Notification:

    method: 'window/showMessage'
    params: ShowMessageParams defined as follows:

interface ShowMessageParams {
    /**
     * The message type. See {@link MessageType}.
     */
    type: number;

    /**
     * The actual message.
     */
    message: string;
}

Where the type is defined as follows:

enum MessageType {
    /**
     * An error message.
     */
    Error = 1,
    /**
     * A warning message.
     */
    Warning = 2,
    /**
     * An information message.
     */
    Info = 3,
    /**
     * A log message.
     */
    Log = 4
}
-}
data MessageType = MtError   -- ^ Error = 1,
                 | MtWarning -- ^ Warning = 2,
                 | MtInfo    -- ^ Info = 3,
                 | MtLog     -- ^ Log = 4
        deriving (MessageType -> MessageType -> Bool
(MessageType -> MessageType -> Bool)
-> (MessageType -> MessageType -> Bool) -> Eq MessageType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageType -> MessageType -> Bool
$c/= :: MessageType -> MessageType -> Bool
== :: MessageType -> MessageType -> Bool
$c== :: MessageType -> MessageType -> Bool
Eq,Eq MessageType
Eq MessageType
-> (MessageType -> MessageType -> Ordering)
-> (MessageType -> MessageType -> Bool)
-> (MessageType -> MessageType -> Bool)
-> (MessageType -> MessageType -> Bool)
-> (MessageType -> MessageType -> Bool)
-> (MessageType -> MessageType -> MessageType)
-> (MessageType -> MessageType -> MessageType)
-> Ord MessageType
MessageType -> MessageType -> Bool
MessageType -> MessageType -> Ordering
MessageType -> MessageType -> MessageType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: MessageType -> MessageType -> MessageType
$cmin :: MessageType -> MessageType -> MessageType
max :: MessageType -> MessageType -> MessageType
$cmax :: MessageType -> MessageType -> MessageType
>= :: MessageType -> MessageType -> Bool
$c>= :: MessageType -> MessageType -> Bool
> :: MessageType -> MessageType -> Bool
$c> :: MessageType -> MessageType -> Bool
<= :: MessageType -> MessageType -> Bool
$c<= :: MessageType -> MessageType -> Bool
< :: MessageType -> MessageType -> Bool
$c< :: MessageType -> MessageType -> Bool
compare :: MessageType -> MessageType -> Ordering
$ccompare :: MessageType -> MessageType -> Ordering
$cp1Ord :: Eq MessageType
Ord,Int -> MessageType -> ShowS
[MessageType] -> ShowS
MessageType -> String
(Int -> MessageType -> ShowS)
-> (MessageType -> String)
-> ([MessageType] -> ShowS)
-> Show MessageType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageType] -> ShowS
$cshowList :: [MessageType] -> ShowS
show :: MessageType -> String
$cshow :: MessageType -> String
showsPrec :: Int -> MessageType -> ShowS
$cshowsPrec :: Int -> MessageType -> ShowS
Show,ReadPrec [MessageType]
ReadPrec MessageType
Int -> ReadS MessageType
ReadS [MessageType]
(Int -> ReadS MessageType)
-> ReadS [MessageType]
-> ReadPrec MessageType
-> ReadPrec [MessageType]
-> Read MessageType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageType]
$creadListPrec :: ReadPrec [MessageType]
readPrec :: ReadPrec MessageType
$creadPrec :: ReadPrec MessageType
readList :: ReadS [MessageType]
$creadList :: ReadS [MessageType]
readsPrec :: Int -> ReadS MessageType
$creadsPrec :: Int -> ReadS MessageType
Read,Int -> MessageType
MessageType -> Int
MessageType -> [MessageType]
MessageType -> MessageType
MessageType -> MessageType -> [MessageType]
MessageType -> MessageType -> MessageType -> [MessageType]
(MessageType -> MessageType)
-> (MessageType -> MessageType)
-> (Int -> MessageType)
-> (MessageType -> Int)
-> (MessageType -> [MessageType])
-> (MessageType -> MessageType -> [MessageType])
-> (MessageType -> MessageType -> [MessageType])
-> (MessageType -> MessageType -> MessageType -> [MessageType])
-> Enum MessageType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MessageType -> MessageType -> MessageType -> [MessageType]
$cenumFromThenTo :: MessageType -> MessageType -> MessageType -> [MessageType]
enumFromTo :: MessageType -> MessageType -> [MessageType]
$cenumFromTo :: MessageType -> MessageType -> [MessageType]
enumFromThen :: MessageType -> MessageType -> [MessageType]
$cenumFromThen :: MessageType -> MessageType -> [MessageType]
enumFrom :: MessageType -> [MessageType]
$cenumFrom :: MessageType -> [MessageType]
fromEnum :: MessageType -> Int
$cfromEnum :: MessageType -> Int
toEnum :: Int -> MessageType
$ctoEnum :: Int -> MessageType
pred :: MessageType -> MessageType
$cpred :: MessageType -> MessageType
succ :: MessageType -> MessageType
$csucc :: MessageType -> MessageType
Enum)

instance A.ToJSON MessageType where
  toJSON :: MessageType -> Value
toJSON MessageType
MtError   = Scientific -> Value
A.Number Scientific
1
  toJSON MessageType
MtWarning = Scientific -> Value
A.Number Scientific
2
  toJSON MessageType
MtInfo    = Scientific -> Value
A.Number Scientific
3
  toJSON MessageType
MtLog     = Scientific -> Value
A.Number Scientific
4

instance A.FromJSON MessageType where
  parseJSON :: Value -> Parser MessageType
parseJSON (A.Number Scientific
1) = MessageType -> Parser MessageType
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtError
  parseJSON (A.Number Scientific
2) = MessageType -> Parser MessageType
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtWarning
  parseJSON (A.Number Scientific
3) = MessageType -> Parser MessageType
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtInfo
  parseJSON (A.Number Scientific
4) = MessageType -> Parser MessageType
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtLog
  parseJSON Value
_            = Parser MessageType
forall a. Monoid a => a
mempty

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


data ShowMessageParams =
  ShowMessageParams {
    ShowMessageParams -> MessageType
_xtype   :: MessageType
  , ShowMessageParams -> Text
_message :: Text
  } deriving (Int -> ShowMessageParams -> ShowS
[ShowMessageParams] -> ShowS
ShowMessageParams -> String
(Int -> ShowMessageParams -> ShowS)
-> (ShowMessageParams -> String)
-> ([ShowMessageParams] -> ShowS)
-> Show ShowMessageParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShowMessageParams] -> ShowS
$cshowList :: [ShowMessageParams] -> ShowS
show :: ShowMessageParams -> String
$cshow :: ShowMessageParams -> String
showsPrec :: Int -> ShowMessageParams -> ShowS
$cshowsPrec :: Int -> ShowMessageParams -> ShowS
Show, ReadPrec [ShowMessageParams]
ReadPrec ShowMessageParams
Int -> ReadS ShowMessageParams
ReadS [ShowMessageParams]
(Int -> ReadS ShowMessageParams)
-> ReadS [ShowMessageParams]
-> ReadPrec ShowMessageParams
-> ReadPrec [ShowMessageParams]
-> Read ShowMessageParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShowMessageParams]
$creadListPrec :: ReadPrec [ShowMessageParams]
readPrec :: ReadPrec ShowMessageParams
$creadPrec :: ReadPrec ShowMessageParams
readList :: ReadS [ShowMessageParams]
$creadList :: ReadS [ShowMessageParams]
readsPrec :: Int -> ReadS ShowMessageParams
$creadsPrec :: Int -> ReadS ShowMessageParams
Read, ShowMessageParams -> ShowMessageParams -> Bool
(ShowMessageParams -> ShowMessageParams -> Bool)
-> (ShowMessageParams -> ShowMessageParams -> Bool)
-> Eq ShowMessageParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShowMessageParams -> ShowMessageParams -> Bool
$c/= :: ShowMessageParams -> ShowMessageParams -> Bool
== :: ShowMessageParams -> ShowMessageParams -> Bool
$c== :: ShowMessageParams -> ShowMessageParams -> Bool
Eq)

deriveJSON lspOptions{ fieldLabelModifier = customModifier } ''ShowMessageParams

type ShowMessageNotification = NotificationMessage ServerMethod ShowMessageParams

-- ---------------------------------------------------------------------
{-
ShowMessage Request

https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#showmessage-request

    New: The show message request is sent from a server to a client to ask the
    client to display a particular message in the user interface. In addition to
    the show message notification the request allows to pass actions and to wait
    for an answer from the client.

Request:

    method: 'window/showMessageRequest'
    params: ShowMessageRequestParams defined as follows:

Response:

    result: the selected MessageActionItem
    error: code and message set in case an exception happens during showing a message.

interface ShowMessageRequestParams {
    /**
     * The message type. See {@link MessageType}
     */
    type: number;

    /**
     * The actual message
     */
    message: string;

    /**
     * The message action items to present.
     */
    actions?: MessageActionItem[];
}

Where the MessageActionItem is defined as follows:

interface MessageActionItem {
    /**
     * A short title like 'Retry', 'Open Log' etc.
     */
    title: string;
}
-}

data MessageActionItem =
  MessageActionItem
    { MessageActionItem -> Text
_title :: Text
    } deriving (Int -> MessageActionItem -> ShowS
[MessageActionItem] -> ShowS
MessageActionItem -> String
(Int -> MessageActionItem -> ShowS)
-> (MessageActionItem -> String)
-> ([MessageActionItem] -> ShowS)
-> Show MessageActionItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageActionItem] -> ShowS
$cshowList :: [MessageActionItem] -> ShowS
show :: MessageActionItem -> String
$cshow :: MessageActionItem -> String
showsPrec :: Int -> MessageActionItem -> ShowS
$cshowsPrec :: Int -> MessageActionItem -> ShowS
Show,ReadPrec [MessageActionItem]
ReadPrec MessageActionItem
Int -> ReadS MessageActionItem
ReadS [MessageActionItem]
(Int -> ReadS MessageActionItem)
-> ReadS [MessageActionItem]
-> ReadPrec MessageActionItem
-> ReadPrec [MessageActionItem]
-> Read MessageActionItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageActionItem]
$creadListPrec :: ReadPrec [MessageActionItem]
readPrec :: ReadPrec MessageActionItem
$creadPrec :: ReadPrec MessageActionItem
readList :: ReadS [MessageActionItem]
$creadList :: ReadS [MessageActionItem]
readsPrec :: Int -> ReadS MessageActionItem
$creadsPrec :: Int -> ReadS MessageActionItem
Read,MessageActionItem -> MessageActionItem -> Bool
(MessageActionItem -> MessageActionItem -> Bool)
-> (MessageActionItem -> MessageActionItem -> Bool)
-> Eq MessageActionItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageActionItem -> MessageActionItem -> Bool
$c/= :: MessageActionItem -> MessageActionItem -> Bool
== :: MessageActionItem -> MessageActionItem -> Bool
$c== :: MessageActionItem -> MessageActionItem -> Bool
Eq)

deriveJSON lspOptions ''MessageActionItem


data ShowMessageRequestParams =
  ShowMessageRequestParams
    { ShowMessageRequestParams -> MessageType
_xtype   :: MessageType
    , ShowMessageRequestParams -> Text
_message :: Text
    , ShowMessageRequestParams -> Maybe [MessageActionItem]
_actions :: Maybe [MessageActionItem]
    } deriving (Int -> ShowMessageRequestParams -> ShowS
[ShowMessageRequestParams] -> ShowS
ShowMessageRequestParams -> String
(Int -> ShowMessageRequestParams -> ShowS)
-> (ShowMessageRequestParams -> String)
-> ([ShowMessageRequestParams] -> ShowS)
-> Show ShowMessageRequestParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShowMessageRequestParams] -> ShowS
$cshowList :: [ShowMessageRequestParams] -> ShowS
show :: ShowMessageRequestParams -> String
$cshow :: ShowMessageRequestParams -> String
showsPrec :: Int -> ShowMessageRequestParams -> ShowS
$cshowsPrec :: Int -> ShowMessageRequestParams -> ShowS
Show,ReadPrec [ShowMessageRequestParams]
ReadPrec ShowMessageRequestParams
Int -> ReadS ShowMessageRequestParams
ReadS [ShowMessageRequestParams]
(Int -> ReadS ShowMessageRequestParams)
-> ReadS [ShowMessageRequestParams]
-> ReadPrec ShowMessageRequestParams
-> ReadPrec [ShowMessageRequestParams]
-> Read ShowMessageRequestParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShowMessageRequestParams]
$creadListPrec :: ReadPrec [ShowMessageRequestParams]
readPrec :: ReadPrec ShowMessageRequestParams
$creadPrec :: ReadPrec ShowMessageRequestParams
readList :: ReadS [ShowMessageRequestParams]
$creadList :: ReadS [ShowMessageRequestParams]
readsPrec :: Int -> ReadS ShowMessageRequestParams
$creadsPrec :: Int -> ReadS ShowMessageRequestParams
Read,ShowMessageRequestParams -> ShowMessageRequestParams -> Bool
(ShowMessageRequestParams -> ShowMessageRequestParams -> Bool)
-> (ShowMessageRequestParams -> ShowMessageRequestParams -> Bool)
-> Eq ShowMessageRequestParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShowMessageRequestParams -> ShowMessageRequestParams -> Bool
$c/= :: ShowMessageRequestParams -> ShowMessageRequestParams -> Bool
== :: ShowMessageRequestParams -> ShowMessageRequestParams -> Bool
$c== :: ShowMessageRequestParams -> ShowMessageRequestParams -> Bool
Eq)

deriveJSON lspOptions{ fieldLabelModifier = customModifier } ''ShowMessageRequestParams

type ShowMessageRequest = RequestMessage ServerMethod ShowMessageRequestParams Text
type ShowMessageResponse = ResponseMessage Text

-- ---------------------------------------------------------------------
{-
LogMessage Notification

https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#logmessage-notification

The log message notification is sent from the server to the client to ask the
client to log a particular message.

Notification:

    method: 'window/logMessage'
    params: LogMessageParams defined as follows:

interface LogMessageParams {
    /**
     * The message type. See {@link MessageType}
     */
    type: number;

    /**
     * The actual message
     */
    message: string;
}

Where type is defined as above.
-}

data LogMessageParams =
  LogMessageParams {
    LogMessageParams -> MessageType
_xtype   :: MessageType
  , LogMessageParams -> Text
_message :: Text
  } deriving (Int -> LogMessageParams -> ShowS
[LogMessageParams] -> ShowS
LogMessageParams -> String
(Int -> LogMessageParams -> ShowS)
-> (LogMessageParams -> String)
-> ([LogMessageParams] -> ShowS)
-> Show LogMessageParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogMessageParams] -> ShowS
$cshowList :: [LogMessageParams] -> ShowS
show :: LogMessageParams -> String
$cshow :: LogMessageParams -> String
showsPrec :: Int -> LogMessageParams -> ShowS
$cshowsPrec :: Int -> LogMessageParams -> ShowS
Show, ReadPrec [LogMessageParams]
ReadPrec LogMessageParams
Int -> ReadS LogMessageParams
ReadS [LogMessageParams]
(Int -> ReadS LogMessageParams)
-> ReadS [LogMessageParams]
-> ReadPrec LogMessageParams
-> ReadPrec [LogMessageParams]
-> Read LogMessageParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogMessageParams]
$creadListPrec :: ReadPrec [LogMessageParams]
readPrec :: ReadPrec LogMessageParams
$creadPrec :: ReadPrec LogMessageParams
readList :: ReadS [LogMessageParams]
$creadList :: ReadS [LogMessageParams]
readsPrec :: Int -> ReadS LogMessageParams
$creadsPrec :: Int -> ReadS LogMessageParams
Read, LogMessageParams -> LogMessageParams -> Bool
(LogMessageParams -> LogMessageParams -> Bool)
-> (LogMessageParams -> LogMessageParams -> Bool)
-> Eq LogMessageParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogMessageParams -> LogMessageParams -> Bool
$c/= :: LogMessageParams -> LogMessageParams -> Bool
== :: LogMessageParams -> LogMessageParams -> Bool
$c== :: LogMessageParams -> LogMessageParams -> Bool
Eq)

deriveJSON lspOptions{ fieldLabelModifier = customModifier } ''LogMessageParams


type LogMessageNotification = NotificationMessage ServerMethod LogMessageParams

{-
Progress Begin Notification

To start progress reporting a $/progress notification with the following payload must be sent:

export interface WorkDoneProgressBegin {

	kind: 'begin';

	/**
	 * Mandatory title of the progress operation. Used to briefly inform about
	 * the kind of operation being performed.
	 *
	 * Examples: "Indexing" or "Linking dependencies".
	 */
	title: string;

	/**
	 * Controls if a cancel button should show to allow the user to cancel the
	 * long running operation. Clients that don't support cancellation are allowed
	 * to ignore the setting.
	 */
	cancellable?: boolean;

	/**
	 * Optional, more detailed associated progress message. Contains
	 * complementary information to the `title`.
	 *
	 * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
	 * If unset, the previous progress message (if any) is still valid.
	 */
	message?: string;

	/**
	 * Optional progress percentage to display (value 100 is considered 100%).
	 * If not provided infinite progress is assumed and clients are allowed
	 * to ignore the `percentage` value in subsequent in report notifications.
	 *
	 * The value should be steadily rising. Clients are free to ignore values
	 * that are not following this rule.
	 */
	percentage?: number;
-}

-- | Parameters for a $/progress notification.
data ProgressParams t =
    ProgressParams {
      ProgressParams t -> ProgressToken
_token :: ProgressToken
    , ProgressParams t -> t
_value :: t
    } deriving (Int -> ProgressParams t -> ShowS
[ProgressParams t] -> ShowS
ProgressParams t -> String
(Int -> ProgressParams t -> ShowS)
-> (ProgressParams t -> String)
-> ([ProgressParams t] -> ShowS)
-> Show (ProgressParams t)
forall t. Show t => Int -> ProgressParams t -> ShowS
forall t. Show t => [ProgressParams t] -> ShowS
forall t. Show t => ProgressParams t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProgressParams t] -> ShowS
$cshowList :: forall t. Show t => [ProgressParams t] -> ShowS
show :: ProgressParams t -> String
$cshow :: forall t. Show t => ProgressParams t -> String
showsPrec :: Int -> ProgressParams t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> ProgressParams t -> ShowS
Show, ReadPrec [ProgressParams t]
ReadPrec (ProgressParams t)
Int -> ReadS (ProgressParams t)
ReadS [ProgressParams t]
(Int -> ReadS (ProgressParams t))
-> ReadS [ProgressParams t]
-> ReadPrec (ProgressParams t)
-> ReadPrec [ProgressParams t]
-> Read (ProgressParams t)
forall t. Read t => ReadPrec [ProgressParams t]
forall t. Read t => ReadPrec (ProgressParams t)
forall t. Read t => Int -> ReadS (ProgressParams t)
forall t. Read t => ReadS [ProgressParams t]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProgressParams t]
$creadListPrec :: forall t. Read t => ReadPrec [ProgressParams t]
readPrec :: ReadPrec (ProgressParams t)
$creadPrec :: forall t. Read t => ReadPrec (ProgressParams t)
readList :: ReadS [ProgressParams t]
$creadList :: forall t. Read t => ReadS [ProgressParams t]
readsPrec :: Int -> ReadS (ProgressParams t)
$creadsPrec :: forall t. Read t => Int -> ReadS (ProgressParams t)
Read, ProgressParams t -> ProgressParams t -> Bool
(ProgressParams t -> ProgressParams t -> Bool)
-> (ProgressParams t -> ProgressParams t -> Bool)
-> Eq (ProgressParams t)
forall t. Eq t => ProgressParams t -> ProgressParams t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProgressParams t -> ProgressParams t -> Bool
$c/= :: forall t. Eq t => ProgressParams t -> ProgressParams t -> Bool
== :: ProgressParams t -> ProgressParams t -> Bool
$c== :: forall t. Eq t => ProgressParams t -> ProgressParams t -> Bool
Eq)

deriveJSON lspOptions{ fieldLabelModifier = customModifier } ''ProgressParams

-- | Parameters for 'WorkDoneProgressBeginNotification'.
--
-- @since 0.10.0.0
data WorkDoneProgressBeginParams =
  WorkDoneProgressBeginParams {
  -- | Mandatory title of the progress operation.
  -- Used to briefly inform about the kind of operation being
  -- performed. Examples: "Indexing" or "Linking dependencies".
   WorkDoneProgressBeginParams -> Text
_title :: Text
  -- | Controls if a cancel button should show to allow the user to cancel the
  -- long running operation. Clients that don't support cancellation are allowed
  -- to ignore the setting.
  , WorkDoneProgressBeginParams -> Maybe Bool
_cancellable :: Maybe Bool
  -- | Optional, more detailed associated progress
  -- message. Contains complementary information to the
  -- '_title'. Examples: "3/25 files",
  -- "project/src/module2", "node_modules/some_dep". If
  -- unset, the previous progress message (if any) is
  -- still valid.
  , WorkDoneProgressBeginParams -> Maybe Text
_message :: Maybe Text
  -- | Optional progress percentage to display (value 100 is considered 100%).
  -- If not provided infinite progress is assumed and clients are allowed
  -- to ignore the '_percentage' value in subsequent in report notifications.
  --
  -- The value should be steadily rising. Clients are free to ignore values
  -- that are not following this rule.
  , WorkDoneProgressBeginParams -> Maybe Double
_percentage :: Maybe Double
  } deriving (Int -> WorkDoneProgressBeginParams -> ShowS
[WorkDoneProgressBeginParams] -> ShowS
WorkDoneProgressBeginParams -> String
(Int -> WorkDoneProgressBeginParams -> ShowS)
-> (WorkDoneProgressBeginParams -> String)
-> ([WorkDoneProgressBeginParams] -> ShowS)
-> Show WorkDoneProgressBeginParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkDoneProgressBeginParams] -> ShowS
$cshowList :: [WorkDoneProgressBeginParams] -> ShowS
show :: WorkDoneProgressBeginParams -> String
$cshow :: WorkDoneProgressBeginParams -> String
showsPrec :: Int -> WorkDoneProgressBeginParams -> ShowS
$cshowsPrec :: Int -> WorkDoneProgressBeginParams -> ShowS
Show, ReadPrec [WorkDoneProgressBeginParams]
ReadPrec WorkDoneProgressBeginParams
Int -> ReadS WorkDoneProgressBeginParams
ReadS [WorkDoneProgressBeginParams]
(Int -> ReadS WorkDoneProgressBeginParams)
-> ReadS [WorkDoneProgressBeginParams]
-> ReadPrec WorkDoneProgressBeginParams
-> ReadPrec [WorkDoneProgressBeginParams]
-> Read WorkDoneProgressBeginParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkDoneProgressBeginParams]
$creadListPrec :: ReadPrec [WorkDoneProgressBeginParams]
readPrec :: ReadPrec WorkDoneProgressBeginParams
$creadPrec :: ReadPrec WorkDoneProgressBeginParams
readList :: ReadS [WorkDoneProgressBeginParams]
$creadList :: ReadS [WorkDoneProgressBeginParams]
readsPrec :: Int -> ReadS WorkDoneProgressBeginParams
$creadsPrec :: Int -> ReadS WorkDoneProgressBeginParams
Read, WorkDoneProgressBeginParams -> WorkDoneProgressBeginParams -> Bool
(WorkDoneProgressBeginParams
 -> WorkDoneProgressBeginParams -> Bool)
-> (WorkDoneProgressBeginParams
    -> WorkDoneProgressBeginParams -> Bool)
-> Eq WorkDoneProgressBeginParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkDoneProgressBeginParams -> WorkDoneProgressBeginParams -> Bool
$c/= :: WorkDoneProgressBeginParams -> WorkDoneProgressBeginParams -> Bool
== :: WorkDoneProgressBeginParams -> WorkDoneProgressBeginParams -> Bool
$c== :: WorkDoneProgressBeginParams -> WorkDoneProgressBeginParams -> Bool
Eq)

instance A.ToJSON WorkDoneProgressBeginParams where
    toJSON :: WorkDoneProgressBeginParams -> Value
toJSON WorkDoneProgressBeginParams{Maybe Bool
Maybe Double
Maybe Text
Text
_percentage :: Maybe Double
_message :: Maybe Text
_cancellable :: Maybe Bool
_title :: Text
$sel:_percentage:WorkDoneProgressBeginParams :: WorkDoneProgressBeginParams -> Maybe Double
$sel:_message:WorkDoneProgressBeginParams :: WorkDoneProgressBeginParams -> Maybe Text
$sel:_cancellable:WorkDoneProgressBeginParams :: WorkDoneProgressBeginParams -> Maybe Bool
$sel:_title:WorkDoneProgressBeginParams :: WorkDoneProgressBeginParams -> Text
..} =
        [Pair] -> Value
A.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
            [ Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Text
"kind" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..= (Text
"begin" :: Text)
            , Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Text
"title" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..= Text
_title
            , (Text
"cancellable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_cancellable
            , (Text
"message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
_message
            , (Text
"percentage" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Double
_percentage
            ]

instance A.FromJSON WorkDoneProgressBeginParams where
    parseJSON :: Value -> Parser WorkDoneProgressBeginParams
parseJSON = String
-> (Object -> Parser WorkDoneProgressBeginParams)
-> Value
-> Parser WorkDoneProgressBeginParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"WorkDoneProgressBegin" ((Object -> Parser WorkDoneProgressBeginParams)
 -> Value -> Parser WorkDoneProgressBeginParams)
-> (Object -> Parser WorkDoneProgressBeginParams)
-> Value
-> Parser WorkDoneProgressBeginParams
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Text
kind <- Object
o Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
A..: Text
"kind"
        Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
kind Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
"begin" :: Text)) (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Expected kind \"begin\" but got " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
kind
        Text
_title <- Object
o Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
A..: Text
"title"
        Maybe Bool
_cancellable <- Object
o Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"cancellable"
        Maybe Text
_message <- Object
o Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"message"
        Maybe Double
_percentage <- Object
o Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"percentage"
        WorkDoneProgressBeginParams -> Parser WorkDoneProgressBeginParams
forall (f :: * -> *) a. Applicative f => a -> f a
pure WorkDoneProgressBeginParams :: Text
-> Maybe Bool
-> Maybe Text
-> Maybe Double
-> WorkDoneProgressBeginParams
WorkDoneProgressBeginParams{Maybe Bool
Maybe Double
Maybe Text
Text
_percentage :: Maybe Double
_message :: Maybe Text
_cancellable :: Maybe Bool
_title :: Text
$sel:_percentage:WorkDoneProgressBeginParams :: Maybe Double
$sel:_message:WorkDoneProgressBeginParams :: Maybe Text
$sel:_cancellable:WorkDoneProgressBeginParams :: Maybe Bool
$sel:_title:WorkDoneProgressBeginParams :: Text
..}

-- | The $/progress begin notification is sent from the server to the
-- client to ask the client to start progress.
--
-- @since 0.10.0.0
type WorkDoneProgressBeginNotification = NotificationMessage ServerMethod (ProgressParams WorkDoneProgressBeginParams)

{-
Progress Report Notification

Reporting progress is done using the following payload:

export interface WorkDoneProgressReport {

	kind: 'report';

	/**
	 * Controls enablement state of a cancel button. This property is only valid if a cancel
	 * button got requested in the `WorkDoneProgressStart` payload.
	 *
	 * Clients that don't support cancellation or don't support control the button's
	 * enablement state are allowed to ignore the setting.
	 */
	cancellable?: boolean;

	/**
	 * Optional, more detailed associated progress message. Contains
	 * complementary information to the `title`.
	 *
	 * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
	 * If unset, the previous progress message (if any) is still valid.
	 */
	message?: string;

	/**
	 * Optional progress percentage to display (value 100 is considered 100%).
	 * If not provided infinite progress is assumed and clients are allowed
	 * to ignore the `percentage` value in subsequent in report notifications.
	 *
	 * The value should be steadily rising. Clients are free to ignore values
	 * that are not following this rule.
	 */
	percentage?: number;
}
-}

-- | Parameters for 'WorkDoneProgressReportNotification'
--
-- @since 0.10.0.0
data WorkDoneProgressReportParams =
  WorkDoneProgressReportParams {
    WorkDoneProgressReportParams -> Maybe Bool
_cancellable :: Maybe Bool
  -- | Optional, more detailed associated progress
  -- message. Contains complementary information to the
  -- '_title'. Examples: "3/25 files",
  -- "project/src/module2", "node_modules/some_dep". If
  -- unset, the previous progress message (if any) is
  -- still valid.
  , WorkDoneProgressReportParams -> Maybe Text
_message :: Maybe Text
  -- | Optional progress percentage to display (value 100 is considered 100%).
  -- If infinite progress was indicated in the start notification client
  -- are allowed to ignore the value. In addition the value should be steadily
  -- rising. Clients are free to ignore values that are not following this rule.
  , WorkDoneProgressReportParams -> Maybe Double
_percentage :: Maybe Double
  } deriving (Int -> WorkDoneProgressReportParams -> ShowS
[WorkDoneProgressReportParams] -> ShowS
WorkDoneProgressReportParams -> String
(Int -> WorkDoneProgressReportParams -> ShowS)
-> (WorkDoneProgressReportParams -> String)
-> ([WorkDoneProgressReportParams] -> ShowS)
-> Show WorkDoneProgressReportParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkDoneProgressReportParams] -> ShowS
$cshowList :: [WorkDoneProgressReportParams] -> ShowS
show :: WorkDoneProgressReportParams -> String
$cshow :: WorkDoneProgressReportParams -> String
showsPrec :: Int -> WorkDoneProgressReportParams -> ShowS
$cshowsPrec :: Int -> WorkDoneProgressReportParams -> ShowS
Show, ReadPrec [WorkDoneProgressReportParams]
ReadPrec WorkDoneProgressReportParams
Int -> ReadS WorkDoneProgressReportParams
ReadS [WorkDoneProgressReportParams]
(Int -> ReadS WorkDoneProgressReportParams)
-> ReadS [WorkDoneProgressReportParams]
-> ReadPrec WorkDoneProgressReportParams
-> ReadPrec [WorkDoneProgressReportParams]
-> Read WorkDoneProgressReportParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkDoneProgressReportParams]
$creadListPrec :: ReadPrec [WorkDoneProgressReportParams]
readPrec :: ReadPrec WorkDoneProgressReportParams
$creadPrec :: ReadPrec WorkDoneProgressReportParams
readList :: ReadS [WorkDoneProgressReportParams]
$creadList :: ReadS [WorkDoneProgressReportParams]
readsPrec :: Int -> ReadS WorkDoneProgressReportParams
$creadsPrec :: Int -> ReadS WorkDoneProgressReportParams
Read, WorkDoneProgressReportParams
-> WorkDoneProgressReportParams -> Bool
(WorkDoneProgressReportParams
 -> WorkDoneProgressReportParams -> Bool)
-> (WorkDoneProgressReportParams
    -> WorkDoneProgressReportParams -> Bool)
-> Eq WorkDoneProgressReportParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkDoneProgressReportParams
-> WorkDoneProgressReportParams -> Bool
$c/= :: WorkDoneProgressReportParams
-> WorkDoneProgressReportParams -> Bool
== :: WorkDoneProgressReportParams
-> WorkDoneProgressReportParams -> Bool
$c== :: WorkDoneProgressReportParams
-> WorkDoneProgressReportParams -> Bool
Eq)

instance A.ToJSON WorkDoneProgressReportParams where
  toJSON :: WorkDoneProgressReportParams -> Value
toJSON WorkDoneProgressReportParams{Maybe Bool
Maybe Double
Maybe Text
_percentage :: Maybe Double
_message :: Maybe Text
_cancellable :: Maybe Bool
$sel:_percentage:WorkDoneProgressReportParams :: WorkDoneProgressReportParams -> Maybe Double
$sel:_message:WorkDoneProgressReportParams :: WorkDoneProgressReportParams -> Maybe Text
$sel:_cancellable:WorkDoneProgressReportParams :: WorkDoneProgressReportParams -> Maybe Bool
..} =
    [Pair] -> Value
A.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
      [ Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Text
"kind" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..= (Text
"report" :: Text)
      , (Text
"cancellable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_cancellable
      , (Text
"message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
_message
      , (Text
"percentage" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Double
_percentage
      ]

instance A.FromJSON WorkDoneProgressReportParams where
  parseJSON :: Value -> Parser WorkDoneProgressReportParams
parseJSON = String
-> (Object -> Parser WorkDoneProgressReportParams)
-> Value
-> Parser WorkDoneProgressReportParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"WorkDoneProgressReport" ((Object -> Parser WorkDoneProgressReportParams)
 -> Value -> Parser WorkDoneProgressReportParams)
-> (Object -> Parser WorkDoneProgressReportParams)
-> Value
-> Parser WorkDoneProgressReportParams
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    Text
kind <- Object
o Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
A..: Text
"kind"
    Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
kind Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
"report" :: Text)) (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Expected kind \"report\" but got " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
kind
    Maybe Bool
_cancellable <- Object
o Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"cancellable"
    Maybe Text
_message <- Object
o Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"message"
    Maybe Double
_percentage <- Object
o Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"percentage"
    WorkDoneProgressReportParams -> Parser WorkDoneProgressReportParams
forall (f :: * -> *) a. Applicative f => a -> f a
pure WorkDoneProgressReportParams :: Maybe Bool
-> Maybe Text -> Maybe Double -> WorkDoneProgressReportParams
WorkDoneProgressReportParams{Maybe Bool
Maybe Double
Maybe Text
_percentage :: Maybe Double
_message :: Maybe Text
_cancellable :: Maybe Bool
$sel:_percentage:WorkDoneProgressReportParams :: Maybe Double
$sel:_message:WorkDoneProgressReportParams :: Maybe Text
$sel:_cancellable:WorkDoneProgressReportParams :: Maybe Bool
..}

-- | The workdone $/progress report notification is sent from the server to the
-- client to report progress for a previously started progress.
--
-- @since 0.10.0.0
type WorkDoneProgressReportNotification = NotificationMessage ServerMethod (ProgressParams WorkDoneProgressReportParams)

{-
Progress End Notification

Signaling the end of a progress reporting is done using the following payload:

export interface WorkDoneProgressEnd {

	kind: 'end';

	/**
	 * Optional, a final message indicating to for example indicate the outcome
	 * of the operation.
	 */
	message?: string;
}
-}

-- | Parameters for 'WorkDoneProgressEndNotification'.
--
-- @since 0.10.0.0
data WorkDoneProgressEndParams =
  WorkDoneProgressEndParams {
    WorkDoneProgressEndParams -> Maybe Text
_message   :: Maybe Text
  } deriving (Int -> WorkDoneProgressEndParams -> ShowS
[WorkDoneProgressEndParams] -> ShowS
WorkDoneProgressEndParams -> String
(Int -> WorkDoneProgressEndParams -> ShowS)
-> (WorkDoneProgressEndParams -> String)
-> ([WorkDoneProgressEndParams] -> ShowS)
-> Show WorkDoneProgressEndParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkDoneProgressEndParams] -> ShowS
$cshowList :: [WorkDoneProgressEndParams] -> ShowS
show :: WorkDoneProgressEndParams -> String
$cshow :: WorkDoneProgressEndParams -> String
showsPrec :: Int -> WorkDoneProgressEndParams -> ShowS
$cshowsPrec :: Int -> WorkDoneProgressEndParams -> ShowS
Show, ReadPrec [WorkDoneProgressEndParams]
ReadPrec WorkDoneProgressEndParams
Int -> ReadS WorkDoneProgressEndParams
ReadS [WorkDoneProgressEndParams]
(Int -> ReadS WorkDoneProgressEndParams)
-> ReadS [WorkDoneProgressEndParams]
-> ReadPrec WorkDoneProgressEndParams
-> ReadPrec [WorkDoneProgressEndParams]
-> Read WorkDoneProgressEndParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkDoneProgressEndParams]
$creadListPrec :: ReadPrec [WorkDoneProgressEndParams]
readPrec :: ReadPrec WorkDoneProgressEndParams
$creadPrec :: ReadPrec WorkDoneProgressEndParams
readList :: ReadS [WorkDoneProgressEndParams]
$creadList :: ReadS [WorkDoneProgressEndParams]
readsPrec :: Int -> ReadS WorkDoneProgressEndParams
$creadsPrec :: Int -> ReadS WorkDoneProgressEndParams
Read, WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool
(WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool)
-> (WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool)
-> Eq WorkDoneProgressEndParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool
$c/= :: WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool
== :: WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool
$c== :: WorkDoneProgressEndParams -> WorkDoneProgressEndParams -> Bool
Eq)

instance A.ToJSON WorkDoneProgressEndParams where
  toJSON :: WorkDoneProgressEndParams -> Value
toJSON WorkDoneProgressEndParams{Maybe Text
_message :: Maybe Text
$sel:_message:WorkDoneProgressEndParams :: WorkDoneProgressEndParams -> Maybe Text
..} =
    [Pair] -> Value
A.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
      [ Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Text
"kind" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..= (Text
"end" :: Text)
      , (Text
"message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
A..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
_message
      ]

instance A.FromJSON WorkDoneProgressEndParams where
  parseJSON :: Value -> Parser WorkDoneProgressEndParams
parseJSON = String
-> (Object -> Parser WorkDoneProgressEndParams)
-> Value
-> Parser WorkDoneProgressEndParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"WorkDoneProgressEnd" ((Object -> Parser WorkDoneProgressEndParams)
 -> Value -> Parser WorkDoneProgressEndParams)
-> (Object -> Parser WorkDoneProgressEndParams)
-> Value
-> Parser WorkDoneProgressEndParams
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    Text
kind <- Object
o Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
A..: Text
"kind"
    Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
kind Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
"end" :: Text)) (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Expected kind \"end\" but got " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
kind
    Maybe Text
_message <- Object
o Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
A..:? Text
"message"
    WorkDoneProgressEndParams -> Parser WorkDoneProgressEndParams
forall (f :: * -> *) a. Applicative f => a -> f a
pure WorkDoneProgressEndParams :: Maybe Text -> WorkDoneProgressEndParams
WorkDoneProgressEndParams{Maybe Text
_message :: Maybe Text
$sel:_message:WorkDoneProgressEndParams :: Maybe Text
..}

-- | The $/progress end notification is sent from the server to the
-- client to stop a previously started progress.
--
-- @since 0.10.0.0
type WorkDoneProgressEndNotification = NotificationMessage ServerMethod (ProgressParams WorkDoneProgressEndParams)

{-
Progress Cancel Notification

The window/workDoneProgress/cancel notification is sent from the client to the server to inform the server that the user has pressed the cancel button on the progress UX. A server receiving a cancel request must still close a progress using the done notification.

Notification:

method: 'window/workDoneProgress/cancel'
params: WorkDoneProgressCancelParams defined as follows:
export interface WorkDoneProgressCancelParams {
	/**
	 * The token to be used to report progress.
	 */
	token: ProgressToken;
}
-}

-- | Parameters for 'WorkDoneProgressCancelNotification'.
--
-- @since 0.10.0.0
data WorkDoneProgressCancelParams =
  WorkDoneProgressCancelParams {
  -- | A unique identifier to associate multiple progress
  -- notifications with the same progress.
    WorkDoneProgressCancelParams -> ProgressToken
_token   :: ProgressToken
  } deriving (Int -> WorkDoneProgressCancelParams -> ShowS
[WorkDoneProgressCancelParams] -> ShowS
WorkDoneProgressCancelParams -> String
(Int -> WorkDoneProgressCancelParams -> ShowS)
-> (WorkDoneProgressCancelParams -> String)
-> ([WorkDoneProgressCancelParams] -> ShowS)
-> Show WorkDoneProgressCancelParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkDoneProgressCancelParams] -> ShowS
$cshowList :: [WorkDoneProgressCancelParams] -> ShowS
show :: WorkDoneProgressCancelParams -> String
$cshow :: WorkDoneProgressCancelParams -> String
showsPrec :: Int -> WorkDoneProgressCancelParams -> ShowS
$cshowsPrec :: Int -> WorkDoneProgressCancelParams -> ShowS
Show, ReadPrec [WorkDoneProgressCancelParams]
ReadPrec WorkDoneProgressCancelParams
Int -> ReadS WorkDoneProgressCancelParams
ReadS [WorkDoneProgressCancelParams]
(Int -> ReadS WorkDoneProgressCancelParams)
-> ReadS [WorkDoneProgressCancelParams]
-> ReadPrec WorkDoneProgressCancelParams
-> ReadPrec [WorkDoneProgressCancelParams]
-> Read WorkDoneProgressCancelParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkDoneProgressCancelParams]
$creadListPrec :: ReadPrec [WorkDoneProgressCancelParams]
readPrec :: ReadPrec WorkDoneProgressCancelParams
$creadPrec :: ReadPrec WorkDoneProgressCancelParams
readList :: ReadS [WorkDoneProgressCancelParams]
$creadList :: ReadS [WorkDoneProgressCancelParams]
readsPrec :: Int -> ReadS WorkDoneProgressCancelParams
$creadsPrec :: Int -> ReadS WorkDoneProgressCancelParams
Read, WorkDoneProgressCancelParams
-> WorkDoneProgressCancelParams -> Bool
(WorkDoneProgressCancelParams
 -> WorkDoneProgressCancelParams -> Bool)
-> (WorkDoneProgressCancelParams
    -> WorkDoneProgressCancelParams -> Bool)
-> Eq WorkDoneProgressCancelParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkDoneProgressCancelParams
-> WorkDoneProgressCancelParams -> Bool
$c/= :: WorkDoneProgressCancelParams
-> WorkDoneProgressCancelParams -> Bool
== :: WorkDoneProgressCancelParams
-> WorkDoneProgressCancelParams -> Bool
$c== :: WorkDoneProgressCancelParams
-> WorkDoneProgressCancelParams -> Bool
Eq)

deriveJSON lspOptions{ fieldLabelModifier = customModifier } ''WorkDoneProgressCancelParams

-- | The window/workDoneProgress/cancel notification is sent from the client to the server
-- to inform the server that the user has pressed the cancel button on the progress UX.
-- A server receiving a cancel request must still close a progress using the done notification.
--
-- @since 0.10.0.0
type WorkDoneProgressCancelNotification = NotificationMessage ClientMethod WorkDoneProgressCancelParams

data WorkDoneProgressCreateParams =
    WorkDoneProgressCreateParams {
      WorkDoneProgressCreateParams -> ProgressToken
_token :: ProgressToken
    } deriving (Int -> WorkDoneProgressCreateParams -> ShowS
[WorkDoneProgressCreateParams] -> ShowS
WorkDoneProgressCreateParams -> String
(Int -> WorkDoneProgressCreateParams -> ShowS)
-> (WorkDoneProgressCreateParams -> String)
-> ([WorkDoneProgressCreateParams] -> ShowS)
-> Show WorkDoneProgressCreateParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkDoneProgressCreateParams] -> ShowS
$cshowList :: [WorkDoneProgressCreateParams] -> ShowS
show :: WorkDoneProgressCreateParams -> String
$cshow :: WorkDoneProgressCreateParams -> String
showsPrec :: Int -> WorkDoneProgressCreateParams -> ShowS
$cshowsPrec :: Int -> WorkDoneProgressCreateParams -> ShowS
Show, ReadPrec [WorkDoneProgressCreateParams]
ReadPrec WorkDoneProgressCreateParams
Int -> ReadS WorkDoneProgressCreateParams
ReadS [WorkDoneProgressCreateParams]
(Int -> ReadS WorkDoneProgressCreateParams)
-> ReadS [WorkDoneProgressCreateParams]
-> ReadPrec WorkDoneProgressCreateParams
-> ReadPrec [WorkDoneProgressCreateParams]
-> Read WorkDoneProgressCreateParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkDoneProgressCreateParams]
$creadListPrec :: ReadPrec [WorkDoneProgressCreateParams]
readPrec :: ReadPrec WorkDoneProgressCreateParams
$creadPrec :: ReadPrec WorkDoneProgressCreateParams
readList :: ReadS [WorkDoneProgressCreateParams]
$creadList :: ReadS [WorkDoneProgressCreateParams]
readsPrec :: Int -> ReadS WorkDoneProgressCreateParams
$creadsPrec :: Int -> ReadS WorkDoneProgressCreateParams
Read, WorkDoneProgressCreateParams
-> WorkDoneProgressCreateParams -> Bool
(WorkDoneProgressCreateParams
 -> WorkDoneProgressCreateParams -> Bool)
-> (WorkDoneProgressCreateParams
    -> WorkDoneProgressCreateParams -> Bool)
-> Eq WorkDoneProgressCreateParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkDoneProgressCreateParams
-> WorkDoneProgressCreateParams -> Bool
$c/= :: WorkDoneProgressCreateParams
-> WorkDoneProgressCreateParams -> Bool
== :: WorkDoneProgressCreateParams
-> WorkDoneProgressCreateParams -> Bool
$c== :: WorkDoneProgressCreateParams
-> WorkDoneProgressCreateParams -> Bool
Eq)

deriveJSON lspOptions{ fieldLabelModifier = customModifier } ''WorkDoneProgressCreateParams

type WorkDoneProgressCreateRequest = RequestMessage ServerMethod WorkDoneProgressCreateParams ()