{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
-- | Signature Help Request
-- https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#signature-help-request
module Language.LSP.Types.SignatureHelp where
    
import Data.Aeson
import Data.Aeson.TH
import Data.Text (Text)
import Language.LSP.Types.Common
import Language.LSP.Types.MarkupContent
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils
import Control.Applicative (Alternative((<|>)))

-- -------------------------------------

data SignatureHelpParameterInformation =
  SignatureHelpParameterInformation
    { -- | The client supports processing label offsets instead of a simple
      -- label string.
      --
      -- @since 3.14.0
      SignatureHelpParameterInformation -> Maybe Bool
_labelOffsetSupport :: Maybe Bool
    }
  deriving (ReadPrec [SignatureHelpParameterInformation]
ReadPrec SignatureHelpParameterInformation
Int -> ReadS SignatureHelpParameterInformation
ReadS [SignatureHelpParameterInformation]
(Int -> ReadS SignatureHelpParameterInformation)
-> ReadS [SignatureHelpParameterInformation]
-> ReadPrec SignatureHelpParameterInformation
-> ReadPrec [SignatureHelpParameterInformation]
-> Read SignatureHelpParameterInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelpParameterInformation]
$creadListPrec :: ReadPrec [SignatureHelpParameterInformation]
readPrec :: ReadPrec SignatureHelpParameterInformation
$creadPrec :: ReadPrec SignatureHelpParameterInformation
readList :: ReadS [SignatureHelpParameterInformation]
$creadList :: ReadS [SignatureHelpParameterInformation]
readsPrec :: Int -> ReadS SignatureHelpParameterInformation
$creadsPrec :: Int -> ReadS SignatureHelpParameterInformation
Read, Int -> SignatureHelpParameterInformation -> ShowS
[SignatureHelpParameterInformation] -> ShowS
SignatureHelpParameterInformation -> String
(Int -> SignatureHelpParameterInformation -> ShowS)
-> (SignatureHelpParameterInformation -> String)
-> ([SignatureHelpParameterInformation] -> ShowS)
-> Show SignatureHelpParameterInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelpParameterInformation] -> ShowS
$cshowList :: [SignatureHelpParameterInformation] -> ShowS
show :: SignatureHelpParameterInformation -> String
$cshow :: SignatureHelpParameterInformation -> String
showsPrec :: Int -> SignatureHelpParameterInformation -> ShowS
$cshowsPrec :: Int -> SignatureHelpParameterInformation -> ShowS
Show, SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
(SignatureHelpParameterInformation
 -> SignatureHelpParameterInformation -> Bool)
-> (SignatureHelpParameterInformation
    -> SignatureHelpParameterInformation -> Bool)
-> Eq SignatureHelpParameterInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
$c/= :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
== :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
$c== :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
Eq)
deriveJSON lspOptions ''SignatureHelpParameterInformation

data SignatureHelpSignatureInformation =
  SignatureHelpSignatureInformation
    { -- | Client supports the follow content formats for the documentation
      -- property. The order describes the preferred format of the client.
      SignatureHelpSignatureInformation -> Maybe (List MarkupKind)
_documentationFormat :: Maybe (List MarkupKind)
      -- | Client capabilities specific to parameter information.
    , SignatureHelpSignatureInformation
-> Maybe SignatureHelpParameterInformation
_parameterInformation :: Maybe SignatureHelpParameterInformation
      -- | The client supports the `activeParameter` property on
      -- 'SignatureInformation' literal.
      --
      -- @since 3.16.0
    , SignatureHelpSignatureInformation -> Maybe Bool
_activeParameterSuport :: Maybe Bool
    }
  deriving (Int -> SignatureHelpSignatureInformation -> ShowS
[SignatureHelpSignatureInformation] -> ShowS
SignatureHelpSignatureInformation -> String
(Int -> SignatureHelpSignatureInformation -> ShowS)
-> (SignatureHelpSignatureInformation -> String)
-> ([SignatureHelpSignatureInformation] -> ShowS)
-> Show SignatureHelpSignatureInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelpSignatureInformation] -> ShowS
$cshowList :: [SignatureHelpSignatureInformation] -> ShowS
show :: SignatureHelpSignatureInformation -> String
$cshow :: SignatureHelpSignatureInformation -> String
showsPrec :: Int -> SignatureHelpSignatureInformation -> ShowS
$cshowsPrec :: Int -> SignatureHelpSignatureInformation -> ShowS
Show, ReadPrec [SignatureHelpSignatureInformation]
ReadPrec SignatureHelpSignatureInformation
Int -> ReadS SignatureHelpSignatureInformation
ReadS [SignatureHelpSignatureInformation]
(Int -> ReadS SignatureHelpSignatureInformation)
-> ReadS [SignatureHelpSignatureInformation]
-> ReadPrec SignatureHelpSignatureInformation
-> ReadPrec [SignatureHelpSignatureInformation]
-> Read SignatureHelpSignatureInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelpSignatureInformation]
$creadListPrec :: ReadPrec [SignatureHelpSignatureInformation]
readPrec :: ReadPrec SignatureHelpSignatureInformation
$creadPrec :: ReadPrec SignatureHelpSignatureInformation
readList :: ReadS [SignatureHelpSignatureInformation]
$creadList :: ReadS [SignatureHelpSignatureInformation]
readsPrec :: Int -> ReadS SignatureHelpSignatureInformation
$creadsPrec :: Int -> ReadS SignatureHelpSignatureInformation
Read, SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
(SignatureHelpSignatureInformation
 -> SignatureHelpSignatureInformation -> Bool)
-> (SignatureHelpSignatureInformation
    -> SignatureHelpSignatureInformation -> Bool)
-> Eq SignatureHelpSignatureInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
$c/= :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
== :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
$c== :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
Eq)

deriveJSON lspOptions ''SignatureHelpSignatureInformation

data SignatureHelpClientCapabilities =
  SignatureHelpClientCapabilities
    { -- | Whether signature help supports dynamic registration.
      SignatureHelpClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
      -- | The client supports the following 'SignatureInformation'
      -- specific properties.
    , SignatureHelpClientCapabilities
-> Maybe SignatureHelpSignatureInformation
_signatureInformation :: Maybe SignatureHelpSignatureInformation
      -- | The client supports to send additional context information for a
      -- @textDocument/signatureHelp@ request. A client that opts into
      -- contextSupport will also support the '_retriggerCharacters' on
      -- 'SignatureHelpOptions'.
      --
      -- @since 3.15.0
    , SignatureHelpClientCapabilities -> Maybe Bool
_contextSupport :: Maybe Bool
    } deriving (Int -> SignatureHelpClientCapabilities -> ShowS
[SignatureHelpClientCapabilities] -> ShowS
SignatureHelpClientCapabilities -> String
(Int -> SignatureHelpClientCapabilities -> ShowS)
-> (SignatureHelpClientCapabilities -> String)
-> ([SignatureHelpClientCapabilities] -> ShowS)
-> Show SignatureHelpClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelpClientCapabilities] -> ShowS
$cshowList :: [SignatureHelpClientCapabilities] -> ShowS
show :: SignatureHelpClientCapabilities -> String
$cshow :: SignatureHelpClientCapabilities -> String
showsPrec :: Int -> SignatureHelpClientCapabilities -> ShowS
$cshowsPrec :: Int -> SignatureHelpClientCapabilities -> ShowS
Show, ReadPrec [SignatureHelpClientCapabilities]
ReadPrec SignatureHelpClientCapabilities
Int -> ReadS SignatureHelpClientCapabilities
ReadS [SignatureHelpClientCapabilities]
(Int -> ReadS SignatureHelpClientCapabilities)
-> ReadS [SignatureHelpClientCapabilities]
-> ReadPrec SignatureHelpClientCapabilities
-> ReadPrec [SignatureHelpClientCapabilities]
-> Read SignatureHelpClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelpClientCapabilities]
$creadListPrec :: ReadPrec [SignatureHelpClientCapabilities]
readPrec :: ReadPrec SignatureHelpClientCapabilities
$creadPrec :: ReadPrec SignatureHelpClientCapabilities
readList :: ReadS [SignatureHelpClientCapabilities]
$creadList :: ReadS [SignatureHelpClientCapabilities]
readsPrec :: Int -> ReadS SignatureHelpClientCapabilities
$creadsPrec :: Int -> ReadS SignatureHelpClientCapabilities
Read, SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
(SignatureHelpClientCapabilities
 -> SignatureHelpClientCapabilities -> Bool)
-> (SignatureHelpClientCapabilities
    -> SignatureHelpClientCapabilities -> Bool)
-> Eq SignatureHelpClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
$c/= :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
== :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
$c== :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''SignatureHelpClientCapabilities

-- -------------------------------------

makeExtendingDatatype "SignatureHelpOptions" [''WorkDoneProgressOptions]
  [ ("_triggerCharacters", [t| Maybe (List Text) |])
  , ("_retriggerCharacters", [t| Maybe (List Text) |])
  ]
deriveJSON lspOptions ''SignatureHelpOptions

makeExtendingDatatype "SignatureHelpRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''SignatureHelpOptions
  ] []
deriveJSON lspOptions ''SignatureHelpRegistrationOptions

-- -------------------------------------

data SignatureHelpDoc = SignatureHelpDocString Text | SignatureHelpDocMarkup MarkupContent
  deriving (ReadPrec [SignatureHelpDoc]
ReadPrec SignatureHelpDoc
Int -> ReadS SignatureHelpDoc
ReadS [SignatureHelpDoc]
(Int -> ReadS SignatureHelpDoc)
-> ReadS [SignatureHelpDoc]
-> ReadPrec SignatureHelpDoc
-> ReadPrec [SignatureHelpDoc]
-> Read SignatureHelpDoc
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelpDoc]
$creadListPrec :: ReadPrec [SignatureHelpDoc]
readPrec :: ReadPrec SignatureHelpDoc
$creadPrec :: ReadPrec SignatureHelpDoc
readList :: ReadS [SignatureHelpDoc]
$creadList :: ReadS [SignatureHelpDoc]
readsPrec :: Int -> ReadS SignatureHelpDoc
$creadsPrec :: Int -> ReadS SignatureHelpDoc
Read,Int -> SignatureHelpDoc -> ShowS
[SignatureHelpDoc] -> ShowS
SignatureHelpDoc -> String
(Int -> SignatureHelpDoc -> ShowS)
-> (SignatureHelpDoc -> String)
-> ([SignatureHelpDoc] -> ShowS)
-> Show SignatureHelpDoc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelpDoc] -> ShowS
$cshowList :: [SignatureHelpDoc] -> ShowS
show :: SignatureHelpDoc -> String
$cshow :: SignatureHelpDoc -> String
showsPrec :: Int -> SignatureHelpDoc -> ShowS
$cshowsPrec :: Int -> SignatureHelpDoc -> ShowS
Show,SignatureHelpDoc -> SignatureHelpDoc -> Bool
(SignatureHelpDoc -> SignatureHelpDoc -> Bool)
-> (SignatureHelpDoc -> SignatureHelpDoc -> Bool)
-> Eq SignatureHelpDoc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
$c/= :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
== :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
$c== :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
Eq)

deriveJSON lspOptionsUntagged ''SignatureHelpDoc

-- -------------------------------------

data ParameterLabel = ParameterLabelString Text | ParameterLabelOffset UInt UInt
  deriving (ReadPrec [ParameterLabel]
ReadPrec ParameterLabel
Int -> ReadS ParameterLabel
ReadS [ParameterLabel]
(Int -> ReadS ParameterLabel)
-> ReadS [ParameterLabel]
-> ReadPrec ParameterLabel
-> ReadPrec [ParameterLabel]
-> Read ParameterLabel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterLabel]
$creadListPrec :: ReadPrec [ParameterLabel]
readPrec :: ReadPrec ParameterLabel
$creadPrec :: ReadPrec ParameterLabel
readList :: ReadS [ParameterLabel]
$creadList :: ReadS [ParameterLabel]
readsPrec :: Int -> ReadS ParameterLabel
$creadsPrec :: Int -> ReadS ParameterLabel
Read,Int -> ParameterLabel -> ShowS
[ParameterLabel] -> ShowS
ParameterLabel -> String
(Int -> ParameterLabel -> ShowS)
-> (ParameterLabel -> String)
-> ([ParameterLabel] -> ShowS)
-> Show ParameterLabel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterLabel] -> ShowS
$cshowList :: [ParameterLabel] -> ShowS
show :: ParameterLabel -> String
$cshow :: ParameterLabel -> String
showsPrec :: Int -> ParameterLabel -> ShowS
$cshowsPrec :: Int -> ParameterLabel -> ShowS
Show,ParameterLabel -> ParameterLabel -> Bool
(ParameterLabel -> ParameterLabel -> Bool)
-> (ParameterLabel -> ParameterLabel -> Bool) -> Eq ParameterLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterLabel -> ParameterLabel -> Bool
$c/= :: ParameterLabel -> ParameterLabel -> Bool
== :: ParameterLabel -> ParameterLabel -> Bool
$c== :: ParameterLabel -> ParameterLabel -> Bool
Eq)

instance ToJSON ParameterLabel where
  toJSON :: ParameterLabel -> Value
toJSON (ParameterLabelString Text
t) = Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
t
  toJSON (ParameterLabelOffset UInt
l UInt
h) = [UInt] -> Value
forall a. ToJSON a => a -> Value
toJSON [UInt
l, UInt
h]

instance FromJSON ParameterLabel where
  parseJSON :: Value -> Parser ParameterLabel
parseJSON Value
x = Text -> ParameterLabel
ParameterLabelString (Text -> ParameterLabel) -> Parser Text -> Parser ParameterLabel
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Text
forall a. FromJSON a => Value -> Parser a
parseJSON Value
x Parser ParameterLabel
-> Parser ParameterLabel -> Parser ParameterLabel
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Value -> Parser ParameterLabel
parseInterval Value
x
    where
      parseInterval :: Value -> Parser ParameterLabel
parseInterval v :: Value
v@(Array Array
_) = do
        [UInt]
is <- Value -> Parser [UInt]
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
        case [UInt]
is of
          [UInt
l, UInt
h] -> ParameterLabel -> Parser ParameterLabel
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParameterLabel -> Parser ParameterLabel)
-> ParameterLabel -> Parser ParameterLabel
forall a b. (a -> b) -> a -> b
$ UInt -> UInt -> ParameterLabel
ParameterLabelOffset UInt
l UInt
h
          [UInt]
_ -> String -> Parser ParameterLabel
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"ParameterLabel"
      parseInterval Value
_ = String -> Parser ParameterLabel
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"ParameterLabel"

-- -------------------------------------

{-| 
Represents a parameter of a callable-signature. A parameter can
have a label and a doc-comment.
-}
data ParameterInformation =
  ParameterInformation
    { ParameterInformation -> ParameterLabel
_label         :: ParameterLabel -- ^ The label of this parameter information.
    , ParameterInformation -> Maybe SignatureHelpDoc
_documentation :: Maybe SignatureHelpDoc -- ^ The human-readable doc-comment of this parameter.
    } deriving (ReadPrec [ParameterInformation]
ReadPrec ParameterInformation
Int -> ReadS ParameterInformation
ReadS [ParameterInformation]
(Int -> ReadS ParameterInformation)
-> ReadS [ParameterInformation]
-> ReadPrec ParameterInformation
-> ReadPrec [ParameterInformation]
-> Read ParameterInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterInformation]
$creadListPrec :: ReadPrec [ParameterInformation]
readPrec :: ReadPrec ParameterInformation
$creadPrec :: ReadPrec ParameterInformation
readList :: ReadS [ParameterInformation]
$creadList :: ReadS [ParameterInformation]
readsPrec :: Int -> ReadS ParameterInformation
$creadsPrec :: Int -> ReadS ParameterInformation
Read,Int -> ParameterInformation -> ShowS
[ParameterInformation] -> ShowS
ParameterInformation -> String
(Int -> ParameterInformation -> ShowS)
-> (ParameterInformation -> String)
-> ([ParameterInformation] -> ShowS)
-> Show ParameterInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterInformation] -> ShowS
$cshowList :: [ParameterInformation] -> ShowS
show :: ParameterInformation -> String
$cshow :: ParameterInformation -> String
showsPrec :: Int -> ParameterInformation -> ShowS
$cshowsPrec :: Int -> ParameterInformation -> ShowS
Show,ParameterInformation -> ParameterInformation -> Bool
(ParameterInformation -> ParameterInformation -> Bool)
-> (ParameterInformation -> ParameterInformation -> Bool)
-> Eq ParameterInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterInformation -> ParameterInformation -> Bool
$c/= :: ParameterInformation -> ParameterInformation -> Bool
== :: ParameterInformation -> ParameterInformation -> Bool
$c== :: ParameterInformation -> ParameterInformation -> Bool
Eq)
deriveJSON lspOptions ''ParameterInformation

-- -------------------------------------

{-|
Represents the signature of something callable. A signature
can have a label, like a function-name, a doc-comment, and
a set of parameters.
-}
data SignatureInformation =
  SignatureInformation
    { SignatureInformation -> Text
_label           :: Text -- ^ The label of the signature.
    , SignatureInformation -> Maybe SignatureHelpDoc
_documentation   :: Maybe SignatureHelpDoc -- ^ The human-readable doc-comment of this signature.
    , SignatureInformation -> Maybe (List ParameterInformation)
_parameters      :: Maybe (List ParameterInformation) -- ^ The parameters of this signature.
    , SignatureInformation -> Maybe UInt
_activeParameter :: Maybe UInt -- ^ The index of the active parameter.
    } deriving (ReadPrec [SignatureInformation]
ReadPrec SignatureInformation
Int -> ReadS SignatureInformation
ReadS [SignatureInformation]
(Int -> ReadS SignatureInformation)
-> ReadS [SignatureInformation]
-> ReadPrec SignatureInformation
-> ReadPrec [SignatureInformation]
-> Read SignatureInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureInformation]
$creadListPrec :: ReadPrec [SignatureInformation]
readPrec :: ReadPrec SignatureInformation
$creadPrec :: ReadPrec SignatureInformation
readList :: ReadS [SignatureInformation]
$creadList :: ReadS [SignatureInformation]
readsPrec :: Int -> ReadS SignatureInformation
$creadsPrec :: Int -> ReadS SignatureInformation
Read,Int -> SignatureInformation -> ShowS
[SignatureInformation] -> ShowS
SignatureInformation -> String
(Int -> SignatureInformation -> ShowS)
-> (SignatureInformation -> String)
-> ([SignatureInformation] -> ShowS)
-> Show SignatureInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureInformation] -> ShowS
$cshowList :: [SignatureInformation] -> ShowS
show :: SignatureInformation -> String
$cshow :: SignatureInformation -> String
showsPrec :: Int -> SignatureInformation -> ShowS
$cshowsPrec :: Int -> SignatureInformation -> ShowS
Show,SignatureInformation -> SignatureInformation -> Bool
(SignatureInformation -> SignatureInformation -> Bool)
-> (SignatureInformation -> SignatureInformation -> Bool)
-> Eq SignatureInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureInformation -> SignatureInformation -> Bool
$c/= :: SignatureInformation -> SignatureInformation -> Bool
== :: SignatureInformation -> SignatureInformation -> Bool
$c== :: SignatureInformation -> SignatureInformation -> Bool
Eq)

deriveJSON lspOptions ''SignatureInformation


{-|
Signature help represents the signature of something
callable. There can be multiple signature but only one
active and only one active parameter.
-}
data SignatureHelp =
  SignatureHelp
    { SignatureHelp -> List SignatureInformation
_signatures      :: List SignatureInformation -- ^ One or more signatures.
    , SignatureHelp -> Maybe UInt
_activeSignature :: Maybe UInt -- ^ The active signature.
    , SignatureHelp -> Maybe UInt
_activeParameter :: Maybe UInt -- ^ The active parameter of the active signature.
    } deriving (ReadPrec [SignatureHelp]
ReadPrec SignatureHelp
Int -> ReadS SignatureHelp
ReadS [SignatureHelp]
(Int -> ReadS SignatureHelp)
-> ReadS [SignatureHelp]
-> ReadPrec SignatureHelp
-> ReadPrec [SignatureHelp]
-> Read SignatureHelp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelp]
$creadListPrec :: ReadPrec [SignatureHelp]
readPrec :: ReadPrec SignatureHelp
$creadPrec :: ReadPrec SignatureHelp
readList :: ReadS [SignatureHelp]
$creadList :: ReadS [SignatureHelp]
readsPrec :: Int -> ReadS SignatureHelp
$creadsPrec :: Int -> ReadS SignatureHelp
Read,Int -> SignatureHelp -> ShowS
[SignatureHelp] -> ShowS
SignatureHelp -> String
(Int -> SignatureHelp -> ShowS)
-> (SignatureHelp -> String)
-> ([SignatureHelp] -> ShowS)
-> Show SignatureHelp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelp] -> ShowS
$cshowList :: [SignatureHelp] -> ShowS
show :: SignatureHelp -> String
$cshow :: SignatureHelp -> String
showsPrec :: Int -> SignatureHelp -> ShowS
$cshowsPrec :: Int -> SignatureHelp -> ShowS
Show,SignatureHelp -> SignatureHelp -> Bool
(SignatureHelp -> SignatureHelp -> Bool)
-> (SignatureHelp -> SignatureHelp -> Bool) -> Eq SignatureHelp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelp -> SignatureHelp -> Bool
$c/= :: SignatureHelp -> SignatureHelp -> Bool
== :: SignatureHelp -> SignatureHelp -> Bool
$c== :: SignatureHelp -> SignatureHelp -> Bool
Eq)

deriveJSON lspOptions ''SignatureHelp

-- -------------------------------------

-- | How a signature help was triggered.
--
-- @since 3.15.0
data SignatureHelpTriggerKind = SHTKInvoked -- ^ Signature help was invoked manually by the user or by a command.
                              | SHTKTriggerCharacter -- ^ Signature help was triggered by a trigger character.
                              | SHTKContentChange -- ^ Signature help was triggered by the cursor moving or by the document content changing.
  deriving (ReadPrec [SignatureHelpTriggerKind]
ReadPrec SignatureHelpTriggerKind
Int -> ReadS SignatureHelpTriggerKind
ReadS [SignatureHelpTriggerKind]
(Int -> ReadS SignatureHelpTriggerKind)
-> ReadS [SignatureHelpTriggerKind]
-> ReadPrec SignatureHelpTriggerKind
-> ReadPrec [SignatureHelpTriggerKind]
-> Read SignatureHelpTriggerKind
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelpTriggerKind]
$creadListPrec :: ReadPrec [SignatureHelpTriggerKind]
readPrec :: ReadPrec SignatureHelpTriggerKind
$creadPrec :: ReadPrec SignatureHelpTriggerKind
readList :: ReadS [SignatureHelpTriggerKind]
$creadList :: ReadS [SignatureHelpTriggerKind]
readsPrec :: Int -> ReadS SignatureHelpTriggerKind
$creadsPrec :: Int -> ReadS SignatureHelpTriggerKind
Read,Int -> SignatureHelpTriggerKind -> ShowS
[SignatureHelpTriggerKind] -> ShowS
SignatureHelpTriggerKind -> String
(Int -> SignatureHelpTriggerKind -> ShowS)
-> (SignatureHelpTriggerKind -> String)
-> ([SignatureHelpTriggerKind] -> ShowS)
-> Show SignatureHelpTriggerKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelpTriggerKind] -> ShowS
$cshowList :: [SignatureHelpTriggerKind] -> ShowS
show :: SignatureHelpTriggerKind -> String
$cshow :: SignatureHelpTriggerKind -> String
showsPrec :: Int -> SignatureHelpTriggerKind -> ShowS
$cshowsPrec :: Int -> SignatureHelpTriggerKind -> ShowS
Show,SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
(SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool)
-> (SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool)
-> Eq SignatureHelpTriggerKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
$c/= :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
== :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
$c== :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
Eq)

instance ToJSON SignatureHelpTriggerKind where
  toJSON :: SignatureHelpTriggerKind -> Value
toJSON SignatureHelpTriggerKind
SHTKInvoked          = Scientific -> Value
Number Scientific
1
  toJSON SignatureHelpTriggerKind
SHTKTriggerCharacter = Scientific -> Value
Number Scientific
2
  toJSON SignatureHelpTriggerKind
SHTKContentChange    = Scientific -> Value
Number Scientific
3

instance FromJSON SignatureHelpTriggerKind where
  parseJSON :: Value -> Parser SignatureHelpTriggerKind
parseJSON (Number Scientific
1) = SignatureHelpTriggerKind -> Parser SignatureHelpTriggerKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure SignatureHelpTriggerKind
SHTKInvoked
  parseJSON (Number Scientific
2) = SignatureHelpTriggerKind -> Parser SignatureHelpTriggerKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure SignatureHelpTriggerKind
SHTKTriggerCharacter
  parseJSON (Number Scientific
3) = SignatureHelpTriggerKind -> Parser SignatureHelpTriggerKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure SignatureHelpTriggerKind
SHTKContentChange
  parseJSON Value
_          = String -> Parser SignatureHelpTriggerKind
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"SignatureHelpTriggerKind"

-- | Additional information about the context in which a signature help request
-- was triggered.
--
-- @since 3.15.0
data SignatureHelpContext = 
  SignatureHelpContext
    { -- | Action that caused signature help to be triggered.
      SignatureHelpContext -> SignatureHelpTriggerKind
_triggerKind :: SignatureHelpTriggerKind
      -- | Character that caused signature help to be triggered. This is
      -- undefined when @triggerKind !==
      -- SignatureHelpTriggerKind.TriggerCharacter@
    , SignatureHelpContext -> Maybe Text
_triggerCharacter :: Maybe Text
      -- | 'True' if signature help was already showing when it was triggered.
      -- 
      -- Retriggers occur when the signature help is already active and can be
      -- caused by actions such as typing a trigger character, a cursor move, or
      -- document content changes.
    , SignatureHelpContext -> Bool
_isRetrigger :: Bool
      -- | The currently active 'SignatureHelp'.
      -- 
      -- The '_activeSignatureHelp' has its @SignatureHelp.activeSignature@
      -- field updated based on the user navigating through available
      -- signatures.
    , SignatureHelpContext -> Maybe SignatureHelp
_activeSignatureHelp :: Maybe SignatureHelp
    }
  deriving (ReadPrec [SignatureHelpContext]
ReadPrec SignatureHelpContext
Int -> ReadS SignatureHelpContext
ReadS [SignatureHelpContext]
(Int -> ReadS SignatureHelpContext)
-> ReadS [SignatureHelpContext]
-> ReadPrec SignatureHelpContext
-> ReadPrec [SignatureHelpContext]
-> Read SignatureHelpContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignatureHelpContext]
$creadListPrec :: ReadPrec [SignatureHelpContext]
readPrec :: ReadPrec SignatureHelpContext
$creadPrec :: ReadPrec SignatureHelpContext
readList :: ReadS [SignatureHelpContext]
$creadList :: ReadS [SignatureHelpContext]
readsPrec :: Int -> ReadS SignatureHelpContext
$creadsPrec :: Int -> ReadS SignatureHelpContext
Read,Int -> SignatureHelpContext -> ShowS
[SignatureHelpContext] -> ShowS
SignatureHelpContext -> String
(Int -> SignatureHelpContext -> ShowS)
-> (SignatureHelpContext -> String)
-> ([SignatureHelpContext] -> ShowS)
-> Show SignatureHelpContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignatureHelpContext] -> ShowS
$cshowList :: [SignatureHelpContext] -> ShowS
show :: SignatureHelpContext -> String
$cshow :: SignatureHelpContext -> String
showsPrec :: Int -> SignatureHelpContext -> ShowS
$cshowsPrec :: Int -> SignatureHelpContext -> ShowS
Show,SignatureHelpContext -> SignatureHelpContext -> Bool
(SignatureHelpContext -> SignatureHelpContext -> Bool)
-> (SignatureHelpContext -> SignatureHelpContext -> Bool)
-> Eq SignatureHelpContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignatureHelpContext -> SignatureHelpContext -> Bool
$c/= :: SignatureHelpContext -> SignatureHelpContext -> Bool
== :: SignatureHelpContext -> SignatureHelpContext -> Bool
$c== :: SignatureHelpContext -> SignatureHelpContext -> Bool
Eq)
deriveJSON lspOptions ''SignatureHelpContext

makeExtendingDatatype "SignatureHelpParams"
  [ ''TextDocumentPositionParams
  , ''WorkDoneProgressParams
  ]
  [ ("_context", [t| Maybe SignatureHelpContext |])
  ]
deriveJSON lspOptions ''SignatureHelpParams