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

import           Data.Aeson
import           Data.Aeson.TH
import           Data.Default
import           Data.Text                      ( Text )

import           Language.LSP.Types.Common
import           Language.LSP.Types.DocumentFilter
import           Language.LSP.Types.Location
import           Language.LSP.Types.Uri
import           Language.LSP.Types.Utils

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

data TextDocumentIdentifier =
  TextDocumentIdentifier
    { TextDocumentIdentifier -> Uri
_uri :: Uri
    } deriving (Int -> TextDocumentIdentifier -> ShowS
[TextDocumentIdentifier] -> ShowS
TextDocumentIdentifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentIdentifier] -> ShowS
$cshowList :: [TextDocumentIdentifier] -> ShowS
show :: TextDocumentIdentifier -> String
$cshow :: TextDocumentIdentifier -> String
showsPrec :: Int -> TextDocumentIdentifier -> ShowS
$cshowsPrec :: Int -> TextDocumentIdentifier -> ShowS
Show, ReadPrec [TextDocumentIdentifier]
ReadPrec TextDocumentIdentifier
Int -> ReadS TextDocumentIdentifier
ReadS [TextDocumentIdentifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentIdentifier]
$creadListPrec :: ReadPrec [TextDocumentIdentifier]
readPrec :: ReadPrec TextDocumentIdentifier
$creadPrec :: ReadPrec TextDocumentIdentifier
readList :: ReadS [TextDocumentIdentifier]
$creadList :: ReadS [TextDocumentIdentifier]
readsPrec :: Int -> ReadS TextDocumentIdentifier
$creadsPrec :: Int -> ReadS TextDocumentIdentifier
Read, TextDocumentIdentifier -> TextDocumentIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentIdentifier -> TextDocumentIdentifier -> Bool
$c/= :: TextDocumentIdentifier -> TextDocumentIdentifier -> Bool
== :: TextDocumentIdentifier -> TextDocumentIdentifier -> Bool
$c== :: TextDocumentIdentifier -> TextDocumentIdentifier -> Bool
Eq)
deriveJSON lspOptions ''TextDocumentIdentifier

type TextDocumentVersion = Maybe Int32

makeExtendingDatatype "VersionedTextDocumentIdentifier" [''TextDocumentIdentifier]
  [ ("_version", [t| TextDocumentVersion |])]
deriveJSON lspOptions ''VersionedTextDocumentIdentifier

data TextDocumentItem =
  TextDocumentItem {
    TextDocumentItem -> Uri
_uri        :: Uri
  , TextDocumentItem -> Text
_languageId :: Text
  , TextDocumentItem -> Int32
_version    :: Int32
  , TextDocumentItem -> Text
_text       :: Text
  } deriving (Int -> TextDocumentItem -> ShowS
[TextDocumentItem] -> ShowS
TextDocumentItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentItem] -> ShowS
$cshowList :: [TextDocumentItem] -> ShowS
show :: TextDocumentItem -> String
$cshow :: TextDocumentItem -> String
showsPrec :: Int -> TextDocumentItem -> ShowS
$cshowsPrec :: Int -> TextDocumentItem -> ShowS
Show, ReadPrec [TextDocumentItem]
ReadPrec TextDocumentItem
Int -> ReadS TextDocumentItem
ReadS [TextDocumentItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentItem]
$creadListPrec :: ReadPrec [TextDocumentItem]
readPrec :: ReadPrec TextDocumentItem
$creadPrec :: ReadPrec TextDocumentItem
readList :: ReadS [TextDocumentItem]
$creadList :: ReadS [TextDocumentItem]
readsPrec :: Int -> ReadS TextDocumentItem
$creadsPrec :: Int -> ReadS TextDocumentItem
Read, TextDocumentItem -> TextDocumentItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentItem -> TextDocumentItem -> Bool
$c/= :: TextDocumentItem -> TextDocumentItem -> Bool
== :: TextDocumentItem -> TextDocumentItem -> Bool
$c== :: TextDocumentItem -> TextDocumentItem -> Bool
Eq)

deriveJSON lspOptions ''TextDocumentItem

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

data TextDocumentPositionParams =
  TextDocumentPositionParams
    { -- | The text document.
      TextDocumentPositionParams -> TextDocumentIdentifier
_textDocument :: TextDocumentIdentifier
    , -- | The position inside the text document.
      TextDocumentPositionParams -> Position
_position     :: Position
    } deriving (Int -> TextDocumentPositionParams -> ShowS
[TextDocumentPositionParams] -> ShowS
TextDocumentPositionParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentPositionParams] -> ShowS
$cshowList :: [TextDocumentPositionParams] -> ShowS
show :: TextDocumentPositionParams -> String
$cshow :: TextDocumentPositionParams -> String
showsPrec :: Int -> TextDocumentPositionParams -> ShowS
$cshowsPrec :: Int -> TextDocumentPositionParams -> ShowS
Show, ReadPrec [TextDocumentPositionParams]
ReadPrec TextDocumentPositionParams
Int -> ReadS TextDocumentPositionParams
ReadS [TextDocumentPositionParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentPositionParams]
$creadListPrec :: ReadPrec [TextDocumentPositionParams]
readPrec :: ReadPrec TextDocumentPositionParams
$creadPrec :: ReadPrec TextDocumentPositionParams
readList :: ReadS [TextDocumentPositionParams]
$creadList :: ReadS [TextDocumentPositionParams]
readsPrec :: Int -> ReadS TextDocumentPositionParams
$creadsPrec :: Int -> ReadS TextDocumentPositionParams
Read, TextDocumentPositionParams -> TextDocumentPositionParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentPositionParams -> TextDocumentPositionParams -> Bool
$c/= :: TextDocumentPositionParams -> TextDocumentPositionParams -> Bool
== :: TextDocumentPositionParams -> TextDocumentPositionParams -> Bool
$c== :: TextDocumentPositionParams -> TextDocumentPositionParams -> Bool
Eq)

deriveJSON lspOptions ''TextDocumentPositionParams

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

-- Text document synchronisation


data TextDocumentSyncClientCapabilities =
  TextDocumentSyncClientCapabilities
    { -- | Whether text document synchronization supports dynamic registration.
      TextDocumentSyncClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool

      -- | The client supports sending will save notifications.
    , TextDocumentSyncClientCapabilities -> Maybe Bool
_willSave :: Maybe Bool

      -- | The client supports sending a will save request and waits for a
      -- response providing text edits which will be applied to the document
      -- before it is saved.
    , TextDocumentSyncClientCapabilities -> Maybe Bool
_willSaveWaitUntil :: Maybe Bool

      -- | The client supports did save notifications.
    , TextDocumentSyncClientCapabilities -> Maybe Bool
_didSave :: Maybe Bool
    } deriving (Int -> TextDocumentSyncClientCapabilities -> ShowS
[TextDocumentSyncClientCapabilities] -> ShowS
TextDocumentSyncClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentSyncClientCapabilities] -> ShowS
$cshowList :: [TextDocumentSyncClientCapabilities] -> ShowS
show :: TextDocumentSyncClientCapabilities -> String
$cshow :: TextDocumentSyncClientCapabilities -> String
showsPrec :: Int -> TextDocumentSyncClientCapabilities -> ShowS
$cshowsPrec :: Int -> TextDocumentSyncClientCapabilities -> ShowS
Show, ReadPrec [TextDocumentSyncClientCapabilities]
ReadPrec TextDocumentSyncClientCapabilities
Int -> ReadS TextDocumentSyncClientCapabilities
ReadS [TextDocumentSyncClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentSyncClientCapabilities]
$creadListPrec :: ReadPrec [TextDocumentSyncClientCapabilities]
readPrec :: ReadPrec TextDocumentSyncClientCapabilities
$creadPrec :: ReadPrec TextDocumentSyncClientCapabilities
readList :: ReadS [TextDocumentSyncClientCapabilities]
$creadList :: ReadS [TextDocumentSyncClientCapabilities]
readsPrec :: Int -> ReadS TextDocumentSyncClientCapabilities
$creadsPrec :: Int -> ReadS TextDocumentSyncClientCapabilities
Read, TextDocumentSyncClientCapabilities
-> TextDocumentSyncClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentSyncClientCapabilities
-> TextDocumentSyncClientCapabilities -> Bool
$c/= :: TextDocumentSyncClientCapabilities
-> TextDocumentSyncClientCapabilities -> Bool
== :: TextDocumentSyncClientCapabilities
-> TextDocumentSyncClientCapabilities -> Bool
$c== :: TextDocumentSyncClientCapabilities
-> TextDocumentSyncClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''TextDocumentSyncClientCapabilities

instance Default TextDocumentSyncClientCapabilities where
  def :: TextDocumentSyncClientCapabilities
def = Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> TextDocumentSyncClientCapabilities
TextDocumentSyncClientCapabilities forall a. Default a => a
def forall a. Default a => a
def forall a. Default a => a
def forall a. Default a => a
def

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

data SaveOptions =
  SaveOptions
  { -- | The client is supposed to include the content on save.
    SaveOptions -> Maybe Bool
_includeText :: Maybe Bool
  } deriving (Int -> SaveOptions -> ShowS
[SaveOptions] -> ShowS
SaveOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SaveOptions] -> ShowS
$cshowList :: [SaveOptions] -> ShowS
show :: SaveOptions -> String
$cshow :: SaveOptions -> String
showsPrec :: Int -> SaveOptions -> ShowS
$cshowsPrec :: Int -> SaveOptions -> ShowS
Show, ReadPrec [SaveOptions]
ReadPrec SaveOptions
Int -> ReadS SaveOptions
ReadS [SaveOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SaveOptions]
$creadListPrec :: ReadPrec [SaveOptions]
readPrec :: ReadPrec SaveOptions
$creadPrec :: ReadPrec SaveOptions
readList :: ReadS [SaveOptions]
$creadList :: ReadS [SaveOptions]
readsPrec :: Int -> ReadS SaveOptions
$creadsPrec :: Int -> ReadS SaveOptions
Read, SaveOptions -> SaveOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SaveOptions -> SaveOptions -> Bool
$c/= :: SaveOptions -> SaveOptions -> Bool
== :: SaveOptions -> SaveOptions -> Bool
$c== :: SaveOptions -> SaveOptions -> Bool
Eq)
deriveJSON lspOptions ''SaveOptions

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

-- | Defines how the host (editor) should sync document changes to the language server.
data TextDocumentSyncKind
  = -- | Documents should not be synced at all.
    TdSyncNone
  | -- | Documents are synced by always sending the full content of the document.
    TdSyncFull
  | -- | Documents are synced by sending the full content on open. After that only incremental updates to the document are send.
    TdSyncIncremental
  deriving (ReadPrec [TextDocumentSyncKind]
ReadPrec TextDocumentSyncKind
Int -> ReadS TextDocumentSyncKind
ReadS [TextDocumentSyncKind]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentSyncKind]
$creadListPrec :: ReadPrec [TextDocumentSyncKind]
readPrec :: ReadPrec TextDocumentSyncKind
$creadPrec :: ReadPrec TextDocumentSyncKind
readList :: ReadS [TextDocumentSyncKind]
$creadList :: ReadS [TextDocumentSyncKind]
readsPrec :: Int -> ReadS TextDocumentSyncKind
$creadsPrec :: Int -> ReadS TextDocumentSyncKind
Read, TextDocumentSyncKind -> TextDocumentSyncKind -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentSyncKind -> TextDocumentSyncKind -> Bool
$c/= :: TextDocumentSyncKind -> TextDocumentSyncKind -> Bool
== :: TextDocumentSyncKind -> TextDocumentSyncKind -> Bool
$c== :: TextDocumentSyncKind -> TextDocumentSyncKind -> Bool
Eq, Int -> TextDocumentSyncKind -> ShowS
[TextDocumentSyncKind] -> ShowS
TextDocumentSyncKind -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentSyncKind] -> ShowS
$cshowList :: [TextDocumentSyncKind] -> ShowS
show :: TextDocumentSyncKind -> String
$cshow :: TextDocumentSyncKind -> String
showsPrec :: Int -> TextDocumentSyncKind -> ShowS
$cshowsPrec :: Int -> TextDocumentSyncKind -> ShowS
Show)

instance ToJSON TextDocumentSyncKind where
  toJSON :: TextDocumentSyncKind -> Value
toJSON TextDocumentSyncKind
TdSyncNone        = Scientific -> Value
Number Scientific
0
  toJSON TextDocumentSyncKind
TdSyncFull        = Scientific -> Value
Number Scientific
1
  toJSON TextDocumentSyncKind
TdSyncIncremental = Scientific -> Value
Number Scientific
2

instance FromJSON TextDocumentSyncKind where
  parseJSON :: Value -> Parser TextDocumentSyncKind
parseJSON (Number Scientific
0) = forall (f :: * -> *) a. Applicative f => a -> f a
pure TextDocumentSyncKind
TdSyncNone
  parseJSON (Number Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure TextDocumentSyncKind
TdSyncFull
  parseJSON (Number Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure TextDocumentSyncKind
TdSyncIncremental
  parseJSON Value
_          = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"TextDocumentSyncKind"

data TextDocumentSyncOptions =
  TextDocumentSyncOptions
  { -- | Open and close notifications are sent to the server. If omitted open
    -- close notification should not be sent.
    TextDocumentSyncOptions -> Maybe Bool
_openClose :: Maybe Bool
  , -- | Change notifications are sent to the server. See
    -- TextDocumentSyncKind.None, TextDocumentSyncKind.Full
    -- and TextDocumentSyncKind.Incremental. If omitted it defaults to
    -- TextDocumentSyncKind.None.
    TextDocumentSyncOptions -> Maybe TextDocumentSyncKind
_change    :: Maybe TextDocumentSyncKind
    -- | If present will save notifications are sent to the server. If omitted the notification should not be
    -- sent.
  , TextDocumentSyncOptions -> Maybe Bool
_willSave  :: Maybe Bool
    -- | If present will save wait until requests are sent to the server. If omitted the request should not be
    -- sent.
  , TextDocumentSyncOptions -> Maybe Bool
_willSaveWaitUntil :: Maybe Bool
    -- | If present save notifications are sent to the server. If omitted the
    -- notification should not be sent.
  , TextDocumentSyncOptions -> Maybe (Bool |? SaveOptions)
_save      :: Maybe (Bool |? SaveOptions)
  } deriving (Int -> TextDocumentSyncOptions -> ShowS
[TextDocumentSyncOptions] -> ShowS
TextDocumentSyncOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentSyncOptions] -> ShowS
$cshowList :: [TextDocumentSyncOptions] -> ShowS
show :: TextDocumentSyncOptions -> String
$cshow :: TextDocumentSyncOptions -> String
showsPrec :: Int -> TextDocumentSyncOptions -> ShowS
$cshowsPrec :: Int -> TextDocumentSyncOptions -> ShowS
Show, ReadPrec [TextDocumentSyncOptions]
ReadPrec TextDocumentSyncOptions
Int -> ReadS TextDocumentSyncOptions
ReadS [TextDocumentSyncOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentSyncOptions]
$creadListPrec :: ReadPrec [TextDocumentSyncOptions]
readPrec :: ReadPrec TextDocumentSyncOptions
$creadPrec :: ReadPrec TextDocumentSyncOptions
readList :: ReadS [TextDocumentSyncOptions]
$creadList :: ReadS [TextDocumentSyncOptions]
readsPrec :: Int -> ReadS TextDocumentSyncOptions
$creadsPrec :: Int -> ReadS TextDocumentSyncOptions
Read, TextDocumentSyncOptions -> TextDocumentSyncOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentSyncOptions -> TextDocumentSyncOptions -> Bool
$c/= :: TextDocumentSyncOptions -> TextDocumentSyncOptions -> Bool
== :: TextDocumentSyncOptions -> TextDocumentSyncOptions -> Bool
$c== :: TextDocumentSyncOptions -> TextDocumentSyncOptions -> Bool
Eq)
deriveJSON lspOptions ''TextDocumentSyncOptions

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

{-
Since most of the registration options require to specify a document selector
there is a base interface that can be used.
-}

data TextDocumentRegistrationOptions =
  TextDocumentRegistrationOptions
    { TextDocumentRegistrationOptions -> Maybe DocumentSelector
_documentSelector :: Maybe DocumentSelector
    } deriving (Int -> TextDocumentRegistrationOptions -> ShowS
[TextDocumentRegistrationOptions] -> ShowS
TextDocumentRegistrationOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentRegistrationOptions] -> ShowS
$cshowList :: [TextDocumentRegistrationOptions] -> ShowS
show :: TextDocumentRegistrationOptions -> String
$cshow :: TextDocumentRegistrationOptions -> String
showsPrec :: Int -> TextDocumentRegistrationOptions -> ShowS
$cshowsPrec :: Int -> TextDocumentRegistrationOptions -> ShowS
Show, ReadPrec [TextDocumentRegistrationOptions]
ReadPrec TextDocumentRegistrationOptions
Int -> ReadS TextDocumentRegistrationOptions
ReadS [TextDocumentRegistrationOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentRegistrationOptions]
$creadListPrec :: ReadPrec [TextDocumentRegistrationOptions]
readPrec :: ReadPrec TextDocumentRegistrationOptions
$creadPrec :: ReadPrec TextDocumentRegistrationOptions
readList :: ReadS [TextDocumentRegistrationOptions]
$creadList :: ReadS [TextDocumentRegistrationOptions]
readsPrec :: Int -> ReadS TextDocumentRegistrationOptions
$creadsPrec :: Int -> ReadS TextDocumentRegistrationOptions
Read, TextDocumentRegistrationOptions
-> TextDocumentRegistrationOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentRegistrationOptions
-> TextDocumentRegistrationOptions -> Bool
$c/= :: TextDocumentRegistrationOptions
-> TextDocumentRegistrationOptions -> Bool
== :: TextDocumentRegistrationOptions
-> TextDocumentRegistrationOptions -> Bool
$c== :: TextDocumentRegistrationOptions
-> TextDocumentRegistrationOptions -> Bool
Eq)

deriveJSON lspOptions ''TextDocumentRegistrationOptions

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

data DidOpenTextDocumentParams =
  DidOpenTextDocumentParams
  { -- | The document that was opened.
    DidOpenTextDocumentParams -> TextDocumentItem
_textDocument :: TextDocumentItem
  } deriving (Int -> DidOpenTextDocumentParams -> ShowS
[DidOpenTextDocumentParams] -> ShowS
DidOpenTextDocumentParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DidOpenTextDocumentParams] -> ShowS
$cshowList :: [DidOpenTextDocumentParams] -> ShowS
show :: DidOpenTextDocumentParams -> String
$cshow :: DidOpenTextDocumentParams -> String
showsPrec :: Int -> DidOpenTextDocumentParams -> ShowS
$cshowsPrec :: Int -> DidOpenTextDocumentParams -> ShowS
Show, ReadPrec [DidOpenTextDocumentParams]
ReadPrec DidOpenTextDocumentParams
Int -> ReadS DidOpenTextDocumentParams
ReadS [DidOpenTextDocumentParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DidOpenTextDocumentParams]
$creadListPrec :: ReadPrec [DidOpenTextDocumentParams]
readPrec :: ReadPrec DidOpenTextDocumentParams
$creadPrec :: ReadPrec DidOpenTextDocumentParams
readList :: ReadS [DidOpenTextDocumentParams]
$creadList :: ReadS [DidOpenTextDocumentParams]
readsPrec :: Int -> ReadS DidOpenTextDocumentParams
$creadsPrec :: Int -> ReadS DidOpenTextDocumentParams
Read, DidOpenTextDocumentParams -> DidOpenTextDocumentParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DidOpenTextDocumentParams -> DidOpenTextDocumentParams -> Bool
$c/= :: DidOpenTextDocumentParams -> DidOpenTextDocumentParams -> Bool
== :: DidOpenTextDocumentParams -> DidOpenTextDocumentParams -> Bool
$c== :: DidOpenTextDocumentParams -> DidOpenTextDocumentParams -> Bool
Eq)

deriveJSON lspOptions ''DidOpenTextDocumentParams

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

makeExtendingDatatype "TextDocumentChangeRegistrationOptions"
  [''TextDocumentRegistrationOptions]
  [("_syncKind", [t| TextDocumentSyncKind |])]

deriveJSON lspOptions ''TextDocumentChangeRegistrationOptions

data TextDocumentContentChangeEvent =
  TextDocumentContentChangeEvent
    { -- | The range of the document that changed.
      TextDocumentContentChangeEvent -> Maybe Range
_range       :: Maybe Range
      -- | The optional length of the range that got replaced.
      -- Deprecated, use _range instead
    , TextDocumentContentChangeEvent -> Maybe UInt
_rangeLength :: Maybe UInt
      -- | The new text for the provided range, if provided.
      -- Otherwise the new text of the whole document.
    , TextDocumentContentChangeEvent -> Text
_text        :: Text
    }
  deriving (ReadPrec [TextDocumentContentChangeEvent]
ReadPrec TextDocumentContentChangeEvent
Int -> ReadS TextDocumentContentChangeEvent
ReadS [TextDocumentContentChangeEvent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentContentChangeEvent]
$creadListPrec :: ReadPrec [TextDocumentContentChangeEvent]
readPrec :: ReadPrec TextDocumentContentChangeEvent
$creadPrec :: ReadPrec TextDocumentContentChangeEvent
readList :: ReadS [TextDocumentContentChangeEvent]
$creadList :: ReadS [TextDocumentContentChangeEvent]
readsPrec :: Int -> ReadS TextDocumentContentChangeEvent
$creadsPrec :: Int -> ReadS TextDocumentContentChangeEvent
Read,Int -> TextDocumentContentChangeEvent -> ShowS
[TextDocumentContentChangeEvent] -> ShowS
TextDocumentContentChangeEvent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentContentChangeEvent] -> ShowS
$cshowList :: [TextDocumentContentChangeEvent] -> ShowS
show :: TextDocumentContentChangeEvent -> String
$cshow :: TextDocumentContentChangeEvent -> String
showsPrec :: Int -> TextDocumentContentChangeEvent -> ShowS
$cshowsPrec :: Int -> TextDocumentContentChangeEvent -> ShowS
Show,TextDocumentContentChangeEvent
-> TextDocumentContentChangeEvent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentContentChangeEvent
-> TextDocumentContentChangeEvent -> Bool
$c/= :: TextDocumentContentChangeEvent
-> TextDocumentContentChangeEvent -> Bool
== :: TextDocumentContentChangeEvent
-> TextDocumentContentChangeEvent -> Bool
$c== :: TextDocumentContentChangeEvent
-> TextDocumentContentChangeEvent -> Bool
Eq)

deriveJSON lspOptions ''TextDocumentContentChangeEvent

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

data DidChangeTextDocumentParams =
  DidChangeTextDocumentParams
    { -- | The document that did change. The version number points
      -- to the version after all provided content changes have
      -- been applied.
      DidChangeTextDocumentParams -> VersionedTextDocumentIdentifier
_textDocument   :: VersionedTextDocumentIdentifier
      -- | The actual content changes. The content changes describe single state changes
      -- to the document. So if there are two content changes c1 (at array index 0) and
      -- c2 (at array index 1) for a document in state S then c1 moves the document from
      -- S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed
      -- on the state S'.
      --
      -- To mirror the content of a document using change events use the following approach:
      -- - start with the same initial content
      -- - apply the 'textDocument/didChange' notifications in the order you recevie them.
      -- - apply the `TextDocumentContentChangeEvent`s in a single notification in the order
      --   you receive them.
    , DidChangeTextDocumentParams -> List TextDocumentContentChangeEvent
_contentChanges :: List TextDocumentContentChangeEvent
    } deriving (Int -> DidChangeTextDocumentParams -> ShowS
[DidChangeTextDocumentParams] -> ShowS
DidChangeTextDocumentParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DidChangeTextDocumentParams] -> ShowS
$cshowList :: [DidChangeTextDocumentParams] -> ShowS
show :: DidChangeTextDocumentParams -> String
$cshow :: DidChangeTextDocumentParams -> String
showsPrec :: Int -> DidChangeTextDocumentParams -> ShowS
$cshowsPrec :: Int -> DidChangeTextDocumentParams -> ShowS
Show,ReadPrec [DidChangeTextDocumentParams]
ReadPrec DidChangeTextDocumentParams
Int -> ReadS DidChangeTextDocumentParams
ReadS [DidChangeTextDocumentParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DidChangeTextDocumentParams]
$creadListPrec :: ReadPrec [DidChangeTextDocumentParams]
readPrec :: ReadPrec DidChangeTextDocumentParams
$creadPrec :: ReadPrec DidChangeTextDocumentParams
readList :: ReadS [DidChangeTextDocumentParams]
$creadList :: ReadS [DidChangeTextDocumentParams]
readsPrec :: Int -> ReadS DidChangeTextDocumentParams
$creadsPrec :: Int -> ReadS DidChangeTextDocumentParams
Read,DidChangeTextDocumentParams -> DidChangeTextDocumentParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DidChangeTextDocumentParams -> DidChangeTextDocumentParams -> Bool
$c/= :: DidChangeTextDocumentParams -> DidChangeTextDocumentParams -> Bool
== :: DidChangeTextDocumentParams -> DidChangeTextDocumentParams -> Bool
$c== :: DidChangeTextDocumentParams -> DidChangeTextDocumentParams -> Bool
Eq)

deriveJSON lspOptions ''DidChangeTextDocumentParams

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

data TextDocumentSaveReason
  = SaveManual
         -- ^ Manually triggered, e.g. by the user pressing save, by starting
         -- debugging, or by an API call.
  | SaveAfterDelay -- ^ Automatic after a delay
  | SaveFocusOut   -- ^ When the editor lost focus
  deriving (Int -> TextDocumentSaveReason -> ShowS
[TextDocumentSaveReason] -> ShowS
TextDocumentSaveReason -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentSaveReason] -> ShowS
$cshowList :: [TextDocumentSaveReason] -> ShowS
show :: TextDocumentSaveReason -> String
$cshow :: TextDocumentSaveReason -> String
showsPrec :: Int -> TextDocumentSaveReason -> ShowS
$cshowsPrec :: Int -> TextDocumentSaveReason -> ShowS
Show, ReadPrec [TextDocumentSaveReason]
ReadPrec TextDocumentSaveReason
Int -> ReadS TextDocumentSaveReason
ReadS [TextDocumentSaveReason]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentSaveReason]
$creadListPrec :: ReadPrec [TextDocumentSaveReason]
readPrec :: ReadPrec TextDocumentSaveReason
$creadPrec :: ReadPrec TextDocumentSaveReason
readList :: ReadS [TextDocumentSaveReason]
$creadList :: ReadS [TextDocumentSaveReason]
readsPrec :: Int -> ReadS TextDocumentSaveReason
$creadsPrec :: Int -> ReadS TextDocumentSaveReason
Read, TextDocumentSaveReason -> TextDocumentSaveReason -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentSaveReason -> TextDocumentSaveReason -> Bool
$c/= :: TextDocumentSaveReason -> TextDocumentSaveReason -> Bool
== :: TextDocumentSaveReason -> TextDocumentSaveReason -> Bool
$c== :: TextDocumentSaveReason -> TextDocumentSaveReason -> Bool
Eq)

instance ToJSON TextDocumentSaveReason where
  toJSON :: TextDocumentSaveReason -> Value
toJSON TextDocumentSaveReason
SaveManual     = Scientific -> Value
Number Scientific
1
  toJSON TextDocumentSaveReason
SaveAfterDelay = Scientific -> Value
Number Scientific
2
  toJSON TextDocumentSaveReason
SaveFocusOut   = Scientific -> Value
Number Scientific
3

instance FromJSON TextDocumentSaveReason where
  parseJSON :: Value -> Parser TextDocumentSaveReason
parseJSON (Number Scientific
1) = forall (f :: * -> *) a. Applicative f => a -> f a
pure TextDocumentSaveReason
SaveManual
  parseJSON (Number Scientific
2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure TextDocumentSaveReason
SaveAfterDelay
  parseJSON (Number Scientific
3) = forall (f :: * -> *) a. Applicative f => a -> f a
pure TextDocumentSaveReason
SaveFocusOut
  parseJSON Value
_          = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"TextDocumentSaveReason"

data WillSaveTextDocumentParams =
  WillSaveTextDocumentParams
    { -- | The document that will be saved.
      WillSaveTextDocumentParams -> TextDocumentIdentifier
_textDocument :: TextDocumentIdentifier
      -- | The 'TextDocumentSaveReason'.
    , WillSaveTextDocumentParams -> TextDocumentSaveReason
_reason       :: TextDocumentSaveReason
    } deriving (Int -> WillSaveTextDocumentParams -> ShowS
[WillSaveTextDocumentParams] -> ShowS
WillSaveTextDocumentParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WillSaveTextDocumentParams] -> ShowS
$cshowList :: [WillSaveTextDocumentParams] -> ShowS
show :: WillSaveTextDocumentParams -> String
$cshow :: WillSaveTextDocumentParams -> String
showsPrec :: Int -> WillSaveTextDocumentParams -> ShowS
$cshowsPrec :: Int -> WillSaveTextDocumentParams -> ShowS
Show, ReadPrec [WillSaveTextDocumentParams]
ReadPrec WillSaveTextDocumentParams
Int -> ReadS WillSaveTextDocumentParams
ReadS [WillSaveTextDocumentParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WillSaveTextDocumentParams]
$creadListPrec :: ReadPrec [WillSaveTextDocumentParams]
readPrec :: ReadPrec WillSaveTextDocumentParams
$creadPrec :: ReadPrec WillSaveTextDocumentParams
readList :: ReadS [WillSaveTextDocumentParams]
$creadList :: ReadS [WillSaveTextDocumentParams]
readsPrec :: Int -> ReadS WillSaveTextDocumentParams
$creadsPrec :: Int -> ReadS WillSaveTextDocumentParams
Read, WillSaveTextDocumentParams -> WillSaveTextDocumentParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WillSaveTextDocumentParams -> WillSaveTextDocumentParams -> Bool
$c/= :: WillSaveTextDocumentParams -> WillSaveTextDocumentParams -> Bool
== :: WillSaveTextDocumentParams -> WillSaveTextDocumentParams -> Bool
$c== :: WillSaveTextDocumentParams -> WillSaveTextDocumentParams -> Bool
Eq)

deriveJSON lspOptions ''WillSaveTextDocumentParams

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


makeExtendingDatatype "TextDocumentSaveRegistrationOptions"
  [''TextDocumentRegistrationOptions]
  [("_includeText", [t| Maybe Bool |])]

deriveJSON lspOptions ''TextDocumentSaveRegistrationOptions

data DidSaveTextDocumentParams =
  DidSaveTextDocumentParams
    { -- | The document that was saved.
      DidSaveTextDocumentParams -> TextDocumentIdentifier
_textDocument :: TextDocumentIdentifier
      -- | Optional the content when saved. Depends on the includeText value
      -- when the save notification was requested.
    , DidSaveTextDocumentParams -> Maybe Text
_text         :: Maybe Text
    } deriving (ReadPrec [DidSaveTextDocumentParams]
ReadPrec DidSaveTextDocumentParams
Int -> ReadS DidSaveTextDocumentParams
ReadS [DidSaveTextDocumentParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DidSaveTextDocumentParams]
$creadListPrec :: ReadPrec [DidSaveTextDocumentParams]
readPrec :: ReadPrec DidSaveTextDocumentParams
$creadPrec :: ReadPrec DidSaveTextDocumentParams
readList :: ReadS [DidSaveTextDocumentParams]
$creadList :: ReadS [DidSaveTextDocumentParams]
readsPrec :: Int -> ReadS DidSaveTextDocumentParams
$creadsPrec :: Int -> ReadS DidSaveTextDocumentParams
Read,Int -> DidSaveTextDocumentParams -> ShowS
[DidSaveTextDocumentParams] -> ShowS
DidSaveTextDocumentParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DidSaveTextDocumentParams] -> ShowS
$cshowList :: [DidSaveTextDocumentParams] -> ShowS
show :: DidSaveTextDocumentParams -> String
$cshow :: DidSaveTextDocumentParams -> String
showsPrec :: Int -> DidSaveTextDocumentParams -> ShowS
$cshowsPrec :: Int -> DidSaveTextDocumentParams -> ShowS
Show,DidSaveTextDocumentParams -> DidSaveTextDocumentParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DidSaveTextDocumentParams -> DidSaveTextDocumentParams -> Bool
$c/= :: DidSaveTextDocumentParams -> DidSaveTextDocumentParams -> Bool
== :: DidSaveTextDocumentParams -> DidSaveTextDocumentParams -> Bool
$c== :: DidSaveTextDocumentParams -> DidSaveTextDocumentParams -> Bool
Eq)

deriveJSON lspOptions ''DidSaveTextDocumentParams

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

data DidCloseTextDocumentParams =
  DidCloseTextDocumentParams
    { -- | The document that was closed.
      DidCloseTextDocumentParams -> TextDocumentIdentifier
_textDocument :: TextDocumentIdentifier
    } deriving (ReadPrec [DidCloseTextDocumentParams]
ReadPrec DidCloseTextDocumentParams
Int -> ReadS DidCloseTextDocumentParams
ReadS [DidCloseTextDocumentParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DidCloseTextDocumentParams]
$creadListPrec :: ReadPrec [DidCloseTextDocumentParams]
readPrec :: ReadPrec DidCloseTextDocumentParams
$creadPrec :: ReadPrec DidCloseTextDocumentParams
readList :: ReadS [DidCloseTextDocumentParams]
$creadList :: ReadS [DidCloseTextDocumentParams]
readsPrec :: Int -> ReadS DidCloseTextDocumentParams
$creadsPrec :: Int -> ReadS DidCloseTextDocumentParams
Read,Int -> DidCloseTextDocumentParams -> ShowS
[DidCloseTextDocumentParams] -> ShowS
DidCloseTextDocumentParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DidCloseTextDocumentParams] -> ShowS
$cshowList :: [DidCloseTextDocumentParams] -> ShowS
show :: DidCloseTextDocumentParams -> String
$cshow :: DidCloseTextDocumentParams -> String
showsPrec :: Int -> DidCloseTextDocumentParams -> ShowS
$cshowsPrec :: Int -> DidCloseTextDocumentParams -> ShowS
Show,DidCloseTextDocumentParams -> DidCloseTextDocumentParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DidCloseTextDocumentParams -> DidCloseTextDocumentParams -> Bool
$c/= :: DidCloseTextDocumentParams -> DidCloseTextDocumentParams -> Bool
== :: DidCloseTextDocumentParams -> DidCloseTextDocumentParams -> Bool
$c== :: DidCloseTextDocumentParams -> DidCloseTextDocumentParams -> Bool
Eq)

deriveJSON lspOptions ''DidCloseTextDocumentParams