{- 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.CodeActionContext 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.CodeActionKind
import qualified Language.LSP.Protocol.Internal.Types.CodeActionTriggerKind
import qualified Language.LSP.Protocol.Internal.Types.Diagnostic
import qualified Language.LSP.Protocol.Types.Common

{-|
Contains additional diagnostic information about the context in which
a `CodeActionProvider.provideCodeActions` is run.
-}
data CodeActionContext = CodeActionContext 
  { {-|
  An array of diagnostics known on the client side overlapping the range provided to the
  `textDocument/codeAction` request. They are provided so that the server knows which
  errors are currently presented to the user for the given range. There is no guarantee
  that these accurately reflect the error state of the resource. The primary parameter
  to compute code actions is the provided range.
  -}
  CodeActionContext -> [Diagnostic]
_diagnostics :: [Language.LSP.Protocol.Internal.Types.Diagnostic.Diagnostic]
  , {-|
  Requested kind of actions to return.

  Actions not of this kind are filtered out by the client before being shown. So servers
  can omit computing them.
  -}
  CodeActionContext -> Maybe [CodeActionKind]
_only :: (Maybe [Language.LSP.Protocol.Internal.Types.CodeActionKind.CodeActionKind])
  , {-|
  The reason why code actions were requested.

  @since 3.17.0
  -}
  CodeActionContext -> Maybe CodeActionTriggerKind
_triggerKind :: (Maybe Language.LSP.Protocol.Internal.Types.CodeActionTriggerKind.CodeActionTriggerKind)
  }
  deriving stock (Int -> CodeActionContext -> ShowS
[CodeActionContext] -> ShowS
CodeActionContext -> String
(Int -> CodeActionContext -> ShowS)
-> (CodeActionContext -> String)
-> ([CodeActionContext] -> ShowS)
-> Show CodeActionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CodeActionContext -> ShowS
showsPrec :: Int -> CodeActionContext -> ShowS
$cshow :: CodeActionContext -> String
show :: CodeActionContext -> String
$cshowList :: [CodeActionContext] -> ShowS
showList :: [CodeActionContext] -> ShowS
Show, CodeActionContext -> CodeActionContext -> Bool
(CodeActionContext -> CodeActionContext -> Bool)
-> (CodeActionContext -> CodeActionContext -> Bool)
-> Eq CodeActionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CodeActionContext -> CodeActionContext -> Bool
== :: CodeActionContext -> CodeActionContext -> Bool
$c/= :: CodeActionContext -> CodeActionContext -> Bool
/= :: CodeActionContext -> CodeActionContext -> Bool
Eq, Eq CodeActionContext
Eq CodeActionContext =>
(CodeActionContext -> CodeActionContext -> Ordering)
-> (CodeActionContext -> CodeActionContext -> Bool)
-> (CodeActionContext -> CodeActionContext -> Bool)
-> (CodeActionContext -> CodeActionContext -> Bool)
-> (CodeActionContext -> CodeActionContext -> Bool)
-> (CodeActionContext -> CodeActionContext -> CodeActionContext)
-> (CodeActionContext -> CodeActionContext -> CodeActionContext)
-> Ord CodeActionContext
CodeActionContext -> CodeActionContext -> Bool
CodeActionContext -> CodeActionContext -> Ordering
CodeActionContext -> CodeActionContext -> CodeActionContext
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 :: CodeActionContext -> CodeActionContext -> Ordering
compare :: CodeActionContext -> CodeActionContext -> Ordering
$c< :: CodeActionContext -> CodeActionContext -> Bool
< :: CodeActionContext -> CodeActionContext -> Bool
$c<= :: CodeActionContext -> CodeActionContext -> Bool
<= :: CodeActionContext -> CodeActionContext -> Bool
$c> :: CodeActionContext -> CodeActionContext -> Bool
> :: CodeActionContext -> CodeActionContext -> Bool
$c>= :: CodeActionContext -> CodeActionContext -> Bool
>= :: CodeActionContext -> CodeActionContext -> Bool
$cmax :: CodeActionContext -> CodeActionContext -> CodeActionContext
max :: CodeActionContext -> CodeActionContext -> CodeActionContext
$cmin :: CodeActionContext -> CodeActionContext -> CodeActionContext
min :: CodeActionContext -> CodeActionContext -> CodeActionContext
Ord, (forall x. CodeActionContext -> Rep CodeActionContext x)
-> (forall x. Rep CodeActionContext x -> CodeActionContext)
-> Generic CodeActionContext
forall x. Rep CodeActionContext x -> CodeActionContext
forall x. CodeActionContext -> Rep CodeActionContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CodeActionContext -> Rep CodeActionContext x
from :: forall x. CodeActionContext -> Rep CodeActionContext x
$cto :: forall x. Rep CodeActionContext x -> CodeActionContext
to :: forall x. Rep CodeActionContext x -> CodeActionContext
Generic)
  deriving anyclass (CodeActionContext -> ()
(CodeActionContext -> ()) -> NFData CodeActionContext
forall a. (a -> ()) -> NFData a
$crnf :: CodeActionContext -> ()
rnf :: CodeActionContext -> ()
NFData, Eq CodeActionContext
Eq CodeActionContext =>
(Int -> CodeActionContext -> Int)
-> (CodeActionContext -> Int) -> Hashable CodeActionContext
Int -> CodeActionContext -> Int
CodeActionContext -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> CodeActionContext -> Int
hashWithSalt :: Int -> CodeActionContext -> Int
$chash :: CodeActionContext -> Int
hash :: CodeActionContext -> Int
Hashable)
  deriving (forall ann. CodeActionContext -> Doc ann)
-> (forall ann. [CodeActionContext] -> Doc ann)
-> Pretty CodeActionContext
forall ann. [CodeActionContext] -> Doc ann
forall ann. CodeActionContext -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. CodeActionContext -> Doc ann
pretty :: forall ann. CodeActionContext -> Doc ann
$cprettyList :: forall ann. [CodeActionContext] -> Doc ann
prettyList :: forall ann. [CodeActionContext] -> Doc ann
Pretty via (ViaJSON CodeActionContext)

instance Aeson.ToJSON CodeActionContext where
  toJSON :: CodeActionContext -> Value
toJSON (CodeActionContext [Diagnostic]
arg0 Maybe [CodeActionKind]
arg1 Maybe CodeActionTriggerKind
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
"diagnostics" Key -> [Diagnostic] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= [Diagnostic]
arg0]
    ,String
"only" String -> Maybe [CodeActionKind] -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe [CodeActionKind]
arg1
    ,String
"triggerKind" String -> Maybe CodeActionTriggerKind -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe CodeActionTriggerKind
arg2]

instance Aeson.FromJSON CodeActionContext where
  parseJSON :: Value -> Parser CodeActionContext
parseJSON = String
-> (Object -> Parser CodeActionContext)
-> Value
-> Parser CodeActionContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"CodeActionContext" ((Object -> Parser CodeActionContext)
 -> Value -> Parser CodeActionContext)
-> (Object -> Parser CodeActionContext)
-> Value
-> Parser CodeActionContext
forall a b. (a -> b) -> a -> b
$ \Object
arg -> [Diagnostic]
-> Maybe [CodeActionKind]
-> Maybe CodeActionTriggerKind
-> CodeActionContext
CodeActionContext ([Diagnostic]
 -> Maybe [CodeActionKind]
 -> Maybe CodeActionTriggerKind
 -> CodeActionContext)
-> Parser [Diagnostic]
-> Parser
     (Maybe [CodeActionKind]
      -> Maybe CodeActionTriggerKind -> CodeActionContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser [Diagnostic]
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"diagnostics" Parser
  (Maybe [CodeActionKind]
   -> Maybe CodeActionTriggerKind -> CodeActionContext)
-> Parser (Maybe [CodeActionKind])
-> Parser (Maybe CodeActionTriggerKind -> CodeActionContext)
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 [CodeActionKind])
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"only" Parser (Maybe CodeActionTriggerKind -> CodeActionContext)
-> Parser (Maybe CodeActionTriggerKind) -> Parser CodeActionContext
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 CodeActionTriggerKind)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"triggerKind"