{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
module Language.LSP.Types.FoldingRange where
import qualified Data.Aeson as A
import Data.Aeson.TH
import Data.Text (Text)
import Language.LSP.Types.Progress
import Language.LSP.Types.StaticRegistrationOptions
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils
data FoldingRangeClientCapabilities =
FoldingRangeClientCapabilities
{
_dynamicRegistration :: Maybe Bool
, _rangeLimit :: Maybe Int
, _lineFoldingOnly :: Maybe Bool
} deriving (Show, Read, Eq)
deriveJSON lspOptions ''FoldingRangeClientCapabilities
makeExtendingDatatype "FoldingRangeOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''FoldingRangeOptions
makeExtendingDatatype "FoldingRangeRegistrationOptions"
[ ''TextDocumentRegistrationOptions
, ''FoldingRangeOptions
, ''StaticRegistrationOptions
] []
deriveJSON lspOptions ''FoldingRangeRegistrationOptions
makeExtendingDatatype "FoldingRangeParams"
[ ''WorkDoneProgressParams
, ''PartialResultParams
]
[("_textDocument", [t| TextDocumentIdentifier |])]
deriveJSON lspOptions ''FoldingRangeParams
data FoldingRangeKind = FoldingRangeComment
| FoldingRangeImports
| FoldingRangeRegion
| FoldingRangeUnknown Text
deriving (Read, Show, Eq)
instance A.ToJSON FoldingRangeKind where
toJSON FoldingRangeComment = A.String "comment"
toJSON FoldingRangeImports = A.String "imports"
toJSON FoldingRangeRegion = A.String "region"
toJSON (FoldingRangeUnknown x) = A.String x
instance A.FromJSON FoldingRangeKind where
parseJSON (A.String "comment") = pure FoldingRangeComment
parseJSON (A.String "imports") = pure FoldingRangeImports
parseJSON (A.String "region") = pure FoldingRangeRegion
parseJSON (A.String x) = pure (FoldingRangeUnknown x)
parseJSON _ = mempty
data FoldingRange =
FoldingRange
{
_startLine :: Int
, _startCharacter :: Maybe Int
, _endLine :: Int
, _endCharacter :: Maybe Int
, _kind :: Maybe FoldingRangeKind
}
deriving (Read, Show, Eq)
deriveJSON lspOptions ''FoldingRange