{- ORMOLU_DISABLE -}
{- HLINT ignore -}
-- THIS IS A GENERATED FILE, DO NOT EDIT

{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# OPTIONS_GHC -Wno-deprecations #-}
module Language.LSP.Protocol.Internal.Types.Registration where

import Control.DeepSeq
import Data.Hashable
import GHC.Generics
import Language.LSP.Protocol.Utils.Misc
import Prettyprinter
import qualified Data.Aeson
import qualified Data.Aeson as Aeson
import qualified Data.Row.Aeson as Aeson
import qualified Data.Row.Hashable as Hashable
import qualified Data.Text
import qualified Language.LSP.Protocol.Types.Common

{-|
General parameters to to register for an notification or to register a provider.
-}
data Registration = Registration 
  { {-|
  The id used to register the request. The id can be used to deregister
  the request again.
  -}
  Registration -> Text
_id :: Data.Text.Text
  , {-|
  The method / capability to register for.
  -}
  Registration -> Text
_method :: Data.Text.Text
  , {-|
  Options necessary for the registration.
  -}
  Registration -> Maybe Value
_registerOptions :: (Maybe Data.Aeson.Value)
  }
  deriving stock (Int -> Registration -> ShowS
[Registration] -> ShowS
Registration -> String
(Int -> Registration -> ShowS)
-> (Registration -> String)
-> ([Registration] -> ShowS)
-> Show Registration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Registration -> ShowS
showsPrec :: Int -> Registration -> ShowS
$cshow :: Registration -> String
show :: Registration -> String
$cshowList :: [Registration] -> ShowS
showList :: [Registration] -> ShowS
Show, Registration -> Registration -> Bool
(Registration -> Registration -> Bool)
-> (Registration -> Registration -> Bool) -> Eq Registration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Registration -> Registration -> Bool
== :: Registration -> Registration -> Bool
$c/= :: Registration -> Registration -> Bool
/= :: Registration -> Registration -> Bool
Eq, Eq Registration
Eq Registration =>
(Registration -> Registration -> Ordering)
-> (Registration -> Registration -> Bool)
-> (Registration -> Registration -> Bool)
-> (Registration -> Registration -> Bool)
-> (Registration -> Registration -> Bool)
-> (Registration -> Registration -> Registration)
-> (Registration -> Registration -> Registration)
-> Ord Registration
Registration -> Registration -> Bool
Registration -> Registration -> Ordering
Registration -> Registration -> Registration
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
$ccompare :: Registration -> Registration -> Ordering
compare :: Registration -> Registration -> Ordering
$c< :: Registration -> Registration -> Bool
< :: Registration -> Registration -> Bool
$c<= :: Registration -> Registration -> Bool
<= :: Registration -> Registration -> Bool
$c> :: Registration -> Registration -> Bool
> :: Registration -> Registration -> Bool
$c>= :: Registration -> Registration -> Bool
>= :: Registration -> Registration -> Bool
$cmax :: Registration -> Registration -> Registration
max :: Registration -> Registration -> Registration
$cmin :: Registration -> Registration -> Registration
min :: Registration -> Registration -> Registration
Ord, (forall x. Registration -> Rep Registration x)
-> (forall x. Rep Registration x -> Registration)
-> Generic Registration
forall x. Rep Registration x -> Registration
forall x. Registration -> Rep Registration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Registration -> Rep Registration x
from :: forall x. Registration -> Rep Registration x
$cto :: forall x. Rep Registration x -> Registration
to :: forall x. Rep Registration x -> Registration
Generic)
  deriving anyclass (Registration -> ()
(Registration -> ()) -> NFData Registration
forall a. (a -> ()) -> NFData a
$crnf :: Registration -> ()
rnf :: Registration -> ()
NFData, Eq Registration
Eq Registration =>
(Int -> Registration -> Int)
-> (Registration -> Int) -> Hashable Registration
Int -> Registration -> Int
Registration -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Registration -> Int
hashWithSalt :: Int -> Registration -> Int
$chash :: Registration -> Int
hash :: Registration -> Int
Hashable)
  deriving (forall ann. Registration -> Doc ann)
-> (forall ann. [Registration] -> Doc ann) -> Pretty Registration
forall ann. [Registration] -> Doc ann
forall ann. Registration -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Registration -> Doc ann
pretty :: forall ann. Registration -> Doc ann
$cprettyList :: forall ann. [Registration] -> Doc ann
prettyList :: forall ann. [Registration] -> Doc ann
Pretty via (ViaJSON Registration)

instance Aeson.ToJSON Registration where
  toJSON :: Registration -> Value
toJSON (Registration Text
arg0 Text
arg1 Maybe Value
arg2) = [Pair] -> Value
Aeson.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[Pair]] -> [Pair]) -> [[Pair]] -> [Pair]
forall a b. (a -> b) -> a -> b
$  [[Key
"id" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg0]
    ,[Key
"method" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg1]
    ,String
"registerOptions" String -> Maybe Value -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Value
arg2]

instance Aeson.FromJSON Registration where
  parseJSON :: Value -> Parser Registration
parseJSON = String
-> (Object -> Parser Registration) -> Value -> Parser Registration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"Registration" ((Object -> Parser Registration) -> Value -> Parser Registration)
-> (Object -> Parser Registration) -> Value -> Parser Registration
forall a b. (a -> b) -> a -> b
$ \Object
arg -> Text -> Text -> Maybe Value -> Registration
Registration (Text -> Text -> Maybe Value -> Registration)
-> Parser Text -> Parser (Text -> Maybe Value -> Registration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"id" Parser (Text -> Maybe Value -> Registration)
-> Parser Text -> Parser (Maybe Value -> Registration)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
arg Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"method" Parser (Maybe Value -> Registration)
-> Parser (Maybe Value) -> Parser Registration
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
arg Object -> Key -> Parser (Maybe Value)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"registerOptions"