{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
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
data SignatureHelpParameterInformation =
SignatureHelpParameterInformation
{
_labelOffsetSupport :: Maybe Bool
}
deriving (Read, Show, Eq)
deriveJSON lspOptions ''SignatureHelpParameterInformation
data SignatureHelpSignatureInformation =
SignatureHelpSignatureInformation
{
_documentationFormat :: Maybe (List MarkupKind)
, _parameterInformation :: Maybe SignatureHelpParameterInformation
}
deriving (Show, Read, Eq)
deriveJSON lspOptions ''SignatureHelpSignatureInformation
data SignatureHelpClientCapabilities =
SignatureHelpClientCapabilities
{
_dynamicRegistration :: Maybe Bool
, _signatureInformation :: Maybe SignatureHelpSignatureInformation
, _contextSupport :: Maybe Bool
} deriving (Show, Read, Eq)
deriveJSON lspOptions ''SignatureHelpClientCapabilities
makeExtendingDatatype "SignatureHelpOptions" [''WorkDoneProgressOptions]
[ ("_triggerCharacters", [t| Maybe (List String) |])
, ("_retriggerCharacters", [t| Maybe (List String) |])
]
deriveJSON lspOptions ''SignatureHelpOptions
makeExtendingDatatype "SignatureHelpRegistrationOptions"
[ ''TextDocumentRegistrationOptions
, ''SignatureHelpOptions
] []
deriveJSON lspOptions ''SignatureHelpRegistrationOptions
data ParameterInformation =
ParameterInformation
{ _label :: Text
, _documentation :: Maybe Text
} deriving (Read,Show,Eq)
deriveJSON lspOptions ''ParameterInformation
data SignatureInformation =
SignatureInformation
{ _label :: Text
, _documentation :: Maybe Text
, _parameters :: Maybe (List ParameterInformation)
} deriving (Read,Show,Eq)
deriveJSON lspOptions ''SignatureInformation
data SignatureHelp =
SignatureHelp
{ _signatures :: List SignatureInformation
, _activeSignature :: Maybe Int
, _activeParameter :: Maybe Int
} deriving (Read,Show,Eq)
deriveJSON lspOptions ''SignatureHelp
data SignatureHelpTriggerKind = SHTKInvoked
| SHTKTriggerCharacter
| SHTKContentChange
deriving (Read,Show,Eq)
instance ToJSON SignatureHelpTriggerKind where
toJSON SHTKInvoked = Number 1
toJSON SHTKTriggerCharacter = Number 2
toJSON SHTKContentChange = Number 3
instance FromJSON SignatureHelpTriggerKind where
parseJSON (Number 1) = pure SHTKInvoked
parseJSON (Number 2) = pure SHTKTriggerCharacter
parseJSON (Number 3) = pure SHTKContentChange
parseJSON _ = mempty
data SignatureHelpContext =
SignatureHelpContext
{
_triggerKind :: SignatureHelpTriggerKind
, _triggerCharacter :: Maybe String
, _isRetrigger :: Bool
, _activeSignatureHelp :: Maybe SignatureHelp
}
deriving (Read,Show,Eq)
deriveJSON lspOptions ''SignatureHelpContext
makeExtendingDatatype "SignatureHelpParams"
[ ''TextDocumentPositionParams
, ''WorkDoneProgressParams
]
[ ("_context", [t| Maybe SignatureHelpContext |])
]
deriveJSON lspOptions ''SignatureHelpParams