{-# 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
$creadsPrec :: Int -> ReadS SignatureHelpParameterInformation
readsPrec :: Int -> ReadS SignatureHelpParameterInformation
$creadList :: ReadS [SignatureHelpParameterInformation]
readList :: ReadS [SignatureHelpParameterInformation]
$creadPrec :: ReadPrec SignatureHelpParameterInformation
readPrec :: ReadPrec SignatureHelpParameterInformation
$creadListPrec :: ReadPrec [SignatureHelpParameterInformation]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SignatureHelpParameterInformation -> ShowS
showsPrec :: Int -> SignatureHelpParameterInformation -> ShowS
$cshow :: SignatureHelpParameterInformation -> String
show :: SignatureHelpParameterInformation -> String
$cshowList :: [SignatureHelpParameterInformation] -> ShowS
showList :: [SignatureHelpParameterInformation] -> ShowS
Show, SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
(SignatureHelpParameterInformation
 -> SignatureHelpParameterInformation -> Bool)
-> (SignatureHelpParameterInformation
    -> SignatureHelpParameterInformation -> Bool)
-> Eq SignatureHelpParameterInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
== :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
$c/= :: SignatureHelpParameterInformation
-> SignatureHelpParameterInformation -> Bool
/= :: 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
$cshowsPrec :: Int -> SignatureHelpSignatureInformation -> ShowS
showsPrec :: Int -> SignatureHelpSignatureInformation -> ShowS
$cshow :: SignatureHelpSignatureInformation -> String
show :: SignatureHelpSignatureInformation -> String
$cshowList :: [SignatureHelpSignatureInformation] -> ShowS
showList :: [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
$creadsPrec :: Int -> ReadS SignatureHelpSignatureInformation
readsPrec :: Int -> ReadS SignatureHelpSignatureInformation
$creadList :: ReadS [SignatureHelpSignatureInformation]
readList :: ReadS [SignatureHelpSignatureInformation]
$creadPrec :: ReadPrec SignatureHelpSignatureInformation
readPrec :: ReadPrec SignatureHelpSignatureInformation
$creadListPrec :: ReadPrec [SignatureHelpSignatureInformation]
readListPrec :: ReadPrec [SignatureHelpSignatureInformation]
Read, SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
(SignatureHelpSignatureInformation
 -> SignatureHelpSignatureInformation -> Bool)
-> (SignatureHelpSignatureInformation
    -> SignatureHelpSignatureInformation -> Bool)
-> Eq SignatureHelpSignatureInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
== :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
$c/= :: SignatureHelpSignatureInformation
-> SignatureHelpSignatureInformation -> Bool
/= :: 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
$cshowsPrec :: Int -> SignatureHelpClientCapabilities -> ShowS
showsPrec :: Int -> SignatureHelpClientCapabilities -> ShowS
$cshow :: SignatureHelpClientCapabilities -> String
show :: SignatureHelpClientCapabilities -> String
$cshowList :: [SignatureHelpClientCapabilities] -> ShowS
showList :: [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
$creadsPrec :: Int -> ReadS SignatureHelpClientCapabilities
readsPrec :: Int -> ReadS SignatureHelpClientCapabilities
$creadList :: ReadS [SignatureHelpClientCapabilities]
readList :: ReadS [SignatureHelpClientCapabilities]
$creadPrec :: ReadPrec SignatureHelpClientCapabilities
readPrec :: ReadPrec SignatureHelpClientCapabilities
$creadListPrec :: ReadPrec [SignatureHelpClientCapabilities]
readListPrec :: ReadPrec [SignatureHelpClientCapabilities]
Read, SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
(SignatureHelpClientCapabilities
 -> SignatureHelpClientCapabilities -> Bool)
-> (SignatureHelpClientCapabilities
    -> SignatureHelpClientCapabilities -> Bool)
-> Eq SignatureHelpClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
== :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
$c/= :: SignatureHelpClientCapabilities
-> SignatureHelpClientCapabilities -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS SignatureHelpDoc
readsPrec :: Int -> ReadS SignatureHelpDoc
$creadList :: ReadS [SignatureHelpDoc]
readList :: ReadS [SignatureHelpDoc]
$creadPrec :: ReadPrec SignatureHelpDoc
readPrec :: ReadPrec SignatureHelpDoc
$creadListPrec :: ReadPrec [SignatureHelpDoc]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SignatureHelpDoc -> ShowS
showsPrec :: Int -> SignatureHelpDoc -> ShowS
$cshow :: SignatureHelpDoc -> String
show :: SignatureHelpDoc -> String
$cshowList :: [SignatureHelpDoc] -> ShowS
showList :: [SignatureHelpDoc] -> ShowS
Show,SignatureHelpDoc -> SignatureHelpDoc -> Bool
(SignatureHelpDoc -> SignatureHelpDoc -> Bool)
-> (SignatureHelpDoc -> SignatureHelpDoc -> Bool)
-> Eq SignatureHelpDoc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
== :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
$c/= :: SignatureHelpDoc -> SignatureHelpDoc -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS ParameterLabel
readsPrec :: Int -> ReadS ParameterLabel
$creadList :: ReadS [ParameterLabel]
readList :: ReadS [ParameterLabel]
$creadPrec :: ReadPrec ParameterLabel
readPrec :: ReadPrec ParameterLabel
$creadListPrec :: ReadPrec [ParameterLabel]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> ParameterLabel -> ShowS
showsPrec :: Int -> ParameterLabel -> ShowS
$cshow :: ParameterLabel -> String
show :: ParameterLabel -> String
$cshowList :: [ParameterLabel] -> ShowS
showList :: [ParameterLabel] -> ShowS
Show,ParameterLabel -> ParameterLabel -> Bool
(ParameterLabel -> ParameterLabel -> Bool)
-> (ParameterLabel -> ParameterLabel -> Bool) -> Eq ParameterLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParameterLabel -> ParameterLabel -> Bool
== :: ParameterLabel -> ParameterLabel -> Bool
$c/= :: ParameterLabel -> ParameterLabel -> Bool
/= :: 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 a. Parser a -> Parser a -> Parser a
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 a. a -> Parser a
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 a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"ParameterLabel"
      parseInterval Value
_ = String -> Parser ParameterLabel
forall a. String -> Parser a
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
$creadsPrec :: Int -> ReadS ParameterInformation
readsPrec :: Int -> ReadS ParameterInformation
$creadList :: ReadS [ParameterInformation]
readList :: ReadS [ParameterInformation]
$creadPrec :: ReadPrec ParameterInformation
readPrec :: ReadPrec ParameterInformation
$creadListPrec :: ReadPrec [ParameterInformation]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> ParameterInformation -> ShowS
showsPrec :: Int -> ParameterInformation -> ShowS
$cshow :: ParameterInformation -> String
show :: ParameterInformation -> String
$cshowList :: [ParameterInformation] -> ShowS
showList :: [ParameterInformation] -> ShowS
Show,ParameterInformation -> ParameterInformation -> Bool
(ParameterInformation -> ParameterInformation -> Bool)
-> (ParameterInformation -> ParameterInformation -> Bool)
-> Eq ParameterInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParameterInformation -> ParameterInformation -> Bool
== :: ParameterInformation -> ParameterInformation -> Bool
$c/= :: ParameterInformation -> ParameterInformation -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS SignatureInformation
readsPrec :: Int -> ReadS SignatureInformation
$creadList :: ReadS [SignatureInformation]
readList :: ReadS [SignatureInformation]
$creadPrec :: ReadPrec SignatureInformation
readPrec :: ReadPrec SignatureInformation
$creadListPrec :: ReadPrec [SignatureInformation]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SignatureInformation -> ShowS
showsPrec :: Int -> SignatureInformation -> ShowS
$cshow :: SignatureInformation -> String
show :: SignatureInformation -> String
$cshowList :: [SignatureInformation] -> ShowS
showList :: [SignatureInformation] -> ShowS
Show,SignatureInformation -> SignatureInformation -> Bool
(SignatureInformation -> SignatureInformation -> Bool)
-> (SignatureInformation -> SignatureInformation -> Bool)
-> Eq SignatureInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureInformation -> SignatureInformation -> Bool
== :: SignatureInformation -> SignatureInformation -> Bool
$c/= :: SignatureInformation -> SignatureInformation -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS SignatureHelp
readsPrec :: Int -> ReadS SignatureHelp
$creadList :: ReadS [SignatureHelp]
readList :: ReadS [SignatureHelp]
$creadPrec :: ReadPrec SignatureHelp
readPrec :: ReadPrec SignatureHelp
$creadListPrec :: ReadPrec [SignatureHelp]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SignatureHelp -> ShowS
showsPrec :: Int -> SignatureHelp -> ShowS
$cshow :: SignatureHelp -> String
show :: SignatureHelp -> String
$cshowList :: [SignatureHelp] -> ShowS
showList :: [SignatureHelp] -> ShowS
Show,SignatureHelp -> SignatureHelp -> Bool
(SignatureHelp -> SignatureHelp -> Bool)
-> (SignatureHelp -> SignatureHelp -> Bool) -> Eq SignatureHelp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelp -> SignatureHelp -> Bool
== :: SignatureHelp -> SignatureHelp -> Bool
$c/= :: SignatureHelp -> SignatureHelp -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS SignatureHelpTriggerKind
readsPrec :: Int -> ReadS SignatureHelpTriggerKind
$creadList :: ReadS [SignatureHelpTriggerKind]
readList :: ReadS [SignatureHelpTriggerKind]
$creadPrec :: ReadPrec SignatureHelpTriggerKind
readPrec :: ReadPrec SignatureHelpTriggerKind
$creadListPrec :: ReadPrec [SignatureHelpTriggerKind]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SignatureHelpTriggerKind -> ShowS
showsPrec :: Int -> SignatureHelpTriggerKind -> ShowS
$cshow :: SignatureHelpTriggerKind -> String
show :: SignatureHelpTriggerKind -> String
$cshowList :: [SignatureHelpTriggerKind] -> ShowS
showList :: [SignatureHelpTriggerKind] -> ShowS
Show,SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
(SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool)
-> (SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool)
-> Eq SignatureHelpTriggerKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
== :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
$c/= :: SignatureHelpTriggerKind -> SignatureHelpTriggerKind -> Bool
/= :: 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 a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SignatureHelpTriggerKind
SHTKInvoked
  parseJSON (Number Scientific
2) = SignatureHelpTriggerKind -> Parser SignatureHelpTriggerKind
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SignatureHelpTriggerKind
SHTKTriggerCharacter
  parseJSON (Number Scientific
3) = SignatureHelpTriggerKind -> Parser SignatureHelpTriggerKind
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SignatureHelpTriggerKind
SHTKContentChange
  parseJSON Value
_          = String -> Parser SignatureHelpTriggerKind
forall a. String -> Parser a
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
$creadsPrec :: Int -> ReadS SignatureHelpContext
readsPrec :: Int -> ReadS SignatureHelpContext
$creadList :: ReadS [SignatureHelpContext]
readList :: ReadS [SignatureHelpContext]
$creadPrec :: ReadPrec SignatureHelpContext
readPrec :: ReadPrec SignatureHelpContext
$creadListPrec :: ReadPrec [SignatureHelpContext]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SignatureHelpContext -> ShowS
showsPrec :: Int -> SignatureHelpContext -> ShowS
$cshow :: SignatureHelpContext -> String
show :: SignatureHelpContext -> String
$cshowList :: [SignatureHelpContext] -> ShowS
showList :: [SignatureHelpContext] -> ShowS
Show,SignatureHelpContext -> SignatureHelpContext -> Bool
(SignatureHelpContext -> SignatureHelpContext -> Bool)
-> (SignatureHelpContext -> SignatureHelpContext -> Bool)
-> Eq SignatureHelpContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureHelpContext -> SignatureHelpContext -> Bool
== :: SignatureHelpContext -> SignatureHelpContext -> Bool
$c/= :: SignatureHelpContext -> SignatureHelpContext -> Bool
/= :: SignatureHelpContext -> SignatureHelpContext -> Bool
Eq)
deriveJSON lspOptions ''SignatureHelpContext

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