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

{-|
Contains additional information about the context in which a completion request is triggered.
-}
data CompletionContext = CompletionContext 
  { {-|
  How the completion was triggered.
  -}
  CompletionContext -> CompletionTriggerKind
_triggerKind :: Language.LSP.Protocol.Internal.Types.CompletionTriggerKind.CompletionTriggerKind
  , {-|
  The trigger character (a single character) that has trigger code complete.
  Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
  -}
  CompletionContext -> Maybe Text
_triggerCharacter :: (Maybe Data.Text.Text)
  }
  deriving stock (Int -> CompletionContext -> ShowS
[CompletionContext] -> ShowS
CompletionContext -> String
(Int -> CompletionContext -> ShowS)
-> (CompletionContext -> String)
-> ([CompletionContext] -> ShowS)
-> Show CompletionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CompletionContext -> ShowS
showsPrec :: Int -> CompletionContext -> ShowS
$cshow :: CompletionContext -> String
show :: CompletionContext -> String
$cshowList :: [CompletionContext] -> ShowS
showList :: [CompletionContext] -> ShowS
Show, CompletionContext -> CompletionContext -> Bool
(CompletionContext -> CompletionContext -> Bool)
-> (CompletionContext -> CompletionContext -> Bool)
-> Eq CompletionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CompletionContext -> CompletionContext -> Bool
== :: CompletionContext -> CompletionContext -> Bool
$c/= :: CompletionContext -> CompletionContext -> Bool
/= :: CompletionContext -> CompletionContext -> Bool
Eq, Eq CompletionContext
Eq CompletionContext =>
(CompletionContext -> CompletionContext -> Ordering)
-> (CompletionContext -> CompletionContext -> Bool)
-> (CompletionContext -> CompletionContext -> Bool)
-> (CompletionContext -> CompletionContext -> Bool)
-> (CompletionContext -> CompletionContext -> Bool)
-> (CompletionContext -> CompletionContext -> CompletionContext)
-> (CompletionContext -> CompletionContext -> CompletionContext)
-> Ord CompletionContext
CompletionContext -> CompletionContext -> Bool
CompletionContext -> CompletionContext -> Ordering
CompletionContext -> CompletionContext -> CompletionContext
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 :: CompletionContext -> CompletionContext -> Ordering
compare :: CompletionContext -> CompletionContext -> Ordering
$c< :: CompletionContext -> CompletionContext -> Bool
< :: CompletionContext -> CompletionContext -> Bool
$c<= :: CompletionContext -> CompletionContext -> Bool
<= :: CompletionContext -> CompletionContext -> Bool
$c> :: CompletionContext -> CompletionContext -> Bool
> :: CompletionContext -> CompletionContext -> Bool
$c>= :: CompletionContext -> CompletionContext -> Bool
>= :: CompletionContext -> CompletionContext -> Bool
$cmax :: CompletionContext -> CompletionContext -> CompletionContext
max :: CompletionContext -> CompletionContext -> CompletionContext
$cmin :: CompletionContext -> CompletionContext -> CompletionContext
min :: CompletionContext -> CompletionContext -> CompletionContext
Ord, (forall x. CompletionContext -> Rep CompletionContext x)
-> (forall x. Rep CompletionContext x -> CompletionContext)
-> Generic CompletionContext
forall x. Rep CompletionContext x -> CompletionContext
forall x. CompletionContext -> Rep CompletionContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CompletionContext -> Rep CompletionContext x
from :: forall x. CompletionContext -> Rep CompletionContext x
$cto :: forall x. Rep CompletionContext x -> CompletionContext
to :: forall x. Rep CompletionContext x -> CompletionContext
Generic)
  deriving anyclass (CompletionContext -> ()
(CompletionContext -> ()) -> NFData CompletionContext
forall a. (a -> ()) -> NFData a
$crnf :: CompletionContext -> ()
rnf :: CompletionContext -> ()
NFData, Eq CompletionContext
Eq CompletionContext =>
(Int -> CompletionContext -> Int)
-> (CompletionContext -> Int) -> Hashable CompletionContext
Int -> CompletionContext -> Int
CompletionContext -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> CompletionContext -> Int
hashWithSalt :: Int -> CompletionContext -> Int
$chash :: CompletionContext -> Int
hash :: CompletionContext -> Int
Hashable)
  deriving (forall ann. CompletionContext -> Doc ann)
-> (forall ann. [CompletionContext] -> Doc ann)
-> Pretty CompletionContext
forall ann. [CompletionContext] -> Doc ann
forall ann. CompletionContext -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. CompletionContext -> Doc ann
pretty :: forall ann. CompletionContext -> Doc ann
$cprettyList :: forall ann. [CompletionContext] -> Doc ann
prettyList :: forall ann. [CompletionContext] -> Doc ann
Pretty via (ViaJSON CompletionContext)

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

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