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

import qualified Data.Aeson                                 as A
import           Data.Aeson.TH
import           Data.Text                                  (Text)
import           Language.LSP.Types.Utils

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

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 ''ShowMessageParams

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

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 ''ShowMessageRequestParams

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

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 ''LogMessageParams