{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE DuplicateRecordFields #-}
module Language.LSP.Types.Formatting where

import Data.Aeson.TH
import Data.Text (Text)
import Language.LSP.Types.Common
import Language.LSP.Types.Location
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils

data DocumentFormattingClientCapabilities =
  DocumentFormattingClientCapabilities
    { -- | Whether formatting supports dynamic registration.
      DocumentFormattingClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> DocumentFormattingClientCapabilities -> ShowS
[DocumentFormattingClientCapabilities] -> ShowS
DocumentFormattingClientCapabilities -> String
(Int -> DocumentFormattingClientCapabilities -> ShowS)
-> (DocumentFormattingClientCapabilities -> String)
-> ([DocumentFormattingClientCapabilities] -> ShowS)
-> Show DocumentFormattingClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentFormattingClientCapabilities] -> ShowS
$cshowList :: [DocumentFormattingClientCapabilities] -> ShowS
show :: DocumentFormattingClientCapabilities -> String
$cshow :: DocumentFormattingClientCapabilities -> String
showsPrec :: Int -> DocumentFormattingClientCapabilities -> ShowS
$cshowsPrec :: Int -> DocumentFormattingClientCapabilities -> ShowS
Show, ReadPrec [DocumentFormattingClientCapabilities]
ReadPrec DocumentFormattingClientCapabilities
Int -> ReadS DocumentFormattingClientCapabilities
ReadS [DocumentFormattingClientCapabilities]
(Int -> ReadS DocumentFormattingClientCapabilities)
-> ReadS [DocumentFormattingClientCapabilities]
-> ReadPrec DocumentFormattingClientCapabilities
-> ReadPrec [DocumentFormattingClientCapabilities]
-> Read DocumentFormattingClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentFormattingClientCapabilities]
$creadListPrec :: ReadPrec [DocumentFormattingClientCapabilities]
readPrec :: ReadPrec DocumentFormattingClientCapabilities
$creadPrec :: ReadPrec DocumentFormattingClientCapabilities
readList :: ReadS [DocumentFormattingClientCapabilities]
$creadList :: ReadS [DocumentFormattingClientCapabilities]
readsPrec :: Int -> ReadS DocumentFormattingClientCapabilities
$creadsPrec :: Int -> ReadS DocumentFormattingClientCapabilities
Read, DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
(DocumentFormattingClientCapabilities
 -> DocumentFormattingClientCapabilities -> Bool)
-> (DocumentFormattingClientCapabilities
    -> DocumentFormattingClientCapabilities -> Bool)
-> Eq DocumentFormattingClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
$c/= :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
== :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
$c== :: DocumentFormattingClientCapabilities
-> DocumentFormattingClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentFormattingClientCapabilities

makeExtendingDatatype "DocumentFormattingOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''DocumentFormattingOptions

makeExtendingDatatype "DocumentFormattingRegistrationOptions"
  [ ''TextDocumentRegistrationOptions,
    ''DocumentFormattingOptions
  ]
  []
deriveJSON lspOptions ''DocumentFormattingRegistrationOptions

-- | Value-object describing what options formatting should use.
data FormattingOptions = FormattingOptions
  { -- | Size of a tab in spaces.
    FormattingOptions -> UInt
_tabSize :: UInt,
    -- | Prefer spaces over tabs
    FormattingOptions -> Bool
_insertSpaces :: Bool,
    -- | Trim trailing whitespace on a line.
    --
    -- Since LSP 3.15.0
    FormattingOptions -> Maybe Bool
_trimTrailingWhitespace :: Maybe Bool,
    -- | Insert a newline character at the end of the file if one does not exist.
    --
    -- Since LSP 3.15.0
    FormattingOptions -> Maybe Bool
_insertFinalNewline :: Maybe Bool,
    -- | Trim all newlines after the final newline at the end of the file.
    -- 
    -- Since LSP 3.15.0
    FormattingOptions -> Maybe Bool
_trimFinalNewlines :: Maybe Bool
    -- Note: May be more properties
  }
  deriving (ReadPrec [FormattingOptions]
ReadPrec FormattingOptions
Int -> ReadS FormattingOptions
ReadS [FormattingOptions]
(Int -> ReadS FormattingOptions)
-> ReadS [FormattingOptions]
-> ReadPrec FormattingOptions
-> ReadPrec [FormattingOptions]
-> Read FormattingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormattingOptions]
$creadListPrec :: ReadPrec [FormattingOptions]
readPrec :: ReadPrec FormattingOptions
$creadPrec :: ReadPrec FormattingOptions
readList :: ReadS [FormattingOptions]
$creadList :: ReadS [FormattingOptions]
readsPrec :: Int -> ReadS FormattingOptions
$creadsPrec :: Int -> ReadS FormattingOptions
Read, Int -> FormattingOptions -> ShowS
[FormattingOptions] -> ShowS
FormattingOptions -> String
(Int -> FormattingOptions -> ShowS)
-> (FormattingOptions -> String)
-> ([FormattingOptions] -> ShowS)
-> Show FormattingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormattingOptions] -> ShowS
$cshowList :: [FormattingOptions] -> ShowS
show :: FormattingOptions -> String
$cshow :: FormattingOptions -> String
showsPrec :: Int -> FormattingOptions -> ShowS
$cshowsPrec :: Int -> FormattingOptions -> ShowS
Show, FormattingOptions -> FormattingOptions -> Bool
(FormattingOptions -> FormattingOptions -> Bool)
-> (FormattingOptions -> FormattingOptions -> Bool)
-> Eq FormattingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormattingOptions -> FormattingOptions -> Bool
$c/= :: FormattingOptions -> FormattingOptions -> Bool
== :: FormattingOptions -> FormattingOptions -> Bool
$c== :: FormattingOptions -> FormattingOptions -> Bool
Eq)

deriveJSON lspOptions ''FormattingOptions
makeExtendingDatatype "DocumentFormattingParams" [''WorkDoneProgressParams]
  [ ("_textDocument", [t| TextDocumentIdentifier |])
  , ("_options", [t| FormattingOptions |])
  ]
deriveJSON lspOptions ''DocumentFormattingParams

-- -------------------------------------

data DocumentRangeFormattingClientCapabilities =
  DocumentRangeFormattingClientCapabilities
    { -- | Whether formatting supports dynamic registration.
      DocumentRangeFormattingClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> DocumentRangeFormattingClientCapabilities -> ShowS
[DocumentRangeFormattingClientCapabilities] -> ShowS
DocumentRangeFormattingClientCapabilities -> String
(Int -> DocumentRangeFormattingClientCapabilities -> ShowS)
-> (DocumentRangeFormattingClientCapabilities -> String)
-> ([DocumentRangeFormattingClientCapabilities] -> ShowS)
-> Show DocumentRangeFormattingClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentRangeFormattingClientCapabilities] -> ShowS
$cshowList :: [DocumentRangeFormattingClientCapabilities] -> ShowS
show :: DocumentRangeFormattingClientCapabilities -> String
$cshow :: DocumentRangeFormattingClientCapabilities -> String
showsPrec :: Int -> DocumentRangeFormattingClientCapabilities -> ShowS
$cshowsPrec :: Int -> DocumentRangeFormattingClientCapabilities -> ShowS
Show, ReadPrec [DocumentRangeFormattingClientCapabilities]
ReadPrec DocumentRangeFormattingClientCapabilities
Int -> ReadS DocumentRangeFormattingClientCapabilities
ReadS [DocumentRangeFormattingClientCapabilities]
(Int -> ReadS DocumentRangeFormattingClientCapabilities)
-> ReadS [DocumentRangeFormattingClientCapabilities]
-> ReadPrec DocumentRangeFormattingClientCapabilities
-> ReadPrec [DocumentRangeFormattingClientCapabilities]
-> Read DocumentRangeFormattingClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentRangeFormattingClientCapabilities]
$creadListPrec :: ReadPrec [DocumentRangeFormattingClientCapabilities]
readPrec :: ReadPrec DocumentRangeFormattingClientCapabilities
$creadPrec :: ReadPrec DocumentRangeFormattingClientCapabilities
readList :: ReadS [DocumentRangeFormattingClientCapabilities]
$creadList :: ReadS [DocumentRangeFormattingClientCapabilities]
readsPrec :: Int -> ReadS DocumentRangeFormattingClientCapabilities
$creadsPrec :: Int -> ReadS DocumentRangeFormattingClientCapabilities
Read, DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
(DocumentRangeFormattingClientCapabilities
 -> DocumentRangeFormattingClientCapabilities -> Bool)
-> (DocumentRangeFormattingClientCapabilities
    -> DocumentRangeFormattingClientCapabilities -> Bool)
-> Eq DocumentRangeFormattingClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
$c/= :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
== :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
$c== :: DocumentRangeFormattingClientCapabilities
-> DocumentRangeFormattingClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentRangeFormattingClientCapabilities

makeExtendingDatatype "DocumentRangeFormattingOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''DocumentRangeFormattingOptions

makeExtendingDatatype "DocumentRangeFormattingRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''DocumentRangeFormattingOptions
  ]
  []
deriveJSON lspOptions ''DocumentRangeFormattingRegistrationOptions

makeExtendingDatatype "DocumentRangeFormattingParams" [''WorkDoneProgressParams]
  [ ("_textDocument", [t| TextDocumentIdentifier |])
  , ("_range", [t| Range |])
  , ("_options", [t| FormattingOptions |])
  ]
deriveJSON lspOptions ''DocumentRangeFormattingParams

-- -------------------------------------

data DocumentOnTypeFormattingClientCapabilities =
  DocumentOnTypeFormattingClientCapabilities
    { -- | Whether formatting supports dynamic registration.
      DocumentOnTypeFormattingClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS
[DocumentOnTypeFormattingClientCapabilities] -> ShowS
DocumentOnTypeFormattingClientCapabilities -> String
(Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS)
-> (DocumentOnTypeFormattingClientCapabilities -> String)
-> ([DocumentOnTypeFormattingClientCapabilities] -> ShowS)
-> Show DocumentOnTypeFormattingClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentOnTypeFormattingClientCapabilities] -> ShowS
$cshowList :: [DocumentOnTypeFormattingClientCapabilities] -> ShowS
show :: DocumentOnTypeFormattingClientCapabilities -> String
$cshow :: DocumentOnTypeFormattingClientCapabilities -> String
showsPrec :: Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS
$cshowsPrec :: Int -> DocumentOnTypeFormattingClientCapabilities -> ShowS
Show, ReadPrec [DocumentOnTypeFormattingClientCapabilities]
ReadPrec DocumentOnTypeFormattingClientCapabilities
Int -> ReadS DocumentOnTypeFormattingClientCapabilities
ReadS [DocumentOnTypeFormattingClientCapabilities]
(Int -> ReadS DocumentOnTypeFormattingClientCapabilities)
-> ReadS [DocumentOnTypeFormattingClientCapabilities]
-> ReadPrec DocumentOnTypeFormattingClientCapabilities
-> ReadPrec [DocumentOnTypeFormattingClientCapabilities]
-> Read DocumentOnTypeFormattingClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentOnTypeFormattingClientCapabilities]
$creadListPrec :: ReadPrec [DocumentOnTypeFormattingClientCapabilities]
readPrec :: ReadPrec DocumentOnTypeFormattingClientCapabilities
$creadPrec :: ReadPrec DocumentOnTypeFormattingClientCapabilities
readList :: ReadS [DocumentOnTypeFormattingClientCapabilities]
$creadList :: ReadS [DocumentOnTypeFormattingClientCapabilities]
readsPrec :: Int -> ReadS DocumentOnTypeFormattingClientCapabilities
$creadsPrec :: Int -> ReadS DocumentOnTypeFormattingClientCapabilities
Read, DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
(DocumentOnTypeFormattingClientCapabilities
 -> DocumentOnTypeFormattingClientCapabilities -> Bool)
-> (DocumentOnTypeFormattingClientCapabilities
    -> DocumentOnTypeFormattingClientCapabilities -> Bool)
-> Eq DocumentOnTypeFormattingClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
$c/= :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
== :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
$c== :: DocumentOnTypeFormattingClientCapabilities
-> DocumentOnTypeFormattingClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentOnTypeFormattingClientCapabilities

data DocumentOnTypeFormattingOptions =
  DocumentOnTypeFormattingOptions
    { -- | A character on which formatting should be triggered, like @}@.
      DocumentOnTypeFormattingOptions -> Text
_firstTriggerCharacter :: Text
    , -- | More trigger characters.
      DocumentOnTypeFormattingOptions -> Maybe [Text]
_moreTriggerCharacter  :: Maybe [Text]
    } deriving (ReadPrec [DocumentOnTypeFormattingOptions]
ReadPrec DocumentOnTypeFormattingOptions
Int -> ReadS DocumentOnTypeFormattingOptions
ReadS [DocumentOnTypeFormattingOptions]
(Int -> ReadS DocumentOnTypeFormattingOptions)
-> ReadS [DocumentOnTypeFormattingOptions]
-> ReadPrec DocumentOnTypeFormattingOptions
-> ReadPrec [DocumentOnTypeFormattingOptions]
-> Read DocumentOnTypeFormattingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentOnTypeFormattingOptions]
$creadListPrec :: ReadPrec [DocumentOnTypeFormattingOptions]
readPrec :: ReadPrec DocumentOnTypeFormattingOptions
$creadPrec :: ReadPrec DocumentOnTypeFormattingOptions
readList :: ReadS [DocumentOnTypeFormattingOptions]
$creadList :: ReadS [DocumentOnTypeFormattingOptions]
readsPrec :: Int -> ReadS DocumentOnTypeFormattingOptions
$creadsPrec :: Int -> ReadS DocumentOnTypeFormattingOptions
Read,Int -> DocumentOnTypeFormattingOptions -> ShowS
[DocumentOnTypeFormattingOptions] -> ShowS
DocumentOnTypeFormattingOptions -> String
(Int -> DocumentOnTypeFormattingOptions -> ShowS)
-> (DocumentOnTypeFormattingOptions -> String)
-> ([DocumentOnTypeFormattingOptions] -> ShowS)
-> Show DocumentOnTypeFormattingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentOnTypeFormattingOptions] -> ShowS
$cshowList :: [DocumentOnTypeFormattingOptions] -> ShowS
show :: DocumentOnTypeFormattingOptions -> String
$cshow :: DocumentOnTypeFormattingOptions -> String
showsPrec :: Int -> DocumentOnTypeFormattingOptions -> ShowS
$cshowsPrec :: Int -> DocumentOnTypeFormattingOptions -> ShowS
Show,DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
(DocumentOnTypeFormattingOptions
 -> DocumentOnTypeFormattingOptions -> Bool)
-> (DocumentOnTypeFormattingOptions
    -> DocumentOnTypeFormattingOptions -> Bool)
-> Eq DocumentOnTypeFormattingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
$c/= :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
== :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
$c== :: DocumentOnTypeFormattingOptions
-> DocumentOnTypeFormattingOptions -> Bool
Eq)
deriveJSON lspOptions ''DocumentOnTypeFormattingOptions

makeExtendingDatatype "DocumentOnTypeFormattingRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''DocumentOnTypeFormattingOptions
  ]
  []
deriveJSON lspOptions ''DocumentOnTypeFormattingRegistrationOptions

makeExtendingDatatype "DocumentOnTypeFormattingParams" [''TextDocumentPositionParams]
  [ ("_ch", [t| Text |])
  , ("_options", [t| FormattingOptions |])
  ]
deriveJSON lspOptions ''DocumentOnTypeFormattingParams