{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Language.Haskell.LSP.Types.FoldingRange where
import qualified Data.Aeson as A
import Data.Aeson.TH
import Data.Text (Text)
import Language.Haskell.LSP.Types.Constants
import Language.Haskell.LSP.Types.List
import Language.Haskell.LSP.Types.TextDocument
import Language.Haskell.LSP.Types.Message
data FoldingRangeParams =
FoldingRangeParams
{ _textDocument :: TextDocumentIdentifier
}
deriving (Read, Show, Eq)
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
type FoldingRangeRequest = RequestMessage ClientMethod FoldingRangeParams (List FoldingRange)
type FoldingRangeResponse = ResponseMessage (List FoldingRange)