{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DuplicateRecordFields #-}
module Language.LSP.Types.DocumentSymbol where
import Data.Aeson
import Data.Aeson.TH
import Data.Scientific
import Data.Text (Text)
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Common
import Language.LSP.Types.Location
import Language.LSP.Types.Progress
import Language.LSP.Types.Utils
makeExtendingDatatype "DocumentSymbolOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''DocumentSymbolOptions
makeExtendingDatatype "DocumentSymbolRegistrationOptions"
[ ''TextDocumentRegistrationOptions
, ''DocumentSymbolOptions
] []
deriveJSON lspOptions ''DocumentSymbolRegistrationOptions
makeExtendingDatatype "DocumentSymbolParams"
[ ''WorkDoneProgressParams
, ''PartialResultParams
]
[ ("_textDocument", [t| TextDocumentIdentifier |])]
deriveJSON lspOptions ''DocumentSymbolParams
data SymbolKind
= SkFile
| SkModule
| SkNamespace
| SkPackage
| SkClass
| SkMethod
| SkProperty
| SkField
| SkConstructor
| SkEnum
| SkInterface
| SkFunction
| SkVariable
| SkConstant
| SkString
| SkNumber
| SkBoolean
| SkArray
| SkObject
| SkKey
| SkNull
| SkEnumMember
| SkStruct
| SkEvent
| SkOperator
| SkTypeParameter
| SkUnknown Scientific
deriving (Read,Show,Eq)
instance ToJSON SymbolKind where
toJSON SkFile = Number 1
toJSON SkModule = Number 2
toJSON SkNamespace = Number 3
toJSON SkPackage = Number 4
toJSON SkClass = Number 5
toJSON SkMethod = Number 6
toJSON SkProperty = Number 7
toJSON SkField = Number 8
toJSON SkConstructor = Number 9
toJSON SkEnum = Number 10
toJSON SkInterface = Number 11
toJSON SkFunction = Number 12
toJSON SkVariable = Number 13
toJSON SkConstant = Number 14
toJSON SkString = Number 15
toJSON SkNumber = Number 16
toJSON SkBoolean = Number 17
toJSON SkArray = Number 18
toJSON SkObject = Number 19
toJSON SkKey = Number 20
toJSON SkNull = Number 21
toJSON SkEnumMember = Number 22
toJSON SkStruct = Number 23
toJSON SkEvent = Number 24
toJSON SkOperator = Number 25
toJSON SkTypeParameter = Number 26
toJSON (SkUnknown x) = Number x
instance FromJSON SymbolKind where
parseJSON (Number 1) = pure SkFile
parseJSON (Number 2) = pure SkModule
parseJSON (Number 3) = pure SkNamespace
parseJSON (Number 4) = pure SkPackage
parseJSON (Number 5) = pure SkClass
parseJSON (Number 6) = pure SkMethod
parseJSON (Number 7) = pure SkProperty
parseJSON (Number 8) = pure SkField
parseJSON (Number 9) = pure SkConstructor
parseJSON (Number 10) = pure SkEnum
parseJSON (Number 11) = pure SkInterface
parseJSON (Number 12) = pure SkFunction
parseJSON (Number 13) = pure SkVariable
parseJSON (Number 14) = pure SkConstant
parseJSON (Number 15) = pure SkString
parseJSON (Number 16) = pure SkNumber
parseJSON (Number 17) = pure SkBoolean
parseJSON (Number 18) = pure SkArray
parseJSON (Number 19) = pure SkObject
parseJSON (Number 20) = pure SkKey
parseJSON (Number 21) = pure SkNull
parseJSON (Number 22) = pure SkEnumMember
parseJSON (Number 23) = pure SkStruct
parseJSON (Number 24) = pure SkEvent
parseJSON (Number 25) = pure SkOperator
parseJSON (Number 26) = pure SkTypeParameter
parseJSON (Number x) = pure (SkUnknown x)
parseJSON _ = mempty
data DocumentSymbolKindClientCapabilities =
DocumentSymbolKindClientCapabilities
{
_valueSet :: Maybe (List SymbolKind)
}
deriving (Show, Read, Eq)
deriveJSON lspOptions ''DocumentSymbolKindClientCapabilities
data DocumentSymbolClientCapabilities =
DocumentSymbolClientCapabilities
{
_dynamicRegistration :: Maybe Bool
, _symbolKind :: Maybe DocumentSymbolKindClientCapabilities
, _hierarchicalDocumentSymbolSupport :: Maybe Bool
} deriving (Show, Read, Eq)
deriveJSON lspOptions ''DocumentSymbolClientCapabilities
data DocumentSymbol =
DocumentSymbol
{ _name :: Text
, _detail :: Maybe Text
, _kind :: SymbolKind
, _deprecated :: Maybe Bool
, _range :: Range
, _selectionRange :: Range
, _children :: Maybe (List DocumentSymbol)
} deriving (Read,Show,Eq)
deriveJSON lspOptions ''DocumentSymbol
data SymbolInformation =
SymbolInformation
{ _name :: Text
, _kind :: SymbolKind
, _deprecated :: Maybe Bool
, _location :: Location
, _containerName :: Maybe Text
} deriving (Read,Show,Eq)
deriveJSON lspOptions ''SymbolInformation