{-# 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
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
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
Ord,Int -> MessageType -> ShowS
[MessageType] -> ShowS
MessageType -> String
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]
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]
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) = forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtError
  parseJSON (A.Number Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtWarning
  parseJSON (A.Number Scientific
3) = forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtInfo
  parseJSON (A.Number Scientific
4) = forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageType
MtLog
  parseJSON Value
_            = 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
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]
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
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
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]
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
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
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]
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
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
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]
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
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
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]
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
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
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]
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
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