{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DuplicateRecordFields #-}
module Language.LSP.Types.Initialize where
import Data.Aeson
import Data.Aeson.TH
import Data.Text (Text)
import qualified Data.Text as T
import Language.LSP.Types.ClientCapabilities
import Language.LSP.Types.Common
import Language.LSP.Types.Progress
import Language.LSP.Types.ServerCapabilities
import Language.LSP.Types.Uri
import Language.LSP.Types.Utils
import Language.LSP.Types.WorkspaceFolders
data Trace = TraceOff | TraceMessages | TraceVerbose
deriving (Int -> Trace -> ShowS
[Trace] -> ShowS
Trace -> String
(Int -> Trace -> ShowS)
-> (Trace -> String) -> ([Trace] -> ShowS) -> Show Trace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Trace] -> ShowS
$cshowList :: [Trace] -> ShowS
show :: Trace -> String
$cshow :: Trace -> String
showsPrec :: Int -> Trace -> ShowS
$cshowsPrec :: Int -> Trace -> ShowS
Show, ReadPrec [Trace]
ReadPrec Trace
Int -> ReadS Trace
ReadS [Trace]
(Int -> ReadS Trace)
-> ReadS [Trace]
-> ReadPrec Trace
-> ReadPrec [Trace]
-> Read Trace
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Trace]
$creadListPrec :: ReadPrec [Trace]
readPrec :: ReadPrec Trace
$creadPrec :: ReadPrec Trace
readList :: ReadS [Trace]
$creadList :: ReadS [Trace]
readsPrec :: Int -> ReadS Trace
$creadsPrec :: Int -> ReadS Trace
Read, Trace -> Trace -> Bool
(Trace -> Trace -> Bool) -> (Trace -> Trace -> Bool) -> Eq Trace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Trace -> Trace -> Bool
$c/= :: Trace -> Trace -> Bool
== :: Trace -> Trace -> Bool
$c== :: Trace -> Trace -> Bool
Eq)
instance ToJSON Trace where
toJSON :: Trace -> Value
toJSON Trace
TraceOff = Text -> Value
String (String -> Text
T.pack String
"off")
toJSON Trace
TraceMessages = Text -> Value
String (String -> Text
T.pack String
"messages")
toJSON Trace
TraceVerbose = Text -> Value
String (String -> Text
T.pack String
"verbose")
instance FromJSON Trace where
parseJSON :: Value -> Parser Trace
parseJSON (String Text
s) = case Text -> String
T.unpack Text
s of
String
"off" -> Trace -> Parser Trace
forall (m :: * -> *) a. Monad m => a -> m a
return Trace
TraceOff
String
"messages" -> Trace -> Parser Trace
forall (m :: * -> *) a. Monad m => a -> m a
return Trace
TraceMessages
String
"verbose" -> Trace -> Parser Trace
forall (m :: * -> *) a. Monad m => a -> m a
return Trace
TraceVerbose
String
_ -> Parser Trace
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser Trace
forall a. Monoid a => a
mempty
data ClientInfo =
ClientInfo
{
ClientInfo -> Text
_name :: Text
, ClientInfo -> Maybe Text
_version :: Maybe Text
} deriving (Int -> ClientInfo -> ShowS
[ClientInfo] -> ShowS
ClientInfo -> String
(Int -> ClientInfo -> ShowS)
-> (ClientInfo -> String)
-> ([ClientInfo] -> ShowS)
-> Show ClientInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClientInfo] -> ShowS
$cshowList :: [ClientInfo] -> ShowS
show :: ClientInfo -> String
$cshow :: ClientInfo -> String
showsPrec :: Int -> ClientInfo -> ShowS
$cshowsPrec :: Int -> ClientInfo -> ShowS
Show, ReadPrec [ClientInfo]
ReadPrec ClientInfo
Int -> ReadS ClientInfo
ReadS [ClientInfo]
(Int -> ReadS ClientInfo)
-> ReadS [ClientInfo]
-> ReadPrec ClientInfo
-> ReadPrec [ClientInfo]
-> Read ClientInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClientInfo]
$creadListPrec :: ReadPrec [ClientInfo]
readPrec :: ReadPrec ClientInfo
$creadPrec :: ReadPrec ClientInfo
readList :: ReadS [ClientInfo]
$creadList :: ReadS [ClientInfo]
readsPrec :: Int -> ReadS ClientInfo
$creadsPrec :: Int -> ReadS ClientInfo
Read, ClientInfo -> ClientInfo -> Bool
(ClientInfo -> ClientInfo -> Bool)
-> (ClientInfo -> ClientInfo -> Bool) -> Eq ClientInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientInfo -> ClientInfo -> Bool
$c/= :: ClientInfo -> ClientInfo -> Bool
== :: ClientInfo -> ClientInfo -> Bool
$c== :: ClientInfo -> ClientInfo -> Bool
Eq)
deriveJSON lspOptions ''ClientInfo
makeExtendingDatatype "InitializeParams" [''WorkDoneProgressParams]
[ ("_processId", [t| Maybe Int|])
, ("_clientInfo", [t| Maybe ClientInfo |])
, ("_rootPath", [t| Maybe Text |])
, ("_rootUri", [t| Maybe Uri |])
, ("_initializationOptions", [t| Maybe Value |])
, ("_capabilities", [t| ClientCapabilities |])
, ("_trace", [t| Maybe Trace |])
, ("_workspaceFolders", [t| Maybe (List WorkspaceFolder) |])
]
{-# DEPRECATED _rootPath "Use _rootUri" #-}
deriveJSON lspOptions ''InitializeParams
data InitializeError =
InitializeError
{ InitializeError -> Bool
_retry :: Bool
} deriving (ReadPrec [InitializeError]
ReadPrec InitializeError
Int -> ReadS InitializeError
ReadS [InitializeError]
(Int -> ReadS InitializeError)
-> ReadS [InitializeError]
-> ReadPrec InitializeError
-> ReadPrec [InitializeError]
-> Read InitializeError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitializeError]
$creadListPrec :: ReadPrec [InitializeError]
readPrec :: ReadPrec InitializeError
$creadPrec :: ReadPrec InitializeError
readList :: ReadS [InitializeError]
$creadList :: ReadS [InitializeError]
readsPrec :: Int -> ReadS InitializeError
$creadsPrec :: Int -> ReadS InitializeError
Read, Int -> InitializeError -> ShowS
[InitializeError] -> ShowS
InitializeError -> String
(Int -> InitializeError -> ShowS)
-> (InitializeError -> String)
-> ([InitializeError] -> ShowS)
-> Show InitializeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitializeError] -> ShowS
$cshowList :: [InitializeError] -> ShowS
show :: InitializeError -> String
$cshow :: InitializeError -> String
showsPrec :: Int -> InitializeError -> ShowS
$cshowsPrec :: Int -> InitializeError -> ShowS
Show, InitializeError -> InitializeError -> Bool
(InitializeError -> InitializeError -> Bool)
-> (InitializeError -> InitializeError -> Bool)
-> Eq InitializeError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitializeError -> InitializeError -> Bool
$c/= :: InitializeError -> InitializeError -> Bool
== :: InitializeError -> InitializeError -> Bool
$c== :: InitializeError -> InitializeError -> Bool
Eq)
deriveJSON lspOptions ''InitializeError
data ServerInfo =
ServerInfo
{
ServerInfo -> Text
_name :: Text
, ServerInfo -> Maybe Text
_version :: Maybe Text
} deriving (Int -> ServerInfo -> ShowS
[ServerInfo] -> ShowS
ServerInfo -> String
(Int -> ServerInfo -> ShowS)
-> (ServerInfo -> String)
-> ([ServerInfo] -> ShowS)
-> Show ServerInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerInfo] -> ShowS
$cshowList :: [ServerInfo] -> ShowS
show :: ServerInfo -> String
$cshow :: ServerInfo -> String
showsPrec :: Int -> ServerInfo -> ShowS
$cshowsPrec :: Int -> ServerInfo -> ShowS
Show, ReadPrec [ServerInfo]
ReadPrec ServerInfo
Int -> ReadS ServerInfo
ReadS [ServerInfo]
(Int -> ReadS ServerInfo)
-> ReadS [ServerInfo]
-> ReadPrec ServerInfo
-> ReadPrec [ServerInfo]
-> Read ServerInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerInfo]
$creadListPrec :: ReadPrec [ServerInfo]
readPrec :: ReadPrec ServerInfo
$creadPrec :: ReadPrec ServerInfo
readList :: ReadS [ServerInfo]
$creadList :: ReadS [ServerInfo]
readsPrec :: Int -> ReadS ServerInfo
$creadsPrec :: Int -> ReadS ServerInfo
Read, ServerInfo -> ServerInfo -> Bool
(ServerInfo -> ServerInfo -> Bool)
-> (ServerInfo -> ServerInfo -> Bool) -> Eq ServerInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerInfo -> ServerInfo -> Bool
$c/= :: ServerInfo -> ServerInfo -> Bool
== :: ServerInfo -> ServerInfo -> Bool
$c== :: ServerInfo -> ServerInfo -> Bool
Eq)
deriveJSON lspOptions ''ServerInfo
data InitializeResult =
InitializeResult
{
InitializeResult -> ServerCapabilities
_capabilities :: ServerCapabilities
, InitializeResult -> Maybe ServerInfo
_serverInfo :: Maybe ServerInfo
} deriving (Int -> InitializeResult -> ShowS
[InitializeResult] -> ShowS
InitializeResult -> String
(Int -> InitializeResult -> ShowS)
-> (InitializeResult -> String)
-> ([InitializeResult] -> ShowS)
-> Show InitializeResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitializeResult] -> ShowS
$cshowList :: [InitializeResult] -> ShowS
show :: InitializeResult -> String
$cshow :: InitializeResult -> String
showsPrec :: Int -> InitializeResult -> ShowS
$cshowsPrec :: Int -> InitializeResult -> ShowS
Show, ReadPrec [InitializeResult]
ReadPrec InitializeResult
Int -> ReadS InitializeResult
ReadS [InitializeResult]
(Int -> ReadS InitializeResult)
-> ReadS [InitializeResult]
-> ReadPrec InitializeResult
-> ReadPrec [InitializeResult]
-> Read InitializeResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitializeResult]
$creadListPrec :: ReadPrec [InitializeResult]
readPrec :: ReadPrec InitializeResult
$creadPrec :: ReadPrec InitializeResult
readList :: ReadS [InitializeResult]
$creadList :: ReadS [InitializeResult]
readsPrec :: Int -> ReadS InitializeResult
$creadsPrec :: Int -> ReadS InitializeResult
Read, InitializeResult -> InitializeResult -> Bool
(InitializeResult -> InitializeResult -> Bool)
-> (InitializeResult -> InitializeResult -> Bool)
-> Eq InitializeResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitializeResult -> InitializeResult -> Bool
$c/= :: InitializeResult -> InitializeResult -> Bool
== :: InitializeResult -> InitializeResult -> Bool
$c== :: InitializeResult -> InitializeResult -> Bool
Eq)
deriveJSON lspOptions ''InitializeResult
data InitializedParams =
InitializedParams
{
} deriving (Int -> InitializedParams -> ShowS
[InitializedParams] -> ShowS
InitializedParams -> String
(Int -> InitializedParams -> ShowS)
-> (InitializedParams -> String)
-> ([InitializedParams] -> ShowS)
-> Show InitializedParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitializedParams] -> ShowS
$cshowList :: [InitializedParams] -> ShowS
show :: InitializedParams -> String
$cshow :: InitializedParams -> String
showsPrec :: Int -> InitializedParams -> ShowS
$cshowsPrec :: Int -> InitializedParams -> ShowS
Show, ReadPrec [InitializedParams]
ReadPrec InitializedParams
Int -> ReadS InitializedParams
ReadS [InitializedParams]
(Int -> ReadS InitializedParams)
-> ReadS [InitializedParams]
-> ReadPrec InitializedParams
-> ReadPrec [InitializedParams]
-> Read InitializedParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitializedParams]
$creadListPrec :: ReadPrec [InitializedParams]
readPrec :: ReadPrec InitializedParams
$creadPrec :: ReadPrec InitializedParams
readList :: ReadS [InitializedParams]
$creadList :: ReadS [InitializedParams]
readsPrec :: Int -> ReadS InitializedParams
$creadsPrec :: Int -> ReadS InitializedParams
Read, InitializedParams -> InitializedParams -> Bool
(InitializedParams -> InitializedParams -> Bool)
-> (InitializedParams -> InitializedParams -> Bool)
-> Eq InitializedParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitializedParams -> InitializedParams -> Bool
$c/= :: InitializedParams -> InitializedParams -> Bool
== :: InitializedParams -> InitializedParams -> Bool
$c== :: InitializedParams -> InitializedParams -> Bool
Eq)
instance FromJSON InitializedParams where
parseJSON :: Value -> Parser InitializedParams
parseJSON (Object Object
_) = InitializedParams -> Parser InitializedParams
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitializedParams
InitializedParams
parseJSON Value
_ = Parser InitializedParams
forall a. Monoid a => a
mempty
instance ToJSON InitializedParams where
toJSON :: InitializedParams -> Value
toJSON InitializedParams
InitializedParams = Object -> Value
Object Object
forall a. Monoid a => a
mempty