{- 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.SelectionRange 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.Range
import qualified Language.LSP.Protocol.Types.Common

{-|
A selection range represents a part of a selection hierarchy. A selection range
may have a parent selection range that contains it.
-}
data SelectionRange = SelectionRange 
  { {-|
  The `Range` of this selection range.
  -}
  SelectionRange -> Range
_range :: Language.LSP.Protocol.Internal.Types.Range.Range
  , {-|
  The parent selection range containing this range. Therefore `parent.range` must contain `this.range`.
  -}
  SelectionRange -> Maybe SelectionRange
_parent :: (Maybe Language.LSP.Protocol.Internal.Types.SelectionRange.SelectionRange)
  }
  deriving stock (Int -> SelectionRange -> ShowS
[SelectionRange] -> ShowS
SelectionRange -> String
(Int -> SelectionRange -> ShowS)
-> (SelectionRange -> String)
-> ([SelectionRange] -> ShowS)
-> Show SelectionRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SelectionRange -> ShowS
showsPrec :: Int -> SelectionRange -> ShowS
$cshow :: SelectionRange -> String
show :: SelectionRange -> String
$cshowList :: [SelectionRange] -> ShowS
showList :: [SelectionRange] -> ShowS
Show, SelectionRange -> SelectionRange -> Bool
(SelectionRange -> SelectionRange -> Bool)
-> (SelectionRange -> SelectionRange -> Bool) -> Eq SelectionRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SelectionRange -> SelectionRange -> Bool
== :: SelectionRange -> SelectionRange -> Bool
$c/= :: SelectionRange -> SelectionRange -> Bool
/= :: SelectionRange -> SelectionRange -> Bool
Eq, Eq SelectionRange
Eq SelectionRange =>
(SelectionRange -> SelectionRange -> Ordering)
-> (SelectionRange -> SelectionRange -> Bool)
-> (SelectionRange -> SelectionRange -> Bool)
-> (SelectionRange -> SelectionRange -> Bool)
-> (SelectionRange -> SelectionRange -> Bool)
-> (SelectionRange -> SelectionRange -> SelectionRange)
-> (SelectionRange -> SelectionRange -> SelectionRange)
-> Ord SelectionRange
SelectionRange -> SelectionRange -> Bool
SelectionRange -> SelectionRange -> Ordering
SelectionRange -> SelectionRange -> SelectionRange
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 :: SelectionRange -> SelectionRange -> Ordering
compare :: SelectionRange -> SelectionRange -> Ordering
$c< :: SelectionRange -> SelectionRange -> Bool
< :: SelectionRange -> SelectionRange -> Bool
$c<= :: SelectionRange -> SelectionRange -> Bool
<= :: SelectionRange -> SelectionRange -> Bool
$c> :: SelectionRange -> SelectionRange -> Bool
> :: SelectionRange -> SelectionRange -> Bool
$c>= :: SelectionRange -> SelectionRange -> Bool
>= :: SelectionRange -> SelectionRange -> Bool
$cmax :: SelectionRange -> SelectionRange -> SelectionRange
max :: SelectionRange -> SelectionRange -> SelectionRange
$cmin :: SelectionRange -> SelectionRange -> SelectionRange
min :: SelectionRange -> SelectionRange -> SelectionRange
Ord, (forall x. SelectionRange -> Rep SelectionRange x)
-> (forall x. Rep SelectionRange x -> SelectionRange)
-> Generic SelectionRange
forall x. Rep SelectionRange x -> SelectionRange
forall x. SelectionRange -> Rep SelectionRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SelectionRange -> Rep SelectionRange x
from :: forall x. SelectionRange -> Rep SelectionRange x
$cto :: forall x. Rep SelectionRange x -> SelectionRange
to :: forall x. Rep SelectionRange x -> SelectionRange
Generic)
  deriving anyclass (SelectionRange -> ()
(SelectionRange -> ()) -> NFData SelectionRange
forall a. (a -> ()) -> NFData a
$crnf :: SelectionRange -> ()
rnf :: SelectionRange -> ()
NFData, Eq SelectionRange
Eq SelectionRange =>
(Int -> SelectionRange -> Int)
-> (SelectionRange -> Int) -> Hashable SelectionRange
Int -> SelectionRange -> Int
SelectionRange -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> SelectionRange -> Int
hashWithSalt :: Int -> SelectionRange -> Int
$chash :: SelectionRange -> Int
hash :: SelectionRange -> Int
Hashable)
  deriving (forall ann. SelectionRange -> Doc ann)
-> (forall ann. [SelectionRange] -> Doc ann)
-> Pretty SelectionRange
forall ann. [SelectionRange] -> Doc ann
forall ann. SelectionRange -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. SelectionRange -> Doc ann
pretty :: forall ann. SelectionRange -> Doc ann
$cprettyList :: forall ann. [SelectionRange] -> Doc ann
prettyList :: forall ann. [SelectionRange] -> Doc ann
Pretty via (ViaJSON SelectionRange)

instance Aeson.ToJSON SelectionRange where
  toJSON :: SelectionRange -> Value
toJSON (SelectionRange Range
arg0 Maybe SelectionRange
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
"range" Key -> Range -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Range
arg0]
    ,String
"parent" String -> Maybe SelectionRange -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe SelectionRange
arg1]

instance Aeson.FromJSON SelectionRange where
  parseJSON :: Value -> Parser SelectionRange
parseJSON = String
-> (Object -> Parser SelectionRange)
-> Value
-> Parser SelectionRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"SelectionRange" ((Object -> Parser SelectionRange)
 -> Value -> Parser SelectionRange)
-> (Object -> Parser SelectionRange)
-> Value
-> Parser SelectionRange
forall a b. (a -> b) -> a -> b
$ \Object
arg -> Range -> Maybe SelectionRange -> SelectionRange
SelectionRange (Range -> Maybe SelectionRange -> SelectionRange)
-> Parser Range -> Parser (Maybe SelectionRange -> SelectionRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser Range
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"range" Parser (Maybe SelectionRange -> SelectionRange)
-> Parser (Maybe SelectionRange) -> Parser SelectionRange
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 SelectionRange)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"parent"