{- 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.CodeAction where

import Control.DeepSeq
import Data.Hashable
import GHC.Generics
import Language.LSP.Protocol.Utils.Misc
import Prettyprinter
import qualified Data.Aeson
import qualified Data.Aeson as Aeson
import qualified Data.Row as Row
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.CodeActionKind
import qualified Language.LSP.Protocol.Internal.Types.Command
import qualified Language.LSP.Protocol.Internal.Types.Diagnostic
import qualified Language.LSP.Protocol.Internal.Types.WorkspaceEdit
import qualified Language.LSP.Protocol.Types.Common

{-|
A code action represents a change that can be performed in code, e.g. to fix a problem or
to refactor code.

A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed.
-}
data CodeAction = CodeAction 
  { {-|
  A short, human-readable, title for this code action.
  -}
  CodeAction -> Text
_title :: Data.Text.Text
  , {-|
  The kind of the code action.

  Used to filter code actions.
  -}
  CodeAction -> Maybe CodeActionKind
_kind :: (Maybe Language.LSP.Protocol.Internal.Types.CodeActionKind.CodeActionKind)
  , {-|
  The diagnostics that this code action resolves.
  -}
  CodeAction -> Maybe [Diagnostic]
_diagnostics :: (Maybe [Language.LSP.Protocol.Internal.Types.Diagnostic.Diagnostic])
  , {-|
  Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
  by keybindings.

  A quick fix should be marked preferred if it properly addresses the underlying error.
  A refactoring should be marked preferred if it is the most reasonable choice of actions to take.

  @since 3.15.0
  -}
  CodeAction -> Maybe Bool
_isPreferred :: (Maybe Bool)
  , {-|
  Marks that the code action cannot currently be applied.

  Clients should follow the following guidelines regarding disabled code actions:

    - Disabled code actions are not shown in automatic [lightbulbs](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
      code action menus.

    - Disabled actions are shown as faded out in the code action menu when the user requests a more specific type
      of code action, such as refactorings.

    - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)
      that auto applies a code action and only disabled code actions are returned, the client should show the user an
      error message with `reason` in the editor.

  @since 3.16.0
  -}
  CodeAction -> Maybe (Rec (("reason" .== Text) .+ Empty))
_disabled :: (Maybe (Row.Rec ("reason" Row..== Data.Text.Text Row..+ Row.Empty)))
  , {-|
  The workspace edit this code action performs.
  -}
  CodeAction -> Maybe WorkspaceEdit
_edit :: (Maybe Language.LSP.Protocol.Internal.Types.WorkspaceEdit.WorkspaceEdit)
  , {-|
  A command this code action executes. If a code action
  provides an edit and a command, first the edit is
  executed and then the command.
  -}
  CodeAction -> Maybe Command
_command :: (Maybe Language.LSP.Protocol.Internal.Types.Command.Command)
  , {-|
  A data entry field that is preserved on a code action between
  a `textDocument/codeAction` and a `codeAction/resolve` request.

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

instance Aeson.ToJSON CodeAction where
  toJSON :: CodeAction -> Value
toJSON (CodeAction Text
arg0 Maybe CodeActionKind
arg1 Maybe [Diagnostic]
arg2 Maybe Bool
arg3 Maybe (Rec (("reason" .== Text) .+ Empty))
arg4 Maybe WorkspaceEdit
arg5 Maybe Command
arg6 Maybe Value
arg7) = [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
"title" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg0]
    ,String
"kind" 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
"diagnostics" String -> Maybe [Diagnostic] -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe [Diagnostic]
arg2
    ,String
"isPreferred" 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
"disabled" String -> Maybe (Rec ('R '["reason" ':-> Text])) -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe (Rec (("reason" .== Text) .+ Empty))
Maybe (Rec ('R '["reason" ':-> Text]))
arg4
    ,String
"edit" String -> Maybe WorkspaceEdit -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe WorkspaceEdit
arg5
    ,String
"command" String -> Maybe Command -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Command
arg6
    ,String
"data" String -> Maybe Value -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Value
arg7]

instance Aeson.FromJSON CodeAction where
  parseJSON :: Value -> Parser CodeAction
parseJSON = String
-> (Object -> Parser CodeAction) -> Value -> Parser CodeAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"CodeAction" ((Object -> Parser CodeAction) -> Value -> Parser CodeAction)
-> (Object -> Parser CodeAction) -> Value -> Parser CodeAction
forall a b. (a -> b) -> a -> b
$ \Object
arg -> Text
-> Maybe CodeActionKind
-> Maybe [Diagnostic]
-> Maybe Bool
-> Maybe (Rec (("reason" .== Text) .+ Empty))
-> Maybe WorkspaceEdit
-> Maybe Command
-> Maybe Value
-> CodeAction
Text
-> Maybe CodeActionKind
-> Maybe [Diagnostic]
-> Maybe Bool
-> Maybe (Rec ('R '["reason" ':-> Text]))
-> Maybe WorkspaceEdit
-> Maybe Command
-> Maybe Value
-> CodeAction
CodeAction (Text
 -> Maybe CodeActionKind
 -> Maybe [Diagnostic]
 -> Maybe Bool
 -> Maybe (Rec ('R '["reason" ':-> Text]))
 -> Maybe WorkspaceEdit
 -> Maybe Command
 -> Maybe Value
 -> CodeAction)
-> Parser Text
-> Parser
     (Maybe CodeActionKind
      -> Maybe [Diagnostic]
      -> Maybe Bool
      -> Maybe (Rec ('R '["reason" ':-> Text]))
      -> Maybe WorkspaceEdit
      -> Maybe Command
      -> Maybe Value
      -> CodeAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"title" Parser
  (Maybe CodeActionKind
   -> Maybe [Diagnostic]
   -> Maybe Bool
   -> Maybe (Rec ('R '["reason" ':-> Text]))
   -> Maybe WorkspaceEdit
   -> Maybe Command
   -> Maybe Value
   -> CodeAction)
-> Parser (Maybe CodeActionKind)
-> Parser
     (Maybe [Diagnostic]
      -> Maybe Bool
      -> Maybe (Rec ('R '["reason" ':-> Text]))
      -> Maybe WorkspaceEdit
      -> Maybe Command
      -> Maybe Value
      -> CodeAction)
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
"kind" Parser
  (Maybe [Diagnostic]
   -> Maybe Bool
   -> Maybe (Rec ('R '["reason" ':-> Text]))
   -> Maybe WorkspaceEdit
   -> Maybe Command
   -> Maybe Value
   -> CodeAction)
-> Parser (Maybe [Diagnostic])
-> Parser
     (Maybe Bool
      -> Maybe (Rec ('R '["reason" ':-> Text]))
      -> Maybe WorkspaceEdit
      -> Maybe Command
      -> Maybe Value
      -> CodeAction)
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 [Diagnostic])
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"diagnostics" Parser
  (Maybe Bool
   -> Maybe (Rec ('R '["reason" ':-> Text]))
   -> Maybe WorkspaceEdit
   -> Maybe Command
   -> Maybe Value
   -> CodeAction)
-> Parser (Maybe Bool)
-> Parser
     (Maybe (Rec ('R '["reason" ':-> Text]))
      -> Maybe WorkspaceEdit
      -> Maybe Command
      -> Maybe Value
      -> CodeAction)
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
"isPreferred" Parser
  (Maybe (Rec ('R '["reason" ':-> Text]))
   -> Maybe WorkspaceEdit
   -> Maybe Command
   -> Maybe Value
   -> CodeAction)
-> Parser (Maybe (Rec ('R '["reason" ':-> Text])))
-> Parser
     (Maybe WorkspaceEdit -> Maybe Command -> Maybe Value -> CodeAction)
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 (Rec ('R '["reason" ':-> Text])))
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"disabled" Parser
  (Maybe WorkspaceEdit -> Maybe Command -> Maybe Value -> CodeAction)
-> Parser (Maybe WorkspaceEdit)
-> Parser (Maybe Command -> Maybe Value -> CodeAction)
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 WorkspaceEdit)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"edit" Parser (Maybe Command -> Maybe Value -> CodeAction)
-> Parser (Maybe Command) -> Parser (Maybe Value -> CodeAction)
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 Command)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"command" Parser (Maybe Value -> CodeAction)
-> Parser (Maybe Value) -> Parser CodeAction
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 Value)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"data"