{- 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.ColorPresentation where

import Control.DeepSeq
import Data.Hashable
import GHC.Generics
import Language.LSP.Protocol.Utils.Misc
import Prettyprinter
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.Internal.Types.TextEdit
import qualified Language.LSP.Protocol.Types.Common

{-|

-}
data ColorPresentation = ColorPresentation 
  { {-|
  The label of this color presentation. It will be shown on the color
  picker header. By default this is also the text that is inserted when selecting
  this color presentation.
  -}
  ColorPresentation -> Text
_label :: Data.Text.Text
  , {-|
  An `TextEdit` which is applied to a document when selecting
  this presentation for the color.  When `falsy` the `ColorPresentation.label`
  is used.
  -}
  ColorPresentation -> Maybe TextEdit
_textEdit :: (Maybe Language.LSP.Protocol.Internal.Types.TextEdit.TextEdit)
  , {-|
  An optional array of additional `TextEdit` that are applied when
  selecting this color presentation. Edits must not overlap with the main `ColorPresentation.textEdit` nor with themselves.
  -}
  ColorPresentation -> Maybe [TextEdit]
_additionalTextEdits :: (Maybe [Language.LSP.Protocol.Internal.Types.TextEdit.TextEdit])
  }
  deriving stock (Int -> ColorPresentation -> ShowS
[ColorPresentation] -> ShowS
ColorPresentation -> String
(Int -> ColorPresentation -> ShowS)
-> (ColorPresentation -> String)
-> ([ColorPresentation] -> ShowS)
-> Show ColorPresentation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ColorPresentation -> ShowS
showsPrec :: Int -> ColorPresentation -> ShowS
$cshow :: ColorPresentation -> String
show :: ColorPresentation -> String
$cshowList :: [ColorPresentation] -> ShowS
showList :: [ColorPresentation] -> ShowS
Show, ColorPresentation -> ColorPresentation -> Bool
(ColorPresentation -> ColorPresentation -> Bool)
-> (ColorPresentation -> ColorPresentation -> Bool)
-> Eq ColorPresentation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ColorPresentation -> ColorPresentation -> Bool
== :: ColorPresentation -> ColorPresentation -> Bool
$c/= :: ColorPresentation -> ColorPresentation -> Bool
/= :: ColorPresentation -> ColorPresentation -> Bool
Eq, Eq ColorPresentation
Eq ColorPresentation =>
(ColorPresentation -> ColorPresentation -> Ordering)
-> (ColorPresentation -> ColorPresentation -> Bool)
-> (ColorPresentation -> ColorPresentation -> Bool)
-> (ColorPresentation -> ColorPresentation -> Bool)
-> (ColorPresentation -> ColorPresentation -> Bool)
-> (ColorPresentation -> ColorPresentation -> ColorPresentation)
-> (ColorPresentation -> ColorPresentation -> ColorPresentation)
-> Ord ColorPresentation
ColorPresentation -> ColorPresentation -> Bool
ColorPresentation -> ColorPresentation -> Ordering
ColorPresentation -> ColorPresentation -> ColorPresentation
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 :: ColorPresentation -> ColorPresentation -> Ordering
compare :: ColorPresentation -> ColorPresentation -> Ordering
$c< :: ColorPresentation -> ColorPresentation -> Bool
< :: ColorPresentation -> ColorPresentation -> Bool
$c<= :: ColorPresentation -> ColorPresentation -> Bool
<= :: ColorPresentation -> ColorPresentation -> Bool
$c> :: ColorPresentation -> ColorPresentation -> Bool
> :: ColorPresentation -> ColorPresentation -> Bool
$c>= :: ColorPresentation -> ColorPresentation -> Bool
>= :: ColorPresentation -> ColorPresentation -> Bool
$cmax :: ColorPresentation -> ColorPresentation -> ColorPresentation
max :: ColorPresentation -> ColorPresentation -> ColorPresentation
$cmin :: ColorPresentation -> ColorPresentation -> ColorPresentation
min :: ColorPresentation -> ColorPresentation -> ColorPresentation
Ord, (forall x. ColorPresentation -> Rep ColorPresentation x)
-> (forall x. Rep ColorPresentation x -> ColorPresentation)
-> Generic ColorPresentation
forall x. Rep ColorPresentation x -> ColorPresentation
forall x. ColorPresentation -> Rep ColorPresentation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ColorPresentation -> Rep ColorPresentation x
from :: forall x. ColorPresentation -> Rep ColorPresentation x
$cto :: forall x. Rep ColorPresentation x -> ColorPresentation
to :: forall x. Rep ColorPresentation x -> ColorPresentation
Generic)
  deriving anyclass (ColorPresentation -> ()
(ColorPresentation -> ()) -> NFData ColorPresentation
forall a. (a -> ()) -> NFData a
$crnf :: ColorPresentation -> ()
rnf :: ColorPresentation -> ()
NFData, Eq ColorPresentation
Eq ColorPresentation =>
(Int -> ColorPresentation -> Int)
-> (ColorPresentation -> Int) -> Hashable ColorPresentation
Int -> ColorPresentation -> Int
ColorPresentation -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ColorPresentation -> Int
hashWithSalt :: Int -> ColorPresentation -> Int
$chash :: ColorPresentation -> Int
hash :: ColorPresentation -> Int
Hashable)
  deriving (forall ann. ColorPresentation -> Doc ann)
-> (forall ann. [ColorPresentation] -> Doc ann)
-> Pretty ColorPresentation
forall ann. [ColorPresentation] -> Doc ann
forall ann. ColorPresentation -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. ColorPresentation -> Doc ann
pretty :: forall ann. ColorPresentation -> Doc ann
$cprettyList :: forall ann. [ColorPresentation] -> Doc ann
prettyList :: forall ann. [ColorPresentation] -> Doc ann
Pretty via (ViaJSON ColorPresentation)

instance Aeson.ToJSON ColorPresentation where
  toJSON :: ColorPresentation -> Value
toJSON (ColorPresentation Text
arg0 Maybe TextEdit
arg1 Maybe [TextEdit]
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
"label" 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]
    ,String
"textEdit" String -> Maybe TextEdit -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe TextEdit
arg1
    ,String
"additionalTextEdits" String -> Maybe [TextEdit] -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe [TextEdit]
arg2]

instance Aeson.FromJSON ColorPresentation where
  parseJSON :: Value -> Parser ColorPresentation
parseJSON = String
-> (Object -> Parser ColorPresentation)
-> Value
-> Parser ColorPresentation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ColorPresentation" ((Object -> Parser ColorPresentation)
 -> Value -> Parser ColorPresentation)
-> (Object -> Parser ColorPresentation)
-> Value
-> Parser ColorPresentation
forall a b. (a -> b) -> a -> b
$ \Object
arg -> Text -> Maybe TextEdit -> Maybe [TextEdit] -> ColorPresentation
ColorPresentation (Text -> Maybe TextEdit -> Maybe [TextEdit] -> ColorPresentation)
-> Parser Text
-> Parser (Maybe TextEdit -> Maybe [TextEdit] -> ColorPresentation)
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
"label" Parser (Maybe TextEdit -> Maybe [TextEdit] -> ColorPresentation)
-> Parser (Maybe TextEdit)
-> Parser (Maybe [TextEdit] -> ColorPresentation)
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 TextEdit)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"textEdit" Parser (Maybe [TextEdit] -> ColorPresentation)
-> Parser (Maybe [TextEdit]) -> Parser ColorPresentation
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 [TextEdit])
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"additionalTextEdits"