{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# OPTIONS_GHC -Wno-deprecations #-}
module Language.LSP.Protocol.Internal.Types.FormattingOptions 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.Types.Common
data FormattingOptions = FormattingOptions
{
FormattingOptions -> UInt
_tabSize :: Language.LSP.Protocol.Types.Common.UInt
,
FormattingOptions -> Bool
_insertSpaces :: Bool
,
FormattingOptions -> Maybe Bool
_trimTrailingWhitespace :: (Maybe Bool)
,
FormattingOptions -> Maybe Bool
_insertFinalNewline :: (Maybe Bool)
,
FormattingOptions -> Maybe Bool
_trimFinalNewlines :: (Maybe Bool)
}
deriving stock (Int -> FormattingOptions -> ShowS
[FormattingOptions] -> ShowS
FormattingOptions -> String
(Int -> FormattingOptions -> ShowS)
-> (FormattingOptions -> String)
-> ([FormattingOptions] -> ShowS)
-> Show FormattingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FormattingOptions -> ShowS
showsPrec :: Int -> FormattingOptions -> ShowS
$cshow :: FormattingOptions -> String
show :: FormattingOptions -> String
$cshowList :: [FormattingOptions] -> ShowS
showList :: [FormattingOptions] -> ShowS
Show, FormattingOptions -> FormattingOptions -> Bool
(FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> Eq FormattingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FormattingOptions -> FormattingOptions -> Bool
== :: FormattingOptions -> FormattingOptions -> Bool
$c/= :: FormattingOptions -> FormattingOptions -> Bool
/= :: FormattingOptions -> FormattingOptions -> Bool
Eq, Eq FormattingOptions
Eq FormattingOptions =>
(FormattingOptions -> FormattingOptions -> Ordering)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> FormattingOptions)
-> (FormattingOptions -> FormattingOptions -> FormattingOptions)
-> Ord FormattingOptions
FormattingOptions -> FormattingOptions -> Bool
FormattingOptions -> FormattingOptions -> Ordering
FormattingOptions -> FormattingOptions -> FormattingOptions
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 :: FormattingOptions -> FormattingOptions -> Ordering
compare :: FormattingOptions -> FormattingOptions -> Ordering
$c< :: FormattingOptions -> FormattingOptions -> Bool
< :: FormattingOptions -> FormattingOptions -> Bool
$c<= :: FormattingOptions -> FormattingOptions -> Bool
<= :: FormattingOptions -> FormattingOptions -> Bool
$c> :: FormattingOptions -> FormattingOptions -> Bool
> :: FormattingOptions -> FormattingOptions -> Bool
$c>= :: FormattingOptions -> FormattingOptions -> Bool
>= :: FormattingOptions -> FormattingOptions -> Bool
$cmax :: FormattingOptions -> FormattingOptions -> FormattingOptions
max :: FormattingOptions -> FormattingOptions -> FormattingOptions
$cmin :: FormattingOptions -> FormattingOptions -> FormattingOptions
min :: FormattingOptions -> FormattingOptions -> FormattingOptions
Ord, (forall x. FormattingOptions -> Rep FormattingOptions x)
-> (forall x. Rep FormattingOptions x -> FormattingOptions)
-> Generic FormattingOptions
forall x. Rep FormattingOptions x -> FormattingOptions
forall x. FormattingOptions -> Rep FormattingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FormattingOptions -> Rep FormattingOptions x
from :: forall x. FormattingOptions -> Rep FormattingOptions x
$cto :: forall x. Rep FormattingOptions x -> FormattingOptions
to :: forall x. Rep FormattingOptions x -> FormattingOptions
Generic)
deriving anyclass (FormattingOptions -> ()
(FormattingOptions -> ()) -> NFData FormattingOptions
forall a. (a -> ()) -> NFData a
$crnf :: FormattingOptions -> ()
rnf :: FormattingOptions -> ()
NFData, Eq FormattingOptions
Eq FormattingOptions =>
(Int -> FormattingOptions -> Int)
-> (FormattingOptions -> Int) -> Hashable FormattingOptions
Int -> FormattingOptions -> Int
FormattingOptions -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FormattingOptions -> Int
hashWithSalt :: Int -> FormattingOptions -> Int
$chash :: FormattingOptions -> Int
hash :: FormattingOptions -> Int
Hashable)
deriving (forall ann. FormattingOptions -> Doc ann)
-> (forall ann. [FormattingOptions] -> Doc ann)
-> Pretty FormattingOptions
forall ann. [FormattingOptions] -> Doc ann
forall ann. FormattingOptions -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. FormattingOptions -> Doc ann
pretty :: forall ann. FormattingOptions -> Doc ann
$cprettyList :: forall ann. [FormattingOptions] -> Doc ann
prettyList :: forall ann. [FormattingOptions] -> Doc ann
Pretty via (ViaJSON FormattingOptions)
instance Aeson.ToJSON FormattingOptions where
toJSON :: FormattingOptions -> Value
toJSON (FormattingOptions UInt
arg0 Bool
arg1 Maybe Bool
arg2 Maybe Bool
arg3 Maybe Bool
arg4) = [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
"tabSize" Key -> UInt -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= UInt
arg0]
,[Key
"insertSpaces" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Bool
arg1]
,String
"trimTrailingWhitespace" String -> Maybe Bool -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Bool
arg2
,String
"insertFinalNewline" String -> Maybe Bool -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Bool
arg3
,String
"trimFinalNewlines" String -> Maybe Bool -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Bool
arg4]
instance Aeson.FromJSON FormattingOptions where
parseJSON :: Value -> Parser FormattingOptions
parseJSON = String
-> (Object -> Parser FormattingOptions)
-> Value
-> Parser FormattingOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"FormattingOptions" ((Object -> Parser FormattingOptions)
-> Value -> Parser FormattingOptions)
-> (Object -> Parser FormattingOptions)
-> Value
-> Parser FormattingOptions
forall a b. (a -> b) -> a -> b
$ \Object
arg -> UInt
-> Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> FormattingOptions
FormattingOptions (UInt
-> Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> FormattingOptions)
-> Parser UInt
-> Parser
(Bool
-> Maybe Bool -> Maybe Bool -> Maybe Bool -> FormattingOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser UInt
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"tabSize" Parser
(Bool
-> Maybe Bool -> Maybe Bool -> Maybe Bool -> FormattingOptions)
-> Parser Bool
-> Parser
(Maybe Bool -> Maybe Bool -> Maybe Bool -> FormattingOptions)
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 Bool
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"insertSpaces" Parser
(Maybe Bool -> Maybe Bool -> Maybe Bool -> FormattingOptions)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> Maybe Bool -> FormattingOptions)
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 Bool)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"trimTrailingWhitespace" Parser (Maybe Bool -> Maybe Bool -> FormattingOptions)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> FormattingOptions)
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 Bool)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"insertFinalNewline" Parser (Maybe Bool -> FormattingOptions)
-> Parser (Maybe Bool) -> Parser FormattingOptions
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 Bool)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"trimFinalNewlines"