{- 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
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Registration] -> ShowS
$cshowList :: [Registration] -> ShowS
show :: Registration -> String
$cshow :: Registration -> String
showsPrec :: Int -> Registration -> ShowS
$cshowsPrec :: Int -> Registration -> ShowS
Show, Registration -> Registration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Registration -> Registration -> Bool
$c/= :: Registration -> Registration -> Bool
== :: Registration -> Registration -> Bool
$c== :: Registration -> Registration -> Bool
Eq, Eq 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
min :: Registration -> Registration -> Registration
$cmin :: Registration -> Registration -> Registration
max :: Registration -> Registration -> Registration
$cmax :: Registration -> Registration -> Registration
>= :: Registration -> Registration -> Bool
$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
compare :: Registration -> Registration -> Ordering
$ccompare :: Registration -> Registration -> Ordering
Ord, 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
$cto :: forall x. Rep Registration x -> Registration
$cfrom :: forall x. Registration -> Rep Registration x
Generic)
  deriving anyclass (Registration -> ()
forall a. (a -> ()) -> NFData a
rnf :: Registration -> ()
$crnf :: Registration -> ()
NFData, Eq Registration
Int -> Registration -> Int
Registration -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: Registration -> Int
$chash :: Registration -> Int
hashWithSalt :: Int -> Registration -> Int
$chashWithSalt :: Int -> Registration -> Int
Hashable)
  deriving forall ann. [Registration] -> Doc ann
forall ann. Registration -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: forall ann. [Registration] -> Doc ann
$cprettyList :: forall ann. [Registration] -> Doc ann
pretty :: forall ann. Registration -> Doc ann
$cpretty :: 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 forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$  [[Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg0]
    ,[Key
"method" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg1]
    ,String
"registerOptions" forall kv v. (KeyValue 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 = forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"Registration" forall a b. (a -> b) -> a -> b
$ \Object
arg -> Text -> Text -> Maybe Value -> Registration
Registration forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"id" forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
arg forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"method" forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
arg forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Aeson..:! Key
"registerOptions"