{-# 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.Progress
import Language.Haskell.LSP.Types.TextDocument
import Language.Haskell.LSP.Types.Message
data FoldingRangeParams =
FoldingRangeParams
{ FoldingRangeParams -> TextDocumentIdentifier
_textDocument :: TextDocumentIdentifier
, FoldingRangeParams -> Maybe ProgressToken
_workDoneToken :: Maybe ProgressToken
}
deriving (ReadPrec [FoldingRangeParams]
ReadPrec FoldingRangeParams
Int -> ReadS FoldingRangeParams
ReadS [FoldingRangeParams]
(Int -> ReadS FoldingRangeParams)
-> ReadS [FoldingRangeParams]
-> ReadPrec FoldingRangeParams
-> ReadPrec [FoldingRangeParams]
-> Read FoldingRangeParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FoldingRangeParams]
$creadListPrec :: ReadPrec [FoldingRangeParams]
readPrec :: ReadPrec FoldingRangeParams
$creadPrec :: ReadPrec FoldingRangeParams
readList :: ReadS [FoldingRangeParams]
$creadList :: ReadS [FoldingRangeParams]
readsPrec :: Int -> ReadS FoldingRangeParams
$creadsPrec :: Int -> ReadS FoldingRangeParams
Read, Int -> FoldingRangeParams -> ShowS
[FoldingRangeParams] -> ShowS
FoldingRangeParams -> String
(Int -> FoldingRangeParams -> ShowS)
-> (FoldingRangeParams -> String)
-> ([FoldingRangeParams] -> ShowS)
-> Show FoldingRangeParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FoldingRangeParams] -> ShowS
$cshowList :: [FoldingRangeParams] -> ShowS
show :: FoldingRangeParams -> String
$cshow :: FoldingRangeParams -> String
showsPrec :: Int -> FoldingRangeParams -> ShowS
$cshowsPrec :: Int -> FoldingRangeParams -> ShowS
Show, FoldingRangeParams -> FoldingRangeParams -> Bool
(FoldingRangeParams -> FoldingRangeParams -> Bool)
-> (FoldingRangeParams -> FoldingRangeParams -> Bool)
-> Eq FoldingRangeParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FoldingRangeParams -> FoldingRangeParams -> Bool
$c/= :: FoldingRangeParams -> FoldingRangeParams -> Bool
== :: FoldingRangeParams -> FoldingRangeParams -> Bool
$c== :: FoldingRangeParams -> FoldingRangeParams -> Bool
Eq)
deriveJSON lspOptions ''FoldingRangeParams
data FoldingRangeKind =
| FoldingRangeImports
| FoldingRangeRegion
| FoldingRangeUnknown Text
deriving (ReadPrec [FoldingRangeKind]
ReadPrec FoldingRangeKind
Int -> ReadS FoldingRangeKind
ReadS [FoldingRangeKind]
(Int -> ReadS FoldingRangeKind)
-> ReadS [FoldingRangeKind]
-> ReadPrec FoldingRangeKind
-> ReadPrec [FoldingRangeKind]
-> Read FoldingRangeKind
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FoldingRangeKind]
$creadListPrec :: ReadPrec [FoldingRangeKind]
readPrec :: ReadPrec FoldingRangeKind
$creadPrec :: ReadPrec FoldingRangeKind
readList :: ReadS [FoldingRangeKind]
$creadList :: ReadS [FoldingRangeKind]
readsPrec :: Int -> ReadS FoldingRangeKind
$creadsPrec :: Int -> ReadS FoldingRangeKind
Read, Int -> FoldingRangeKind -> ShowS
[FoldingRangeKind] -> ShowS
FoldingRangeKind -> String
(Int -> FoldingRangeKind -> ShowS)
-> (FoldingRangeKind -> String)
-> ([FoldingRangeKind] -> ShowS)
-> Show FoldingRangeKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FoldingRangeKind] -> ShowS
$cshowList :: [FoldingRangeKind] -> ShowS
show :: FoldingRangeKind -> String
$cshow :: FoldingRangeKind -> String
showsPrec :: Int -> FoldingRangeKind -> ShowS
$cshowsPrec :: Int -> FoldingRangeKind -> ShowS
Show, FoldingRangeKind -> FoldingRangeKind -> Bool
(FoldingRangeKind -> FoldingRangeKind -> Bool)
-> (FoldingRangeKind -> FoldingRangeKind -> Bool)
-> Eq FoldingRangeKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FoldingRangeKind -> FoldingRangeKind -> Bool
$c/= :: FoldingRangeKind -> FoldingRangeKind -> Bool
== :: FoldingRangeKind -> FoldingRangeKind -> Bool
$c== :: FoldingRangeKind -> FoldingRangeKind -> Bool
Eq)
instance A.ToJSON FoldingRangeKind where
toJSON :: FoldingRangeKind -> Value
toJSON FoldingRangeKind
FoldingRangeComment = Text -> Value
A.String Text
"comment"
toJSON FoldingRangeKind
FoldingRangeImports = Text -> Value
A.String Text
"imports"
toJSON FoldingRangeKind
FoldingRangeRegion = Text -> Value
A.String Text
"region"
toJSON (FoldingRangeUnknown Text
x) = Text -> Value
A.String Text
x
instance A.FromJSON FoldingRangeKind where
parseJSON :: Value -> Parser FoldingRangeKind
parseJSON (A.String Text
"comment") = FoldingRangeKind -> Parser FoldingRangeKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FoldingRangeKind
FoldingRangeComment
parseJSON (A.String Text
"imports") = FoldingRangeKind -> Parser FoldingRangeKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FoldingRangeKind
FoldingRangeImports
parseJSON (A.String Text
"region") = FoldingRangeKind -> Parser FoldingRangeKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FoldingRangeKind
FoldingRangeRegion
parseJSON (A.String Text
x) = FoldingRangeKind -> Parser FoldingRangeKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> FoldingRangeKind
FoldingRangeUnknown Text
x)
parseJSON Value
_ = Parser FoldingRangeKind
forall a. Monoid a => a
mempty
data FoldingRange =
FoldingRange
{
FoldingRange -> Int
_startLine :: Int
, FoldingRange -> Maybe Int
_startCharacter :: Maybe Int
, FoldingRange -> Int
_endLine :: Int
, FoldingRange -> Maybe Int
_endCharacter :: Maybe Int
, FoldingRange -> Maybe FoldingRangeKind
_kind :: Maybe FoldingRangeKind
}
deriving (ReadPrec [FoldingRange]
ReadPrec FoldingRange
Int -> ReadS FoldingRange
ReadS [FoldingRange]
(Int -> ReadS FoldingRange)
-> ReadS [FoldingRange]
-> ReadPrec FoldingRange
-> ReadPrec [FoldingRange]
-> Read FoldingRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FoldingRange]
$creadListPrec :: ReadPrec [FoldingRange]
readPrec :: ReadPrec FoldingRange
$creadPrec :: ReadPrec FoldingRange
readList :: ReadS [FoldingRange]
$creadList :: ReadS [FoldingRange]
readsPrec :: Int -> ReadS FoldingRange
$creadsPrec :: Int -> ReadS FoldingRange
Read, Int -> FoldingRange -> ShowS
[FoldingRange] -> ShowS
FoldingRange -> String
(Int -> FoldingRange -> ShowS)
-> (FoldingRange -> String)
-> ([FoldingRange] -> ShowS)
-> Show FoldingRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FoldingRange] -> ShowS
$cshowList :: [FoldingRange] -> ShowS
show :: FoldingRange -> String
$cshow :: FoldingRange -> String
showsPrec :: Int -> FoldingRange -> ShowS
$cshowsPrec :: Int -> FoldingRange -> ShowS
Show, FoldingRange -> FoldingRange -> Bool
(FoldingRange -> FoldingRange -> Bool)
-> (FoldingRange -> FoldingRange -> Bool) -> Eq FoldingRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FoldingRange -> FoldingRange -> Bool
$c/= :: FoldingRange -> FoldingRange -> Bool
== :: FoldingRange -> FoldingRange -> Bool
$c== :: FoldingRange -> FoldingRange -> Bool
Eq)
deriveJSON lspOptions ''FoldingRange
type FoldingRangeRequest = RequestMessage ClientMethod FoldingRangeParams (List FoldingRange)
type FoldingRangeResponse = ResponseMessage (List FoldingRange)