{- 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.TextDocumentEdit 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 Language.LSP.Protocol.Internal.Types.AnnotatedTextEdit
import qualified Language.LSP.Protocol.Internal.Types.OptionalVersionedTextDocumentIdentifier
import qualified Language.LSP.Protocol.Internal.Types.TextEdit
import qualified Language.LSP.Protocol.Types.Common

{-|
Describes textual changes on a text document. A TextDocumentEdit describes all changes
on a document version Si and after they are applied move the document to version Si+1.
So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any
kind of ordering. However the edits must be non overlapping.
-}
data TextDocumentEdit = TextDocumentEdit 
  { {-|
  The text document to change.
  -}
  TextDocumentEdit -> OptionalVersionedTextDocumentIdentifier
_textDocument :: Language.LSP.Protocol.Internal.Types.OptionalVersionedTextDocumentIdentifier.OptionalVersionedTextDocumentIdentifier
  , {-|
  The edits to be applied.

  @since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a
  client capability.
  -}
  TextDocumentEdit -> [TextEdit |? AnnotatedTextEdit]
_edits :: [(Language.LSP.Protocol.Internal.Types.TextEdit.TextEdit Language.LSP.Protocol.Types.Common.|? Language.LSP.Protocol.Internal.Types.AnnotatedTextEdit.AnnotatedTextEdit)]
  }
  deriving stock (Int -> TextDocumentEdit -> ShowS
[TextDocumentEdit] -> ShowS
TextDocumentEdit -> String
(Int -> TextDocumentEdit -> ShowS)
-> (TextDocumentEdit -> String)
-> ([TextDocumentEdit] -> ShowS)
-> Show TextDocumentEdit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TextDocumentEdit -> ShowS
showsPrec :: Int -> TextDocumentEdit -> ShowS
$cshow :: TextDocumentEdit -> String
show :: TextDocumentEdit -> String
$cshowList :: [TextDocumentEdit] -> ShowS
showList :: [TextDocumentEdit] -> ShowS
Show, TextDocumentEdit -> TextDocumentEdit -> Bool
(TextDocumentEdit -> TextDocumentEdit -> Bool)
-> (TextDocumentEdit -> TextDocumentEdit -> Bool)
-> Eq TextDocumentEdit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TextDocumentEdit -> TextDocumentEdit -> Bool
== :: TextDocumentEdit -> TextDocumentEdit -> Bool
$c/= :: TextDocumentEdit -> TextDocumentEdit -> Bool
/= :: TextDocumentEdit -> TextDocumentEdit -> Bool
Eq, Eq TextDocumentEdit
Eq TextDocumentEdit =>
(TextDocumentEdit -> TextDocumentEdit -> Ordering)
-> (TextDocumentEdit -> TextDocumentEdit -> Bool)
-> (TextDocumentEdit -> TextDocumentEdit -> Bool)
-> (TextDocumentEdit -> TextDocumentEdit -> Bool)
-> (TextDocumentEdit -> TextDocumentEdit -> Bool)
-> (TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit)
-> (TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit)
-> Ord TextDocumentEdit
TextDocumentEdit -> TextDocumentEdit -> Bool
TextDocumentEdit -> TextDocumentEdit -> Ordering
TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit
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 :: TextDocumentEdit -> TextDocumentEdit -> Ordering
compare :: TextDocumentEdit -> TextDocumentEdit -> Ordering
$c< :: TextDocumentEdit -> TextDocumentEdit -> Bool
< :: TextDocumentEdit -> TextDocumentEdit -> Bool
$c<= :: TextDocumentEdit -> TextDocumentEdit -> Bool
<= :: TextDocumentEdit -> TextDocumentEdit -> Bool
$c> :: TextDocumentEdit -> TextDocumentEdit -> Bool
> :: TextDocumentEdit -> TextDocumentEdit -> Bool
$c>= :: TextDocumentEdit -> TextDocumentEdit -> Bool
>= :: TextDocumentEdit -> TextDocumentEdit -> Bool
$cmax :: TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit
max :: TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit
$cmin :: TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit
min :: TextDocumentEdit -> TextDocumentEdit -> TextDocumentEdit
Ord, (forall x. TextDocumentEdit -> Rep TextDocumentEdit x)
-> (forall x. Rep TextDocumentEdit x -> TextDocumentEdit)
-> Generic TextDocumentEdit
forall x. Rep TextDocumentEdit x -> TextDocumentEdit
forall x. TextDocumentEdit -> Rep TextDocumentEdit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TextDocumentEdit -> Rep TextDocumentEdit x
from :: forall x. TextDocumentEdit -> Rep TextDocumentEdit x
$cto :: forall x. Rep TextDocumentEdit x -> TextDocumentEdit
to :: forall x. Rep TextDocumentEdit x -> TextDocumentEdit
Generic)
  deriving anyclass (TextDocumentEdit -> ()
(TextDocumentEdit -> ()) -> NFData TextDocumentEdit
forall a. (a -> ()) -> NFData a
$crnf :: TextDocumentEdit -> ()
rnf :: TextDocumentEdit -> ()
NFData, Eq TextDocumentEdit
Eq TextDocumentEdit =>
(Int -> TextDocumentEdit -> Int)
-> (TextDocumentEdit -> Int) -> Hashable TextDocumentEdit
Int -> TextDocumentEdit -> Int
TextDocumentEdit -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> TextDocumentEdit -> Int
hashWithSalt :: Int -> TextDocumentEdit -> Int
$chash :: TextDocumentEdit -> Int
hash :: TextDocumentEdit -> Int
Hashable)
  deriving (forall ann. TextDocumentEdit -> Doc ann)
-> (forall ann. [TextDocumentEdit] -> Doc ann)
-> Pretty TextDocumentEdit
forall ann. [TextDocumentEdit] -> Doc ann
forall ann. TextDocumentEdit -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. TextDocumentEdit -> Doc ann
pretty :: forall ann. TextDocumentEdit -> Doc ann
$cprettyList :: forall ann. [TextDocumentEdit] -> Doc ann
prettyList :: forall ann. [TextDocumentEdit] -> Doc ann
Pretty via (ViaJSON TextDocumentEdit)

instance Aeson.ToJSON TextDocumentEdit where
  toJSON :: TextDocumentEdit -> Value
toJSON (TextDocumentEdit OptionalVersionedTextDocumentIdentifier
arg0 [TextEdit |? AnnotatedTextEdit]
arg1) = [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
"textDocument" Key -> OptionalVersionedTextDocumentIdentifier -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= OptionalVersionedTextDocumentIdentifier
arg0]
    ,[Key
"edits" Key -> [TextEdit |? AnnotatedTextEdit] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= [TextEdit |? AnnotatedTextEdit]
arg1]]

instance Aeson.FromJSON TextDocumentEdit where
  parseJSON :: Value -> Parser TextDocumentEdit
parseJSON = String
-> (Object -> Parser TextDocumentEdit)
-> Value
-> Parser TextDocumentEdit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"TextDocumentEdit" ((Object -> Parser TextDocumentEdit)
 -> Value -> Parser TextDocumentEdit)
-> (Object -> Parser TextDocumentEdit)
-> Value
-> Parser TextDocumentEdit
forall a b. (a -> b) -> a -> b
$ \Object
arg -> OptionalVersionedTextDocumentIdentifier
-> [TextEdit |? AnnotatedTextEdit] -> TextDocumentEdit
TextDocumentEdit (OptionalVersionedTextDocumentIdentifier
 -> [TextEdit |? AnnotatedTextEdit] -> TextDocumentEdit)
-> Parser OptionalVersionedTextDocumentIdentifier
-> Parser ([TextEdit |? AnnotatedTextEdit] -> TextDocumentEdit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser OptionalVersionedTextDocumentIdentifier
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"textDocument" Parser ([TextEdit |? AnnotatedTextEdit] -> TextDocumentEdit)
-> Parser [TextEdit |? AnnotatedTextEdit]
-> Parser TextDocumentEdit
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 [TextEdit |? AnnotatedTextEdit]
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"edits"