{-# 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
import Language.LSP.Types.Uri
import Language.LSP.Types.Location

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

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
_            = String -> Parser MessageType
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"MessageType"

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


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

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

-- | Params to show a document.
--
-- @since 3.16.0
data ShowDocumentParams =
  ShowDocumentParams {
    -- | The document uri to show.
    ShowDocumentParams -> Uri
_uri :: Uri

    -- | Indicates to show the resource in an external program.
    -- To show for example `https://code.visualstudio.com/`
    -- in the default WEB browser set `external` to `true`.
  , ShowDocumentParams -> Maybe Bool
_external :: Maybe Bool

    -- | An optional property to indicate whether the editor
    -- showing the document should take focus or not.
    -- Clients might ignore this property if an external
    -- program is started.
  , ShowDocumentParams -> Maybe Bool
_takeFocus :: Maybe Bool

    -- | An optional selection range if the document is a text
    -- document. Clients might ignore the property if an
    -- external program is started or the file is not a text
    -- file.
  , ShowDocumentParams -> Maybe Range
_selection :: Maybe Range
  } deriving (Int -> ShowDocumentParams -> ShowS
[ShowDocumentParams] -> ShowS
ShowDocumentParams -> String
(Int -> ShowDocumentParams -> ShowS)
-> (ShowDocumentParams -> String)
-> ([ShowDocumentParams] -> ShowS)
-> Show ShowDocumentParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShowDocumentParams] -> ShowS
$cshowList :: [ShowDocumentParams] -> ShowS
show :: ShowDocumentParams -> String
$cshow :: ShowDocumentParams -> String
showsPrec :: Int -> ShowDocumentParams -> ShowS
$cshowsPrec :: Int -> ShowDocumentParams -> ShowS
Show, ReadPrec [ShowDocumentParams]
ReadPrec ShowDocumentParams
Int -> ReadS ShowDocumentParams
ReadS [ShowDocumentParams]
(Int -> ReadS ShowDocumentParams)
-> ReadS [ShowDocumentParams]
-> ReadPrec ShowDocumentParams
-> ReadPrec [ShowDocumentParams]
-> Read ShowDocumentParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShowDocumentParams]
$creadListPrec :: ReadPrec [ShowDocumentParams]
readPrec :: ReadPrec ShowDocumentParams
$creadPrec :: ReadPrec ShowDocumentParams
readList :: ReadS [ShowDocumentParams]
$creadList :: ReadS [ShowDocumentParams]
readsPrec :: Int -> ReadS ShowDocumentParams
$creadsPrec :: Int -> ReadS ShowDocumentParams
Read, ShowDocumentParams -> ShowDocumentParams -> Bool
(ShowDocumentParams -> ShowDocumentParams -> Bool)
-> (ShowDocumentParams -> ShowDocumentParams -> Bool)
-> Eq ShowDocumentParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShowDocumentParams -> ShowDocumentParams -> Bool
$c/= :: ShowDocumentParams -> ShowDocumentParams -> Bool
== :: ShowDocumentParams -> ShowDocumentParams -> Bool
$c== :: ShowDocumentParams -> ShowDocumentParams -> Bool
Eq)

deriveJSON lspOptions ''ShowDocumentParams

-- | The result of an show document request.
--
--  @since 3.16.0
data ShowDocumentResult =
  ShowDocumentResult {
    -- | A boolean indicating if the show was successful.
    ShowDocumentResult -> Bool
_success :: Bool
  } deriving (Int -> ShowDocumentResult -> ShowS
[ShowDocumentResult] -> ShowS
ShowDocumentResult -> String
(Int -> ShowDocumentResult -> ShowS)
-> (ShowDocumentResult -> String)
-> ([ShowDocumentResult] -> ShowS)
-> Show ShowDocumentResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShowDocumentResult] -> ShowS
$cshowList :: [ShowDocumentResult] -> ShowS
show :: ShowDocumentResult -> String
$cshow :: ShowDocumentResult -> String
showsPrec :: Int -> ShowDocumentResult -> ShowS
$cshowsPrec :: Int -> ShowDocumentResult -> ShowS
Show, ReadPrec [ShowDocumentResult]
ReadPrec ShowDocumentResult
Int -> ReadS ShowDocumentResult
ReadS [ShowDocumentResult]
(Int -> ReadS ShowDocumentResult)
-> ReadS [ShowDocumentResult]
-> ReadPrec ShowDocumentResult
-> ReadPrec [ShowDocumentResult]
-> Read ShowDocumentResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShowDocumentResult]
$creadListPrec :: ReadPrec [ShowDocumentResult]
readPrec :: ReadPrec ShowDocumentResult
$creadPrec :: ReadPrec ShowDocumentResult
readList :: ReadS [ShowDocumentResult]
$creadList :: ReadS [ShowDocumentResult]
readsPrec :: Int -> ReadS ShowDocumentResult
$creadsPrec :: Int -> ReadS ShowDocumentResult
Read, ShowDocumentResult -> ShowDocumentResult -> Bool
(ShowDocumentResult -> ShowDocumentResult -> Bool)
-> (ShowDocumentResult -> ShowDocumentResult -> Bool)
-> Eq ShowDocumentResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShowDocumentResult -> ShowDocumentResult -> Bool
$c/= :: ShowDocumentResult -> ShowDocumentResult -> Bool
== :: ShowDocumentResult -> ShowDocumentResult -> Bool
$c== :: ShowDocumentResult -> ShowDocumentResult -> Bool
Eq)

deriveJSON lspOptions ''ShowDocumentResult

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

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