{- 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.Diagnostic 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.Aeson as Aeson
import qualified Data.Row.Hashable as Hashable
import qualified Data.Text
import qualified Language.LSP.Protocol.Internal.Types.CodeDescription
import qualified Language.LSP.Protocol.Internal.Types.DiagnosticRelatedInformation
import qualified Language.LSP.Protocol.Internal.Types.DiagnosticSeverity
import qualified Language.LSP.Protocol.Internal.Types.DiagnosticTag
import qualified Language.LSP.Protocol.Internal.Types.Range
import qualified Language.LSP.Protocol.Types.Common

{-|
Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
are only valid in the scope of a resource.
-}
data Diagnostic = Diagnostic 
  { {-|
  The range at which the message applies
  -}
  Diagnostic -> Range
_range :: Language.LSP.Protocol.Internal.Types.Range.Range
  , {-|
  The diagnostic's severity. Can be omitted. If omitted it is up to the
  client to interpret diagnostics as error, warning, info or hint.
  -}
  Diagnostic -> Maybe DiagnosticSeverity
_severity :: (Maybe Language.LSP.Protocol.Internal.Types.DiagnosticSeverity.DiagnosticSeverity)
  , {-|
  The diagnostic's code, which usually appear in the user interface.
  -}
  Diagnostic -> Maybe (Int32 |? Text)
_code :: (Maybe (Language.LSP.Protocol.Types.Common.Int32 Language.LSP.Protocol.Types.Common.|? Data.Text.Text))
  , {-|
  An optional property to describe the error code.
  Requires the code field (above) to be present/not null.

  @since 3.16.0
  -}
  Diagnostic -> Maybe CodeDescription
_codeDescription :: (Maybe Language.LSP.Protocol.Internal.Types.CodeDescription.CodeDescription)
  , {-|
  A human-readable string describing the source of this
  diagnostic, e.g. 'typescript' or 'super lint'. It usually
  appears in the user interface.
  -}
  Diagnostic -> Maybe Text
_source :: (Maybe Data.Text.Text)
  , {-|
  The diagnostic's message. It usually appears in the user interface
  -}
  Diagnostic -> Text
_message :: Data.Text.Text
  , {-|
  Additional metadata about the diagnostic.

  @since 3.15.0
  -}
  Diagnostic -> Maybe [DiagnosticTag]
_tags :: (Maybe [Language.LSP.Protocol.Internal.Types.DiagnosticTag.DiagnosticTag])
  , {-|
  An array of related diagnostic information, e.g. when symbol-names within
  a scope collide all definitions can be marked via this property.
  -}
  Diagnostic -> Maybe [DiagnosticRelatedInformation]
_relatedInformation :: (Maybe [Language.LSP.Protocol.Internal.Types.DiagnosticRelatedInformation.DiagnosticRelatedInformation])
  , {-|
  A data entry field that is preserved between a `textDocument/publishDiagnostics`
  notification and `textDocument/codeAction` request.

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

instance Aeson.ToJSON Diagnostic where
  toJSON :: Diagnostic -> Value
toJSON (Diagnostic Range
arg0 Maybe DiagnosticSeverity
arg1 Maybe (Int32 |? Text)
arg2 Maybe CodeDescription
arg3 Maybe Text
arg4 Text
arg5 Maybe [DiagnosticTag]
arg6 Maybe [DiagnosticRelatedInformation]
arg7 Maybe Value
arg8) = [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
"severity" String -> Maybe DiagnosticSeverity -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe DiagnosticSeverity
arg1
    ,String
"code" String -> Maybe (Int32 |? Text) -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe (Int32 |? Text)
arg2
    ,String
"codeDescription" String -> Maybe CodeDescription -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe CodeDescription
arg3
    ,String
"source" String -> Maybe Text -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe Text
arg4
    ,[Key
"message" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg5]
    ,String
"tags" String -> Maybe [DiagnosticTag] -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe [DiagnosticTag]
arg6
    ,String
"relatedInformation" String -> Maybe [DiagnosticRelatedInformation] -> [Pair]
forall e kv v.
(KeyValue e kv, ToJSON v) =>
String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe [DiagnosticRelatedInformation]
arg7
    ,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
arg8]

instance Aeson.FromJSON Diagnostic where
  parseJSON :: Value -> Parser Diagnostic
parseJSON = String
-> (Object -> Parser Diagnostic) -> Value -> Parser Diagnostic
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"Diagnostic" ((Object -> Parser Diagnostic) -> Value -> Parser Diagnostic)
-> (Object -> Parser Diagnostic) -> Value -> Parser Diagnostic
forall a b. (a -> b) -> a -> b
$ \Object
arg -> Range
-> Maybe DiagnosticSeverity
-> Maybe (Int32 |? Text)
-> Maybe CodeDescription
-> Maybe Text
-> Text
-> Maybe [DiagnosticTag]
-> Maybe [DiagnosticRelatedInformation]
-> Maybe Value
-> Diagnostic
Diagnostic (Range
 -> Maybe DiagnosticSeverity
 -> Maybe (Int32 |? Text)
 -> Maybe CodeDescription
 -> Maybe Text
 -> Text
 -> Maybe [DiagnosticTag]
 -> Maybe [DiagnosticRelatedInformation]
 -> Maybe Value
 -> Diagnostic)
-> Parser Range
-> Parser
     (Maybe DiagnosticSeverity
      -> Maybe (Int32 |? Text)
      -> Maybe CodeDescription
      -> Maybe Text
      -> Text
      -> Maybe [DiagnosticTag]
      -> Maybe [DiagnosticRelatedInformation]
      -> Maybe Value
      -> Diagnostic)
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 DiagnosticSeverity
   -> Maybe (Int32 |? Text)
   -> Maybe CodeDescription
   -> Maybe Text
   -> Text
   -> Maybe [DiagnosticTag]
   -> Maybe [DiagnosticRelatedInformation]
   -> Maybe Value
   -> Diagnostic)
-> Parser (Maybe DiagnosticSeverity)
-> Parser
     (Maybe (Int32 |? Text)
      -> Maybe CodeDescription
      -> Maybe Text
      -> Text
      -> Maybe [DiagnosticTag]
      -> Maybe [DiagnosticRelatedInformation]
      -> Maybe Value
      -> Diagnostic)
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 DiagnosticSeverity)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"severity" Parser
  (Maybe (Int32 |? Text)
   -> Maybe CodeDescription
   -> Maybe Text
   -> Text
   -> Maybe [DiagnosticTag]
   -> Maybe [DiagnosticRelatedInformation]
   -> Maybe Value
   -> Diagnostic)
-> Parser (Maybe (Int32 |? Text))
-> Parser
     (Maybe CodeDescription
      -> Maybe Text
      -> Text
      -> Maybe [DiagnosticTag]
      -> Maybe [DiagnosticRelatedInformation]
      -> Maybe Value
      -> Diagnostic)
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 (Int32 |? Text))
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"code" Parser
  (Maybe CodeDescription
   -> Maybe Text
   -> Text
   -> Maybe [DiagnosticTag]
   -> Maybe [DiagnosticRelatedInformation]
   -> Maybe Value
   -> Diagnostic)
-> Parser (Maybe CodeDescription)
-> Parser
     (Maybe Text
      -> Text
      -> Maybe [DiagnosticTag]
      -> Maybe [DiagnosticRelatedInformation]
      -> Maybe Value
      -> Diagnostic)
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 CodeDescription)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"codeDescription" Parser
  (Maybe Text
   -> Text
   -> Maybe [DiagnosticTag]
   -> Maybe [DiagnosticRelatedInformation]
   -> Maybe Value
   -> Diagnostic)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Maybe [DiagnosticTag]
      -> Maybe [DiagnosticRelatedInformation]
      -> Maybe Value
      -> Diagnostic)
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
"source" Parser
  (Text
   -> Maybe [DiagnosticTag]
   -> Maybe [DiagnosticRelatedInformation]
   -> Maybe Value
   -> Diagnostic)
-> Parser Text
-> Parser
     (Maybe [DiagnosticTag]
      -> Maybe [DiagnosticRelatedInformation]
      -> Maybe Value
      -> Diagnostic)
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 Text
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"message" Parser
  (Maybe [DiagnosticTag]
   -> Maybe [DiagnosticRelatedInformation]
   -> Maybe Value
   -> Diagnostic)
-> Parser (Maybe [DiagnosticTag])
-> Parser
     (Maybe [DiagnosticRelatedInformation] -> Maybe Value -> Diagnostic)
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 [DiagnosticTag])
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"tags" Parser
  (Maybe [DiagnosticRelatedInformation] -> Maybe Value -> Diagnostic)
-> Parser (Maybe [DiagnosticRelatedInformation])
-> Parser (Maybe Value -> Diagnostic)
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 [DiagnosticRelatedInformation])
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"relatedInformation" Parser (Maybe Value -> Diagnostic)
-> Parser (Maybe Value) -> Parser Diagnostic
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"