{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Language.LSP.Types.WorkspaceEdit where
import Control.Monad (unless)
import Data.Aeson
import Data.Aeson.TH
import qualified Data.HashMap.Strict as H
import Data.Maybe (catMaybes)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Hashable
import Language.LSP.Types.Common
import Language.LSP.Types.Location
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Uri
import Language.LSP.Types.Utils
data TextEdit =
TextEdit
{ TextEdit -> Range
_range :: Range
, TextEdit -> Text
_newText :: Text
} deriving (Int -> TextEdit -> ShowS
[TextEdit] -> ShowS
TextEdit -> String
(Int -> TextEdit -> ShowS)
-> (TextEdit -> String) -> ([TextEdit] -> ShowS) -> Show TextEdit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextEdit] -> ShowS
$cshowList :: [TextEdit] -> ShowS
show :: TextEdit -> String
$cshow :: TextEdit -> String
showsPrec :: Int -> TextEdit -> ShowS
$cshowsPrec :: Int -> TextEdit -> ShowS
Show,ReadPrec [TextEdit]
ReadPrec TextEdit
Int -> ReadS TextEdit
ReadS [TextEdit]
(Int -> ReadS TextEdit)
-> ReadS [TextEdit]
-> ReadPrec TextEdit
-> ReadPrec [TextEdit]
-> Read TextEdit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextEdit]
$creadListPrec :: ReadPrec [TextEdit]
readPrec :: ReadPrec TextEdit
$creadPrec :: ReadPrec TextEdit
readList :: ReadS [TextEdit]
$creadList :: ReadS [TextEdit]
readsPrec :: Int -> ReadS TextEdit
$creadsPrec :: Int -> ReadS TextEdit
Read,TextEdit -> TextEdit -> Bool
(TextEdit -> TextEdit -> Bool)
-> (TextEdit -> TextEdit -> Bool) -> Eq TextEdit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextEdit -> TextEdit -> Bool
$c/= :: TextEdit -> TextEdit -> Bool
== :: TextEdit -> TextEdit -> Bool
$c== :: TextEdit -> TextEdit -> Bool
Eq)
deriveJSON lspOptions ''TextEdit
data ChangeAnnotation =
ChangeAnnotation
{
ChangeAnnotation -> Text
_label :: Text
, ChangeAnnotation -> Maybe Bool
_needsConfirmation :: Maybe Bool
, ChangeAnnotation -> Maybe Text
_description :: Maybe Text
} deriving (Int -> ChangeAnnotation -> ShowS
[ChangeAnnotation] -> ShowS
ChangeAnnotation -> String
(Int -> ChangeAnnotation -> ShowS)
-> (ChangeAnnotation -> String)
-> ([ChangeAnnotation] -> ShowS)
-> Show ChangeAnnotation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangeAnnotation] -> ShowS
$cshowList :: [ChangeAnnotation] -> ShowS
show :: ChangeAnnotation -> String
$cshow :: ChangeAnnotation -> String
showsPrec :: Int -> ChangeAnnotation -> ShowS
$cshowsPrec :: Int -> ChangeAnnotation -> ShowS
Show, ReadPrec [ChangeAnnotation]
ReadPrec ChangeAnnotation
Int -> ReadS ChangeAnnotation
ReadS [ChangeAnnotation]
(Int -> ReadS ChangeAnnotation)
-> ReadS [ChangeAnnotation]
-> ReadPrec ChangeAnnotation
-> ReadPrec [ChangeAnnotation]
-> Read ChangeAnnotation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangeAnnotation]
$creadListPrec :: ReadPrec [ChangeAnnotation]
readPrec :: ReadPrec ChangeAnnotation
$creadPrec :: ReadPrec ChangeAnnotation
readList :: ReadS [ChangeAnnotation]
$creadList :: ReadS [ChangeAnnotation]
readsPrec :: Int -> ReadS ChangeAnnotation
$creadsPrec :: Int -> ReadS ChangeAnnotation
Read, ChangeAnnotation -> ChangeAnnotation -> Bool
(ChangeAnnotation -> ChangeAnnotation -> Bool)
-> (ChangeAnnotation -> ChangeAnnotation -> Bool)
-> Eq ChangeAnnotation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangeAnnotation -> ChangeAnnotation -> Bool
$c/= :: ChangeAnnotation -> ChangeAnnotation -> Bool
== :: ChangeAnnotation -> ChangeAnnotation -> Bool
$c== :: ChangeAnnotation -> ChangeAnnotation -> Bool
Eq)
deriveJSON lspOptions ''ChangeAnnotation
newtype ChangeAnnotationIdentifier = ChangeAnnotationIdentifierId Text
deriving (Int -> ChangeAnnotationIdentifier -> ShowS
[ChangeAnnotationIdentifier] -> ShowS
ChangeAnnotationIdentifier -> String
(Int -> ChangeAnnotationIdentifier -> ShowS)
-> (ChangeAnnotationIdentifier -> String)
-> ([ChangeAnnotationIdentifier] -> ShowS)
-> Show ChangeAnnotationIdentifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangeAnnotationIdentifier] -> ShowS
$cshowList :: [ChangeAnnotationIdentifier] -> ShowS
show :: ChangeAnnotationIdentifier -> String
$cshow :: ChangeAnnotationIdentifier -> String
showsPrec :: Int -> ChangeAnnotationIdentifier -> ShowS
$cshowsPrec :: Int -> ChangeAnnotationIdentifier -> ShowS
Show, ReadPrec [ChangeAnnotationIdentifier]
ReadPrec ChangeAnnotationIdentifier
Int -> ReadS ChangeAnnotationIdentifier
ReadS [ChangeAnnotationIdentifier]
(Int -> ReadS ChangeAnnotationIdentifier)
-> ReadS [ChangeAnnotationIdentifier]
-> ReadPrec ChangeAnnotationIdentifier
-> ReadPrec [ChangeAnnotationIdentifier]
-> Read ChangeAnnotationIdentifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangeAnnotationIdentifier]
$creadListPrec :: ReadPrec [ChangeAnnotationIdentifier]
readPrec :: ReadPrec ChangeAnnotationIdentifier
$creadPrec :: ReadPrec ChangeAnnotationIdentifier
readList :: ReadS [ChangeAnnotationIdentifier]
$creadList :: ReadS [ChangeAnnotationIdentifier]
readsPrec :: Int -> ReadS ChangeAnnotationIdentifier
$creadsPrec :: Int -> ReadS ChangeAnnotationIdentifier
Read, ChangeAnnotationIdentifier -> ChangeAnnotationIdentifier -> Bool
(ChangeAnnotationIdentifier -> ChangeAnnotationIdentifier -> Bool)
-> (ChangeAnnotationIdentifier
-> ChangeAnnotationIdentifier -> Bool)
-> Eq ChangeAnnotationIdentifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangeAnnotationIdentifier -> ChangeAnnotationIdentifier -> Bool
$c/= :: ChangeAnnotationIdentifier -> ChangeAnnotationIdentifier -> Bool
== :: ChangeAnnotationIdentifier -> ChangeAnnotationIdentifier -> Bool
$c== :: ChangeAnnotationIdentifier -> ChangeAnnotationIdentifier -> Bool
Eq, Value -> Parser [ChangeAnnotationIdentifier]
Value -> Parser ChangeAnnotationIdentifier
(Value -> Parser ChangeAnnotationIdentifier)
-> (Value -> Parser [ChangeAnnotationIdentifier])
-> FromJSON ChangeAnnotationIdentifier
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ChangeAnnotationIdentifier]
$cparseJSONList :: Value -> Parser [ChangeAnnotationIdentifier]
parseJSON :: Value -> Parser ChangeAnnotationIdentifier
$cparseJSON :: Value -> Parser ChangeAnnotationIdentifier
FromJSON, [ChangeAnnotationIdentifier] -> Encoding
[ChangeAnnotationIdentifier] -> Value
ChangeAnnotationIdentifier -> Encoding
ChangeAnnotationIdentifier -> Value
(ChangeAnnotationIdentifier -> Value)
-> (ChangeAnnotationIdentifier -> Encoding)
-> ([ChangeAnnotationIdentifier] -> Value)
-> ([ChangeAnnotationIdentifier] -> Encoding)
-> ToJSON ChangeAnnotationIdentifier
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ChangeAnnotationIdentifier] -> Encoding
$ctoEncodingList :: [ChangeAnnotationIdentifier] -> Encoding
toJSONList :: [ChangeAnnotationIdentifier] -> Value
$ctoJSONList :: [ChangeAnnotationIdentifier] -> Value
toEncoding :: ChangeAnnotationIdentifier -> Encoding
$ctoEncoding :: ChangeAnnotationIdentifier -> Encoding
toJSON :: ChangeAnnotationIdentifier -> Value
$ctoJSON :: ChangeAnnotationIdentifier -> Value
ToJSON, ToJSONKeyFunction [ChangeAnnotationIdentifier]
ToJSONKeyFunction ChangeAnnotationIdentifier
ToJSONKeyFunction ChangeAnnotationIdentifier
-> ToJSONKeyFunction [ChangeAnnotationIdentifier]
-> ToJSONKey ChangeAnnotationIdentifier
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [ChangeAnnotationIdentifier]
$ctoJSONKeyList :: ToJSONKeyFunction [ChangeAnnotationIdentifier]
toJSONKey :: ToJSONKeyFunction ChangeAnnotationIdentifier
$ctoJSONKey :: ToJSONKeyFunction ChangeAnnotationIdentifier
ToJSONKey, FromJSONKeyFunction [ChangeAnnotationIdentifier]
FromJSONKeyFunction ChangeAnnotationIdentifier
FromJSONKeyFunction ChangeAnnotationIdentifier
-> FromJSONKeyFunction [ChangeAnnotationIdentifier]
-> FromJSONKey ChangeAnnotationIdentifier
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [ChangeAnnotationIdentifier]
$cfromJSONKeyList :: FromJSONKeyFunction [ChangeAnnotationIdentifier]
fromJSONKey :: FromJSONKeyFunction ChangeAnnotationIdentifier
$cfromJSONKey :: FromJSONKeyFunction ChangeAnnotationIdentifier
FromJSONKey, Eq ChangeAnnotationIdentifier
Eq ChangeAnnotationIdentifier
-> (Int -> ChangeAnnotationIdentifier -> Int)
-> (ChangeAnnotationIdentifier -> Int)
-> Hashable ChangeAnnotationIdentifier
Int -> ChangeAnnotationIdentifier -> Int
ChangeAnnotationIdentifier -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ChangeAnnotationIdentifier -> Int
$chash :: ChangeAnnotationIdentifier -> Int
hashWithSalt :: Int -> ChangeAnnotationIdentifier -> Int
$chashWithSalt :: Int -> ChangeAnnotationIdentifier -> Int
$cp1Hashable :: Eq ChangeAnnotationIdentifier
Hashable)
makeExtendingDatatype "AnnotatedTextEdit" [''TextEdit]
[("_annotationId", [t| ChangeAnnotationIdentifier |]) ]
deriveJSON lspOptions ''AnnotatedTextEdit
data TextDocumentEdit =
TextDocumentEdit
{ TextDocumentEdit -> VersionedTextDocumentIdentifier
_textDocument :: VersionedTextDocumentIdentifier
, TextDocumentEdit -> List (TextEdit |? AnnotatedTextEdit)
_edits :: List (TextEdit |? AnnotatedTextEdit)
} deriving (Int -> TextDocumentEdit -> ShowS
[TextDocumentEdit] -> ShowS
TextDocumentEdit -> String
(Int -> TextDocumentEdit -> ShowS)
-> (TextDocumentEdit -> String)
-> ([TextDocumentEdit] -> ShowS)
-> Show TextDocumentEdit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDocumentEdit] -> ShowS
$cshowList :: [TextDocumentEdit] -> ShowS
show :: TextDocumentEdit -> String
$cshow :: TextDocumentEdit -> String
showsPrec :: Int -> TextDocumentEdit -> ShowS
$cshowsPrec :: Int -> TextDocumentEdit -> ShowS
Show, ReadPrec [TextDocumentEdit]
ReadPrec TextDocumentEdit
Int -> ReadS TextDocumentEdit
ReadS [TextDocumentEdit]
(Int -> ReadS TextDocumentEdit)
-> ReadS [TextDocumentEdit]
-> ReadPrec TextDocumentEdit
-> ReadPrec [TextDocumentEdit]
-> Read TextDocumentEdit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDocumentEdit]
$creadListPrec :: ReadPrec [TextDocumentEdit]
readPrec :: ReadPrec TextDocumentEdit
$creadPrec :: ReadPrec TextDocumentEdit
readList :: ReadS [TextDocumentEdit]
$creadList :: ReadS [TextDocumentEdit]
readsPrec :: Int -> ReadS TextDocumentEdit
$creadsPrec :: Int -> ReadS TextDocumentEdit
Read, TextDocumentEdit -> TextDocumentEdit -> Bool
(TextDocumentEdit -> TextDocumentEdit -> Bool)
-> (TextDocumentEdit -> TextDocumentEdit -> Bool)
-> Eq TextDocumentEdit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDocumentEdit -> TextDocumentEdit -> Bool
$c/= :: TextDocumentEdit -> TextDocumentEdit -> Bool
== :: TextDocumentEdit -> TextDocumentEdit -> Bool
$c== :: TextDocumentEdit -> TextDocumentEdit -> Bool
Eq)
deriveJSON lspOptions ''TextDocumentEdit
data CreateFileOptions =
CreateFileOptions
{
CreateFileOptions -> Maybe Bool
_overwrite :: Maybe Bool
, CreateFileOptions -> Maybe Bool
_ignoreIfExists :: Maybe Bool
} deriving (Int -> CreateFileOptions -> ShowS
[CreateFileOptions] -> ShowS
CreateFileOptions -> String
(Int -> CreateFileOptions -> ShowS)
-> (CreateFileOptions -> String)
-> ([CreateFileOptions] -> ShowS)
-> Show CreateFileOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFileOptions] -> ShowS
$cshowList :: [CreateFileOptions] -> ShowS
show :: CreateFileOptions -> String
$cshow :: CreateFileOptions -> String
showsPrec :: Int -> CreateFileOptions -> ShowS
$cshowsPrec :: Int -> CreateFileOptions -> ShowS
Show, ReadPrec [CreateFileOptions]
ReadPrec CreateFileOptions
Int -> ReadS CreateFileOptions
ReadS [CreateFileOptions]
(Int -> ReadS CreateFileOptions)
-> ReadS [CreateFileOptions]
-> ReadPrec CreateFileOptions
-> ReadPrec [CreateFileOptions]
-> Read CreateFileOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFileOptions]
$creadListPrec :: ReadPrec [CreateFileOptions]
readPrec :: ReadPrec CreateFileOptions
$creadPrec :: ReadPrec CreateFileOptions
readList :: ReadS [CreateFileOptions]
$creadList :: ReadS [CreateFileOptions]
readsPrec :: Int -> ReadS CreateFileOptions
$creadsPrec :: Int -> ReadS CreateFileOptions
Read, CreateFileOptions -> CreateFileOptions -> Bool
(CreateFileOptions -> CreateFileOptions -> Bool)
-> (CreateFileOptions -> CreateFileOptions -> Bool)
-> Eq CreateFileOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFileOptions -> CreateFileOptions -> Bool
$c/= :: CreateFileOptions -> CreateFileOptions -> Bool
== :: CreateFileOptions -> CreateFileOptions -> Bool
$c== :: CreateFileOptions -> CreateFileOptions -> Bool
Eq)
deriveJSON lspOptions ''CreateFileOptions
data CreateFile =
CreateFile
{
CreateFile -> Uri
_uri :: Uri
, CreateFile -> Maybe CreateFileOptions
_options :: Maybe CreateFileOptions
, CreateFile -> Maybe ChangeAnnotationIdentifier
_annotationId :: Maybe ChangeAnnotationIdentifier
} deriving (Int -> CreateFile -> ShowS
[CreateFile] -> ShowS
CreateFile -> String
(Int -> CreateFile -> ShowS)
-> (CreateFile -> String)
-> ([CreateFile] -> ShowS)
-> Show CreateFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFile] -> ShowS
$cshowList :: [CreateFile] -> ShowS
show :: CreateFile -> String
$cshow :: CreateFile -> String
showsPrec :: Int -> CreateFile -> ShowS
$cshowsPrec :: Int -> CreateFile -> ShowS
Show, ReadPrec [CreateFile]
ReadPrec CreateFile
Int -> ReadS CreateFile
ReadS [CreateFile]
(Int -> ReadS CreateFile)
-> ReadS [CreateFile]
-> ReadPrec CreateFile
-> ReadPrec [CreateFile]
-> Read CreateFile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFile]
$creadListPrec :: ReadPrec [CreateFile]
readPrec :: ReadPrec CreateFile
$creadPrec :: ReadPrec CreateFile
readList :: ReadS [CreateFile]
$creadList :: ReadS [CreateFile]
readsPrec :: Int -> ReadS CreateFile
$creadsPrec :: Int -> ReadS CreateFile
Read, CreateFile -> CreateFile -> Bool
(CreateFile -> CreateFile -> Bool)
-> (CreateFile -> CreateFile -> Bool) -> Eq CreateFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFile -> CreateFile -> Bool
$c/= :: CreateFile -> CreateFile -> Bool
== :: CreateFile -> CreateFile -> Bool
$c== :: CreateFile -> CreateFile -> Bool
Eq)
instance ToJSON CreateFile where
toJSON :: CreateFile -> Value
toJSON CreateFile{Maybe ChangeAnnotationIdentifier
Maybe CreateFileOptions
Uri
_annotationId :: Maybe ChangeAnnotationIdentifier
_options :: Maybe CreateFileOptions
_uri :: Uri
$sel:_annotationId:CreateFile :: CreateFile -> Maybe ChangeAnnotationIdentifier
$sel:_options:CreateFile :: CreateFile -> Maybe CreateFileOptions
$sel:_uri:CreateFile :: CreateFile -> Uri
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"kind" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Text
"create" :: Text)
, Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"uri" Key -> Uri -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Uri
_uri
, (Key
"options" Key -> CreateFileOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=) (CreateFileOptions -> Pair)
-> Maybe CreateFileOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe CreateFileOptions
_options
, (Key
"annotationId" Key -> ChangeAnnotationIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=) (ChangeAnnotationIdentifier -> Pair)
-> Maybe ChangeAnnotationIdentifier -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ChangeAnnotationIdentifier
_annotationId
]
instance FromJSON CreateFile where
parseJSON :: Value -> Parser CreateFile
parseJSON = String
-> (Object -> Parser CreateFile) -> Value -> Parser CreateFile
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"CreateFile" ((Object -> Parser CreateFile) -> Value -> Parser CreateFile)
-> (Object -> Parser CreateFile) -> Value -> Parser CreateFile
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Text
kind <- Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"kind"
Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
kind Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
"create" :: Text))
(Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Expected kind \"create\" but got " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
kind
Uri
_uri <- Object
o Object -> Key -> Parser Uri
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"uri"
Maybe CreateFileOptions
_options <- Object
o Object -> Key -> Parser (Maybe CreateFileOptions)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"options"
Maybe ChangeAnnotationIdentifier
_annotationId <- Object
o Object -> Key -> Parser (Maybe ChangeAnnotationIdentifier)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"annotationId"
CreateFile -> Parser CreateFile
forall (f :: * -> *) a. Applicative f => a -> f a
pure CreateFile :: Uri
-> Maybe CreateFileOptions
-> Maybe ChangeAnnotationIdentifier
-> CreateFile
CreateFile{Maybe ChangeAnnotationIdentifier
Maybe CreateFileOptions
Uri
_annotationId :: Maybe ChangeAnnotationIdentifier
_options :: Maybe CreateFileOptions
_uri :: Uri
$sel:_annotationId:CreateFile :: Maybe ChangeAnnotationIdentifier
$sel:_options:CreateFile :: Maybe CreateFileOptions
$sel:_uri:CreateFile :: Uri
..}
data RenameFileOptions =
RenameFileOptions
{
RenameFileOptions -> Maybe Bool
_overwrite :: Maybe Bool
, RenameFileOptions -> Maybe Bool
_ignoreIfExists :: Maybe Bool
} deriving (Int -> RenameFileOptions -> ShowS
[RenameFileOptions] -> ShowS
RenameFileOptions -> String
(Int -> RenameFileOptions -> ShowS)
-> (RenameFileOptions -> String)
-> ([RenameFileOptions] -> ShowS)
-> Show RenameFileOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenameFileOptions] -> ShowS
$cshowList :: [RenameFileOptions] -> ShowS
show :: RenameFileOptions -> String
$cshow :: RenameFileOptions -> String
showsPrec :: Int -> RenameFileOptions -> ShowS
$cshowsPrec :: Int -> RenameFileOptions -> ShowS
Show, ReadPrec [RenameFileOptions]
ReadPrec RenameFileOptions
Int -> ReadS RenameFileOptions
ReadS [RenameFileOptions]
(Int -> ReadS RenameFileOptions)
-> ReadS [RenameFileOptions]
-> ReadPrec RenameFileOptions
-> ReadPrec [RenameFileOptions]
-> Read RenameFileOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenameFileOptions]
$creadListPrec :: ReadPrec [RenameFileOptions]
readPrec :: ReadPrec RenameFileOptions
$creadPrec :: ReadPrec RenameFileOptions
readList :: ReadS [RenameFileOptions]
$creadList :: ReadS [RenameFileOptions]
readsPrec :: Int -> ReadS RenameFileOptions
$creadsPrec :: Int -> ReadS RenameFileOptions
Read, RenameFileOptions -> RenameFileOptions -> Bool
(RenameFileOptions -> RenameFileOptions -> Bool)
-> (RenameFileOptions -> RenameFileOptions -> Bool)
-> Eq RenameFileOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenameFileOptions -> RenameFileOptions -> Bool
$c/= :: RenameFileOptions -> RenameFileOptions -> Bool
== :: RenameFileOptions -> RenameFileOptions -> Bool
$c== :: RenameFileOptions -> RenameFileOptions -> Bool
Eq)
deriveJSON lspOptions ''RenameFileOptions
data RenameFile =
RenameFile
{
RenameFile -> Uri
_oldUri :: Uri
, RenameFile -> Uri
_newUri :: Uri
, RenameFile -> Maybe RenameFileOptions
_options :: Maybe RenameFileOptions
, RenameFile -> Maybe ChangeAnnotationIdentifier
_annotationId :: Maybe ChangeAnnotationIdentifier
} deriving (Int -> RenameFile -> ShowS
[RenameFile] -> ShowS
RenameFile -> String
(Int -> RenameFile -> ShowS)
-> (RenameFile -> String)
-> ([RenameFile] -> ShowS)
-> Show RenameFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenameFile] -> ShowS
$cshowList :: [RenameFile] -> ShowS
show :: RenameFile -> String
$cshow :: RenameFile -> String
showsPrec :: Int -> RenameFile -> ShowS
$cshowsPrec :: Int -> RenameFile -> ShowS
Show, ReadPrec [RenameFile]
ReadPrec RenameFile
Int -> ReadS RenameFile
ReadS [RenameFile]
(Int -> ReadS RenameFile)
-> ReadS [RenameFile]
-> ReadPrec RenameFile
-> ReadPrec [RenameFile]
-> Read RenameFile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenameFile]
$creadListPrec :: ReadPrec [RenameFile]
readPrec :: ReadPrec RenameFile
$creadPrec :: ReadPrec RenameFile
readList :: ReadS [RenameFile]
$creadList :: ReadS [RenameFile]
readsPrec :: Int -> ReadS RenameFile
$creadsPrec :: Int -> ReadS RenameFile
Read, RenameFile -> RenameFile -> Bool
(RenameFile -> RenameFile -> Bool)
-> (RenameFile -> RenameFile -> Bool) -> Eq RenameFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenameFile -> RenameFile -> Bool
$c/= :: RenameFile -> RenameFile -> Bool
== :: RenameFile -> RenameFile -> Bool
$c== :: RenameFile -> RenameFile -> Bool
Eq)
instance ToJSON RenameFile where
toJSON :: RenameFile -> Value
toJSON RenameFile{Maybe ChangeAnnotationIdentifier
Maybe RenameFileOptions
Uri
_annotationId :: Maybe ChangeAnnotationIdentifier
_options :: Maybe RenameFileOptions
_newUri :: Uri
_oldUri :: Uri
$sel:_annotationId:RenameFile :: RenameFile -> Maybe ChangeAnnotationIdentifier
$sel:_options:RenameFile :: RenameFile -> Maybe RenameFileOptions
$sel:_newUri:RenameFile :: RenameFile -> Uri
$sel:_oldUri:RenameFile :: RenameFile -> Uri
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"kind" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Text
"rename" :: Text)
, Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"oldUri" Key -> Uri -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Uri
_oldUri
, Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"newUri" Key -> Uri -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Uri
_newUri
, (Key
"options" Key -> RenameFileOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=) (RenameFileOptions -> Pair)
-> Maybe RenameFileOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe RenameFileOptions
_options
, (Key
"annotationId" Key -> ChangeAnnotationIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=) (ChangeAnnotationIdentifier -> Pair)
-> Maybe ChangeAnnotationIdentifier -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ChangeAnnotationIdentifier
_annotationId
]
instance FromJSON RenameFile where
parseJSON :: Value -> Parser RenameFile
parseJSON = String
-> (Object -> Parser RenameFile) -> Value -> Parser RenameFile
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"RenameFile" ((Object -> Parser RenameFile) -> Value -> Parser RenameFile)
-> (Object -> Parser RenameFile) -> Value -> Parser RenameFile
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Text
kind <- Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"kind"
Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
kind Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
"rename" :: Text))
(Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Expected kind \"rename\" but got " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
kind
Uri
_oldUri <- Object
o Object -> Key -> Parser Uri
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"oldUri"
Uri
_newUri <- Object
o Object -> Key -> Parser Uri
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"newUri"
Maybe RenameFileOptions
_options <- Object
o Object -> Key -> Parser (Maybe RenameFileOptions)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"options"
Maybe ChangeAnnotationIdentifier
_annotationId <- Object
o Object -> Key -> Parser (Maybe ChangeAnnotationIdentifier)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"annotationId"
RenameFile -> Parser RenameFile
forall (f :: * -> *) a. Applicative f => a -> f a
pure RenameFile :: Uri
-> Uri
-> Maybe RenameFileOptions
-> Maybe ChangeAnnotationIdentifier
-> RenameFile
RenameFile{Maybe ChangeAnnotationIdentifier
Maybe RenameFileOptions
Uri
_annotationId :: Maybe ChangeAnnotationIdentifier
_options :: Maybe RenameFileOptions
_newUri :: Uri
_oldUri :: Uri
$sel:_annotationId:RenameFile :: Maybe ChangeAnnotationIdentifier
$sel:_options:RenameFile :: Maybe RenameFileOptions
$sel:_newUri:RenameFile :: Uri
$sel:_oldUri:RenameFile :: Uri
..}
data DeleteFileOptions =
DeleteFileOptions
{
DeleteFileOptions -> Maybe Bool
_recursive :: Maybe Bool
, DeleteFileOptions -> Maybe Bool
_ignoreIfNotExists :: Maybe Bool
} deriving (Int -> DeleteFileOptions -> ShowS
[DeleteFileOptions] -> ShowS
DeleteFileOptions -> String
(Int -> DeleteFileOptions -> ShowS)
-> (DeleteFileOptions -> String)
-> ([DeleteFileOptions] -> ShowS)
-> Show DeleteFileOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFileOptions] -> ShowS
$cshowList :: [DeleteFileOptions] -> ShowS
show :: DeleteFileOptions -> String
$cshow :: DeleteFileOptions -> String
showsPrec :: Int -> DeleteFileOptions -> ShowS
$cshowsPrec :: Int -> DeleteFileOptions -> ShowS
Show, ReadPrec [DeleteFileOptions]
ReadPrec DeleteFileOptions
Int -> ReadS DeleteFileOptions
ReadS [DeleteFileOptions]
(Int -> ReadS DeleteFileOptions)
-> ReadS [DeleteFileOptions]
-> ReadPrec DeleteFileOptions
-> ReadPrec [DeleteFileOptions]
-> Read DeleteFileOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFileOptions]
$creadListPrec :: ReadPrec [DeleteFileOptions]
readPrec :: ReadPrec DeleteFileOptions
$creadPrec :: ReadPrec DeleteFileOptions
readList :: ReadS [DeleteFileOptions]
$creadList :: ReadS [DeleteFileOptions]
readsPrec :: Int -> ReadS DeleteFileOptions
$creadsPrec :: Int -> ReadS DeleteFileOptions
Read, DeleteFileOptions -> DeleteFileOptions -> Bool
(DeleteFileOptions -> DeleteFileOptions -> Bool)
-> (DeleteFileOptions -> DeleteFileOptions -> Bool)
-> Eq DeleteFileOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFileOptions -> DeleteFileOptions -> Bool
$c/= :: DeleteFileOptions -> DeleteFileOptions -> Bool
== :: DeleteFileOptions -> DeleteFileOptions -> Bool
$c== :: DeleteFileOptions -> DeleteFileOptions -> Bool
Eq)
deriveJSON lspOptions ''DeleteFileOptions
data DeleteFile =
DeleteFile
{
DeleteFile -> Uri
_uri :: Uri
, DeleteFile -> Maybe DeleteFileOptions
_options :: Maybe DeleteFileOptions
, DeleteFile -> Maybe ChangeAnnotationIdentifier
_annotationId :: Maybe ChangeAnnotationIdentifier
} deriving (Int -> DeleteFile -> ShowS
[DeleteFile] -> ShowS
DeleteFile -> String
(Int -> DeleteFile -> ShowS)
-> (DeleteFile -> String)
-> ([DeleteFile] -> ShowS)
-> Show DeleteFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFile] -> ShowS
$cshowList :: [DeleteFile] -> ShowS
show :: DeleteFile -> String
$cshow :: DeleteFile -> String
showsPrec :: Int -> DeleteFile -> ShowS
$cshowsPrec :: Int -> DeleteFile -> ShowS
Show, ReadPrec [DeleteFile]
ReadPrec DeleteFile
Int -> ReadS DeleteFile
ReadS [DeleteFile]
(Int -> ReadS DeleteFile)
-> ReadS [DeleteFile]
-> ReadPrec DeleteFile
-> ReadPrec [DeleteFile]
-> Read DeleteFile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFile]
$creadListPrec :: ReadPrec [DeleteFile]
readPrec :: ReadPrec DeleteFile
$creadPrec :: ReadPrec DeleteFile
readList :: ReadS [DeleteFile]
$creadList :: ReadS [DeleteFile]
readsPrec :: Int -> ReadS DeleteFile
$creadsPrec :: Int -> ReadS DeleteFile
Read, DeleteFile -> DeleteFile -> Bool
(DeleteFile -> DeleteFile -> Bool)
-> (DeleteFile -> DeleteFile -> Bool) -> Eq DeleteFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFile -> DeleteFile -> Bool
$c/= :: DeleteFile -> DeleteFile -> Bool
== :: DeleteFile -> DeleteFile -> Bool
$c== :: DeleteFile -> DeleteFile -> Bool
Eq)
instance ToJSON DeleteFile where
toJSON :: DeleteFile -> Value
toJSON DeleteFile{Maybe ChangeAnnotationIdentifier
Maybe DeleteFileOptions
Uri
_annotationId :: Maybe ChangeAnnotationIdentifier
_options :: Maybe DeleteFileOptions
_uri :: Uri
$sel:_annotationId:DeleteFile :: DeleteFile -> Maybe ChangeAnnotationIdentifier
$sel:_options:DeleteFile :: DeleteFile -> Maybe DeleteFileOptions
$sel:_uri:DeleteFile :: DeleteFile -> Uri
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"kind" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Text
"delete" :: Text)
, Pair -> Maybe Pair
forall a. a -> Maybe a
Just (Pair -> Maybe Pair) -> Pair -> Maybe Pair
forall a b. (a -> b) -> a -> b
$ Key
"uri" Key -> Uri -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Uri
_uri
, (Key
"options" Key -> DeleteFileOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=) (DeleteFileOptions -> Pair)
-> Maybe DeleteFileOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe DeleteFileOptions
_options
, (Key
"annotationId" Key -> ChangeAnnotationIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=) (ChangeAnnotationIdentifier -> Pair)
-> Maybe ChangeAnnotationIdentifier -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ChangeAnnotationIdentifier
_annotationId
]
instance FromJSON DeleteFile where
parseJSON :: Value -> Parser DeleteFile
parseJSON = String
-> (Object -> Parser DeleteFile) -> Value -> Parser DeleteFile
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"DeleteFile" ((Object -> Parser DeleteFile) -> Value -> Parser DeleteFile)
-> (Object -> Parser DeleteFile) -> Value -> Parser DeleteFile
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Text
kind <- Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"kind"
Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
kind Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
"delete" :: Text))
(Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Expected kind \"delete\" but got " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
kind
Uri
_uri <- Object
o Object -> Key -> Parser Uri
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"uri"
Maybe DeleteFileOptions
_options <- Object
o Object -> Key -> Parser (Maybe DeleteFileOptions)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"options"
Maybe ChangeAnnotationIdentifier
_annotationId <- Object
o Object -> Key -> Parser (Maybe ChangeAnnotationIdentifier)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"annotationId"
DeleteFile -> Parser DeleteFile
forall (f :: * -> *) a. Applicative f => a -> f a
pure DeleteFile :: Uri
-> Maybe DeleteFileOptions
-> Maybe ChangeAnnotationIdentifier
-> DeleteFile
DeleteFile{Maybe ChangeAnnotationIdentifier
Maybe DeleteFileOptions
Uri
_annotationId :: Maybe ChangeAnnotationIdentifier
_options :: Maybe DeleteFileOptions
_uri :: Uri
$sel:_annotationId:DeleteFile :: Maybe ChangeAnnotationIdentifier
$sel:_options:DeleteFile :: Maybe DeleteFileOptions
$sel:_uri:DeleteFile :: Uri
..}
type DocumentChange = TextDocumentEdit |? CreateFile |? RenameFile |? DeleteFile
type WorkspaceEditMap = H.HashMap Uri (List TextEdit)
type ChangeAnnotationMap = H.HashMap ChangeAnnotationIdentifier ChangeAnnotation
data WorkspaceEdit =
WorkspaceEdit
{
WorkspaceEdit -> Maybe WorkspaceEditMap
_changes :: Maybe WorkspaceEditMap
, WorkspaceEdit -> Maybe (List DocumentChange)
_documentChanges :: Maybe (List DocumentChange)
, WorkspaceEdit -> Maybe ChangeAnnotationMap
_changeAnnotations :: Maybe ChangeAnnotationMap
} deriving (Int -> WorkspaceEdit -> ShowS
[WorkspaceEdit] -> ShowS
WorkspaceEdit -> String
(Int -> WorkspaceEdit -> ShowS)
-> (WorkspaceEdit -> String)
-> ([WorkspaceEdit] -> ShowS)
-> Show WorkspaceEdit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkspaceEdit] -> ShowS
$cshowList :: [WorkspaceEdit] -> ShowS
show :: WorkspaceEdit -> String
$cshow :: WorkspaceEdit -> String
showsPrec :: Int -> WorkspaceEdit -> ShowS
$cshowsPrec :: Int -> WorkspaceEdit -> ShowS
Show, ReadPrec [WorkspaceEdit]
ReadPrec WorkspaceEdit
Int -> ReadS WorkspaceEdit
ReadS [WorkspaceEdit]
(Int -> ReadS WorkspaceEdit)
-> ReadS [WorkspaceEdit]
-> ReadPrec WorkspaceEdit
-> ReadPrec [WorkspaceEdit]
-> Read WorkspaceEdit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkspaceEdit]
$creadListPrec :: ReadPrec [WorkspaceEdit]
readPrec :: ReadPrec WorkspaceEdit
$creadPrec :: ReadPrec WorkspaceEdit
readList :: ReadS [WorkspaceEdit]
$creadList :: ReadS [WorkspaceEdit]
readsPrec :: Int -> ReadS WorkspaceEdit
$creadsPrec :: Int -> ReadS WorkspaceEdit
Read, WorkspaceEdit -> WorkspaceEdit -> Bool
(WorkspaceEdit -> WorkspaceEdit -> Bool)
-> (WorkspaceEdit -> WorkspaceEdit -> Bool) -> Eq WorkspaceEdit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkspaceEdit -> WorkspaceEdit -> Bool
$c/= :: WorkspaceEdit -> WorkspaceEdit -> Bool
== :: WorkspaceEdit -> WorkspaceEdit -> Bool
$c== :: WorkspaceEdit -> WorkspaceEdit -> Bool
Eq)
instance Semigroup WorkspaceEdit where
(WorkspaceEdit Maybe WorkspaceEditMap
a Maybe (List DocumentChange)
b Maybe ChangeAnnotationMap
c) <> :: WorkspaceEdit -> WorkspaceEdit -> WorkspaceEdit
<> (WorkspaceEdit Maybe WorkspaceEditMap
a' Maybe (List DocumentChange)
b' Maybe ChangeAnnotationMap
c') = Maybe WorkspaceEditMap
-> Maybe (List DocumentChange)
-> Maybe ChangeAnnotationMap
-> WorkspaceEdit
WorkspaceEdit (Maybe WorkspaceEditMap
a Maybe WorkspaceEditMap
-> Maybe WorkspaceEditMap -> Maybe WorkspaceEditMap
forall a. Semigroup a => a -> a -> a
<> Maybe WorkspaceEditMap
a') (Maybe (List DocumentChange)
b Maybe (List DocumentChange)
-> Maybe (List DocumentChange) -> Maybe (List DocumentChange)
forall a. Semigroup a => a -> a -> a
<> Maybe (List DocumentChange)
b') (Maybe ChangeAnnotationMap
c Maybe ChangeAnnotationMap
-> Maybe ChangeAnnotationMap -> Maybe ChangeAnnotationMap
forall a. Semigroup a => a -> a -> a
<> Maybe ChangeAnnotationMap
c')
instance Monoid WorkspaceEdit where
mempty :: WorkspaceEdit
mempty = Maybe WorkspaceEditMap
-> Maybe (List DocumentChange)
-> Maybe ChangeAnnotationMap
-> WorkspaceEdit
WorkspaceEdit Maybe WorkspaceEditMap
forall a. Maybe a
Nothing Maybe (List DocumentChange)
forall a. Maybe a
Nothing Maybe ChangeAnnotationMap
forall a. Maybe a
Nothing
deriveJSON lspOptions ''WorkspaceEdit
data ResourceOperationKind
= ResourceOperationCreate
| ResourceOperationRename
| ResourceOperationDelete
deriving (ReadPrec [ResourceOperationKind]
ReadPrec ResourceOperationKind
Int -> ReadS ResourceOperationKind
ReadS [ResourceOperationKind]
(Int -> ReadS ResourceOperationKind)
-> ReadS [ResourceOperationKind]
-> ReadPrec ResourceOperationKind
-> ReadPrec [ResourceOperationKind]
-> Read ResourceOperationKind
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceOperationKind]
$creadListPrec :: ReadPrec [ResourceOperationKind]
readPrec :: ReadPrec ResourceOperationKind
$creadPrec :: ReadPrec ResourceOperationKind
readList :: ReadS [ResourceOperationKind]
$creadList :: ReadS [ResourceOperationKind]
readsPrec :: Int -> ReadS ResourceOperationKind
$creadsPrec :: Int -> ReadS ResourceOperationKind
Read, Int -> ResourceOperationKind -> ShowS
[ResourceOperationKind] -> ShowS
ResourceOperationKind -> String
(Int -> ResourceOperationKind -> ShowS)
-> (ResourceOperationKind -> String)
-> ([ResourceOperationKind] -> ShowS)
-> Show ResourceOperationKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceOperationKind] -> ShowS
$cshowList :: [ResourceOperationKind] -> ShowS
show :: ResourceOperationKind -> String
$cshow :: ResourceOperationKind -> String
showsPrec :: Int -> ResourceOperationKind -> ShowS
$cshowsPrec :: Int -> ResourceOperationKind -> ShowS
Show, ResourceOperationKind -> ResourceOperationKind -> Bool
(ResourceOperationKind -> ResourceOperationKind -> Bool)
-> (ResourceOperationKind -> ResourceOperationKind -> Bool)
-> Eq ResourceOperationKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceOperationKind -> ResourceOperationKind -> Bool
$c/= :: ResourceOperationKind -> ResourceOperationKind -> Bool
== :: ResourceOperationKind -> ResourceOperationKind -> Bool
$c== :: ResourceOperationKind -> ResourceOperationKind -> Bool
Eq)
instance ToJSON ResourceOperationKind where
toJSON :: ResourceOperationKind -> Value
toJSON ResourceOperationKind
ResourceOperationCreate = Text -> Value
String Text
"create"
toJSON ResourceOperationKind
ResourceOperationRename = Text -> Value
String Text
"rename"
toJSON ResourceOperationKind
ResourceOperationDelete = Text -> Value
String Text
"delete"
instance FromJSON ResourceOperationKind where
parseJSON :: Value -> Parser ResourceOperationKind
parseJSON (String Text
"create") = ResourceOperationKind -> Parser ResourceOperationKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure ResourceOperationKind
ResourceOperationCreate
parseJSON (String Text
"rename") = ResourceOperationKind -> Parser ResourceOperationKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure ResourceOperationKind
ResourceOperationRename
parseJSON (String Text
"delete") = ResourceOperationKind -> Parser ResourceOperationKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure ResourceOperationKind
ResourceOperationDelete
parseJSON Value
_ = String -> Parser ResourceOperationKind
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"ResourceOperationKind"
data FailureHandlingKind
= FailureHandlingAbort
| FailureHandlingTransactional
| FailureHandlingTextOnlyTransactional
| FailureHandlingUndo
deriving (ReadPrec [FailureHandlingKind]
ReadPrec FailureHandlingKind
Int -> ReadS FailureHandlingKind
ReadS [FailureHandlingKind]
(Int -> ReadS FailureHandlingKind)
-> ReadS [FailureHandlingKind]
-> ReadPrec FailureHandlingKind
-> ReadPrec [FailureHandlingKind]
-> Read FailureHandlingKind
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureHandlingKind]
$creadListPrec :: ReadPrec [FailureHandlingKind]
readPrec :: ReadPrec FailureHandlingKind
$creadPrec :: ReadPrec FailureHandlingKind
readList :: ReadS [FailureHandlingKind]
$creadList :: ReadS [FailureHandlingKind]
readsPrec :: Int -> ReadS FailureHandlingKind
$creadsPrec :: Int -> ReadS FailureHandlingKind
Read, Int -> FailureHandlingKind -> ShowS
[FailureHandlingKind] -> ShowS
FailureHandlingKind -> String
(Int -> FailureHandlingKind -> ShowS)
-> (FailureHandlingKind -> String)
-> ([FailureHandlingKind] -> ShowS)
-> Show FailureHandlingKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureHandlingKind] -> ShowS
$cshowList :: [FailureHandlingKind] -> ShowS
show :: FailureHandlingKind -> String
$cshow :: FailureHandlingKind -> String
showsPrec :: Int -> FailureHandlingKind -> ShowS
$cshowsPrec :: Int -> FailureHandlingKind -> ShowS
Show, FailureHandlingKind -> FailureHandlingKind -> Bool
(FailureHandlingKind -> FailureHandlingKind -> Bool)
-> (FailureHandlingKind -> FailureHandlingKind -> Bool)
-> Eq FailureHandlingKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureHandlingKind -> FailureHandlingKind -> Bool
$c/= :: FailureHandlingKind -> FailureHandlingKind -> Bool
== :: FailureHandlingKind -> FailureHandlingKind -> Bool
$c== :: FailureHandlingKind -> FailureHandlingKind -> Bool
Eq)
instance ToJSON FailureHandlingKind where
toJSON :: FailureHandlingKind -> Value
toJSON FailureHandlingKind
FailureHandlingAbort = Text -> Value
String Text
"abort"
toJSON FailureHandlingKind
FailureHandlingTransactional = Text -> Value
String Text
"transactional"
toJSON FailureHandlingKind
FailureHandlingTextOnlyTransactional = Text -> Value
String Text
"textOnlyTransactional"
toJSON FailureHandlingKind
FailureHandlingUndo = Text -> Value
String Text
"undo"
instance FromJSON FailureHandlingKind where
parseJSON :: Value -> Parser FailureHandlingKind
parseJSON (String Text
"abort") = FailureHandlingKind -> Parser FailureHandlingKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FailureHandlingKind
FailureHandlingAbort
parseJSON (String Text
"transactional") = FailureHandlingKind -> Parser FailureHandlingKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FailureHandlingKind
FailureHandlingTransactional
parseJSON (String Text
"textOnlyTransactional") = FailureHandlingKind -> Parser FailureHandlingKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FailureHandlingKind
FailureHandlingTextOnlyTransactional
parseJSON (String Text
"undo") = FailureHandlingKind -> Parser FailureHandlingKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure FailureHandlingKind
FailureHandlingUndo
parseJSON Value
_ = String -> Parser FailureHandlingKind
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"FailureHandlingKind"
data WorkspaceEditChangeAnnotationClientCapabilities =
WorkspaceEditChangeAnnotationClientCapabilities
{
WorkspaceEditChangeAnnotationClientCapabilities -> Maybe Bool
groupsOnLabel :: Maybe Bool
} deriving (Int -> WorkspaceEditChangeAnnotationClientCapabilities -> ShowS
[WorkspaceEditChangeAnnotationClientCapabilities] -> ShowS
WorkspaceEditChangeAnnotationClientCapabilities -> String
(Int -> WorkspaceEditChangeAnnotationClientCapabilities -> ShowS)
-> (WorkspaceEditChangeAnnotationClientCapabilities -> String)
-> ([WorkspaceEditChangeAnnotationClientCapabilities] -> ShowS)
-> Show WorkspaceEditChangeAnnotationClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkspaceEditChangeAnnotationClientCapabilities] -> ShowS
$cshowList :: [WorkspaceEditChangeAnnotationClientCapabilities] -> ShowS
show :: WorkspaceEditChangeAnnotationClientCapabilities -> String
$cshow :: WorkspaceEditChangeAnnotationClientCapabilities -> String
showsPrec :: Int -> WorkspaceEditChangeAnnotationClientCapabilities -> ShowS
$cshowsPrec :: Int -> WorkspaceEditChangeAnnotationClientCapabilities -> ShowS
Show, ReadPrec [WorkspaceEditChangeAnnotationClientCapabilities]
ReadPrec WorkspaceEditChangeAnnotationClientCapabilities
Int -> ReadS WorkspaceEditChangeAnnotationClientCapabilities
ReadS [WorkspaceEditChangeAnnotationClientCapabilities]
(Int -> ReadS WorkspaceEditChangeAnnotationClientCapabilities)
-> ReadS [WorkspaceEditChangeAnnotationClientCapabilities]
-> ReadPrec WorkspaceEditChangeAnnotationClientCapabilities
-> ReadPrec [WorkspaceEditChangeAnnotationClientCapabilities]
-> Read WorkspaceEditChangeAnnotationClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkspaceEditChangeAnnotationClientCapabilities]
$creadListPrec :: ReadPrec [WorkspaceEditChangeAnnotationClientCapabilities]
readPrec :: ReadPrec WorkspaceEditChangeAnnotationClientCapabilities
$creadPrec :: ReadPrec WorkspaceEditChangeAnnotationClientCapabilities
readList :: ReadS [WorkspaceEditChangeAnnotationClientCapabilities]
$creadList :: ReadS [WorkspaceEditChangeAnnotationClientCapabilities]
readsPrec :: Int -> ReadS WorkspaceEditChangeAnnotationClientCapabilities
$creadsPrec :: Int -> ReadS WorkspaceEditChangeAnnotationClientCapabilities
Read, WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool
(WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool)
-> (WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool)
-> Eq WorkspaceEditChangeAnnotationClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool
$c/= :: WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool
== :: WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool
$c== :: WorkspaceEditChangeAnnotationClientCapabilities
-> WorkspaceEditChangeAnnotationClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''WorkspaceEditChangeAnnotationClientCapabilities
data WorkspaceEditClientCapabilities =
WorkspaceEditClientCapabilities
{ WorkspaceEditClientCapabilities -> Maybe Bool
_documentChanges :: Maybe Bool
, WorkspaceEditClientCapabilities
-> Maybe (List ResourceOperationKind)
_resourceOperations :: Maybe (List ResourceOperationKind)
, WorkspaceEditClientCapabilities -> Maybe FailureHandlingKind
_failureHandling :: Maybe FailureHandlingKind
, WorkspaceEditClientCapabilities -> Maybe Bool
_normalizesLineEndings :: Maybe Bool
, WorkspaceEditClientCapabilities
-> Maybe WorkspaceEditChangeAnnotationClientCapabilities
_changeAnnotationSupport :: Maybe WorkspaceEditChangeAnnotationClientCapabilities
} deriving (Int -> WorkspaceEditClientCapabilities -> ShowS
[WorkspaceEditClientCapabilities] -> ShowS
WorkspaceEditClientCapabilities -> String
(Int -> WorkspaceEditClientCapabilities -> ShowS)
-> (WorkspaceEditClientCapabilities -> String)
-> ([WorkspaceEditClientCapabilities] -> ShowS)
-> Show WorkspaceEditClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkspaceEditClientCapabilities] -> ShowS
$cshowList :: [WorkspaceEditClientCapabilities] -> ShowS
show :: WorkspaceEditClientCapabilities -> String
$cshow :: WorkspaceEditClientCapabilities -> String
showsPrec :: Int -> WorkspaceEditClientCapabilities -> ShowS
$cshowsPrec :: Int -> WorkspaceEditClientCapabilities -> ShowS
Show, ReadPrec [WorkspaceEditClientCapabilities]
ReadPrec WorkspaceEditClientCapabilities
Int -> ReadS WorkspaceEditClientCapabilities
ReadS [WorkspaceEditClientCapabilities]
(Int -> ReadS WorkspaceEditClientCapabilities)
-> ReadS [WorkspaceEditClientCapabilities]
-> ReadPrec WorkspaceEditClientCapabilities
-> ReadPrec [WorkspaceEditClientCapabilities]
-> Read WorkspaceEditClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkspaceEditClientCapabilities]
$creadListPrec :: ReadPrec [WorkspaceEditClientCapabilities]
readPrec :: ReadPrec WorkspaceEditClientCapabilities
$creadPrec :: ReadPrec WorkspaceEditClientCapabilities
readList :: ReadS [WorkspaceEditClientCapabilities]
$creadList :: ReadS [WorkspaceEditClientCapabilities]
readsPrec :: Int -> ReadS WorkspaceEditClientCapabilities
$creadsPrec :: Int -> ReadS WorkspaceEditClientCapabilities
Read, WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool
(WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool)
-> (WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool)
-> Eq WorkspaceEditClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool
$c/= :: WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool
== :: WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool
$c== :: WorkspaceEditClientCapabilities
-> WorkspaceEditClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''WorkspaceEditClientCapabilities
data ApplyWorkspaceEditParams =
ApplyWorkspaceEditParams
{
ApplyWorkspaceEditParams -> Maybe Text
_label :: Maybe Text
, ApplyWorkspaceEditParams -> WorkspaceEdit
_edit :: WorkspaceEdit
} deriving (Int -> ApplyWorkspaceEditParams -> ShowS
[ApplyWorkspaceEditParams] -> ShowS
ApplyWorkspaceEditParams -> String
(Int -> ApplyWorkspaceEditParams -> ShowS)
-> (ApplyWorkspaceEditParams -> String)
-> ([ApplyWorkspaceEditParams] -> ShowS)
-> Show ApplyWorkspaceEditParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplyWorkspaceEditParams] -> ShowS
$cshowList :: [ApplyWorkspaceEditParams] -> ShowS
show :: ApplyWorkspaceEditParams -> String
$cshow :: ApplyWorkspaceEditParams -> String
showsPrec :: Int -> ApplyWorkspaceEditParams -> ShowS
$cshowsPrec :: Int -> ApplyWorkspaceEditParams -> ShowS
Show, ReadPrec [ApplyWorkspaceEditParams]
ReadPrec ApplyWorkspaceEditParams
Int -> ReadS ApplyWorkspaceEditParams
ReadS [ApplyWorkspaceEditParams]
(Int -> ReadS ApplyWorkspaceEditParams)
-> ReadS [ApplyWorkspaceEditParams]
-> ReadPrec ApplyWorkspaceEditParams
-> ReadPrec [ApplyWorkspaceEditParams]
-> Read ApplyWorkspaceEditParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplyWorkspaceEditParams]
$creadListPrec :: ReadPrec [ApplyWorkspaceEditParams]
readPrec :: ReadPrec ApplyWorkspaceEditParams
$creadPrec :: ReadPrec ApplyWorkspaceEditParams
readList :: ReadS [ApplyWorkspaceEditParams]
$creadList :: ReadS [ApplyWorkspaceEditParams]
readsPrec :: Int -> ReadS ApplyWorkspaceEditParams
$creadsPrec :: Int -> ReadS ApplyWorkspaceEditParams
Read, ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool
(ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool)
-> (ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool)
-> Eq ApplyWorkspaceEditParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool
$c/= :: ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool
== :: ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool
$c== :: ApplyWorkspaceEditParams -> ApplyWorkspaceEditParams -> Bool
Eq)
deriveJSON lspOptions ''ApplyWorkspaceEditParams
data ApplyWorkspaceEditResponseBody =
ApplyWorkspaceEditResponseBody
{
ApplyWorkspaceEditResponseBody -> Bool
_applied :: Bool
, ApplyWorkspaceEditResponseBody -> Maybe Text
_failureReason :: Maybe Text
, ApplyWorkspaceEditResponseBody -> Maybe UInt
_failedChange :: Maybe UInt
} deriving (Int -> ApplyWorkspaceEditResponseBody -> ShowS
[ApplyWorkspaceEditResponseBody] -> ShowS
ApplyWorkspaceEditResponseBody -> String
(Int -> ApplyWorkspaceEditResponseBody -> ShowS)
-> (ApplyWorkspaceEditResponseBody -> String)
-> ([ApplyWorkspaceEditResponseBody] -> ShowS)
-> Show ApplyWorkspaceEditResponseBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplyWorkspaceEditResponseBody] -> ShowS
$cshowList :: [ApplyWorkspaceEditResponseBody] -> ShowS
show :: ApplyWorkspaceEditResponseBody -> String
$cshow :: ApplyWorkspaceEditResponseBody -> String
showsPrec :: Int -> ApplyWorkspaceEditResponseBody -> ShowS
$cshowsPrec :: Int -> ApplyWorkspaceEditResponseBody -> ShowS
Show, ReadPrec [ApplyWorkspaceEditResponseBody]
ReadPrec ApplyWorkspaceEditResponseBody
Int -> ReadS ApplyWorkspaceEditResponseBody
ReadS [ApplyWorkspaceEditResponseBody]
(Int -> ReadS ApplyWorkspaceEditResponseBody)
-> ReadS [ApplyWorkspaceEditResponseBody]
-> ReadPrec ApplyWorkspaceEditResponseBody
-> ReadPrec [ApplyWorkspaceEditResponseBody]
-> Read ApplyWorkspaceEditResponseBody
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplyWorkspaceEditResponseBody]
$creadListPrec :: ReadPrec [ApplyWorkspaceEditResponseBody]
readPrec :: ReadPrec ApplyWorkspaceEditResponseBody
$creadPrec :: ReadPrec ApplyWorkspaceEditResponseBody
readList :: ReadS [ApplyWorkspaceEditResponseBody]
$creadList :: ReadS [ApplyWorkspaceEditResponseBody]
readsPrec :: Int -> ReadS ApplyWorkspaceEditResponseBody
$creadsPrec :: Int -> ReadS ApplyWorkspaceEditResponseBody
Read, ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool
(ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool)
-> (ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool)
-> Eq ApplyWorkspaceEditResponseBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool
$c/= :: ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool
== :: ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool
$c== :: ApplyWorkspaceEditResponseBody
-> ApplyWorkspaceEditResponseBody -> Bool
Eq)
deriveJSON lspOptions ''ApplyWorkspaceEditResponseBody
applyTextEdit :: TextEdit -> Text -> Text
applyTextEdit :: TextEdit -> Text -> Text
applyTextEdit (TextEdit (Range Position
sp Position
ep) Text
newText) Text
oldText =
let (Text
_, Text
afterEnd) = Position -> Text -> (Text, Text)
splitAtPos Position
ep Text
oldText
(Text
beforeStart, Text
_) = Position -> Text -> (Text, Text)
splitAtPos Position
sp Text
oldText
in [Text] -> Text
forall a. Monoid a => [a] -> a
mconcat [Text
beforeStart, Text
newText, Text
afterEnd]
where
splitAtPos :: Position -> Text -> (Text, Text)
splitAtPos :: Position -> Text -> (Text, Text)
splitAtPos (Position UInt
sl UInt
sc) Text
t =
let index :: UInt
index = UInt
sc UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt -> Text -> UInt
startLineIndex UInt
sl Text
t
in Int -> Text -> (Text, Text)
T.splitAt (UInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral UInt
index) Text
t
startLineIndex :: UInt -> Text -> UInt
startLineIndex :: UInt -> Text -> UInt
startLineIndex UInt
0 Text
_ = UInt
0
startLineIndex UInt
line Text
t' =
case (Char -> Bool) -> Text -> Maybe Int
T.findIndex (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\n') Text
t' of
Just Int
i -> Int -> UInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt
1 UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt -> Text -> UInt
startLineIndex (UInt
line UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
- UInt
1) (Int -> Text -> Text
T.drop (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Text
t')
Maybe Int
Nothing -> Int -> UInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UInt) -> Int -> UInt
forall a b. (a -> b) -> a -> b
$ Text -> Int
T.length Text
t'
editTextEdit :: TextEdit -> TextEdit -> TextEdit
editTextEdit :: TextEdit -> TextEdit -> TextEdit
editTextEdit (TextEdit Range
origRange Text
origText) TextEdit
innerEdit =
let newText :: Text
newText = TextEdit -> Text -> Text
applyTextEdit TextEdit
innerEdit Text
origText
in Range -> Text -> TextEdit
TextEdit Range
origRange Text
newText