{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module Language.LSP.Types.WorkspaceEdit where
import Data.Aeson
import Data.Aeson.TH
import qualified Data.HashMap.Strict as H
import Data.Text (Text)
import qualified Data.Text as T
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 TextDocumentEdit =
TextDocumentEdit
{ TextDocumentEdit -> VersionedTextDocumentIdentifier
_textDocument :: VersionedTextDocumentIdentifier
, TextDocumentEdit -> List TextEdit
_edits :: List TextEdit
} 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
type WorkspaceEditMap = H.HashMap Uri (List TextEdit)
data WorkspaceEdit =
WorkspaceEdit
{ WorkspaceEdit -> Maybe WorkspaceEditMap
_changes :: Maybe WorkspaceEditMap
, WorkspaceEdit -> Maybe (List TextDocumentEdit)
_documentChanges :: Maybe (List TextDocumentEdit)
} 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 TextDocumentEdit)
b) <> :: WorkspaceEdit -> WorkspaceEdit -> WorkspaceEdit
<> (WorkspaceEdit Maybe WorkspaceEditMap
c Maybe (List TextDocumentEdit)
d) = Maybe WorkspaceEditMap
-> Maybe (List TextDocumentEdit) -> WorkspaceEdit
WorkspaceEdit (Maybe WorkspaceEditMap
a Maybe WorkspaceEditMap
-> Maybe WorkspaceEditMap -> Maybe WorkspaceEditMap
forall a. Semigroup a => a -> a -> a
<> Maybe WorkspaceEditMap
c) (Maybe (List TextDocumentEdit)
b Maybe (List TextDocumentEdit)
-> Maybe (List TextDocumentEdit) -> Maybe (List TextDocumentEdit)
forall a. Semigroup a => a -> a -> a
<> Maybe (List TextDocumentEdit)
d)
instance Monoid WorkspaceEdit where
mempty :: WorkspaceEdit
mempty = Maybe WorkspaceEditMap
-> Maybe (List TextDocumentEdit) -> WorkspaceEdit
WorkspaceEdit Maybe WorkspaceEditMap
forall a. Maybe a
Nothing Maybe (List TextDocumentEdit)
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
_ = Parser ResourceOperationKind
forall a. Monoid a => a
mempty
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
_ = Parser FailureHandlingKind
forall a. Monoid a => a
mempty
data WorkspaceEditClientCapabilities =
WorkspaceEditClientCapabilities
{ WorkspaceEditClientCapabilities -> Maybe Bool
_documentChanges :: Maybe Bool
, WorkspaceEditClientCapabilities
-> Maybe (List ResourceOperationKind)
_resourceOperations :: Maybe (List ResourceOperationKind)
, WorkspaceEditClientCapabilities -> Maybe FailureHandlingKind
_failureHandling :: Maybe FailureHandlingKind
} 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
} 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 Int
sl Int
sc) Text
t =
let index :: Int
index = Int
sc Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int -> Text -> Int
forall t. (Eq t, Num t) => t -> Text -> Int
startLineIndex Int
sl Text
t
in Int -> Text -> (Text, Text)
T.splitAt Int
index Text
t
startLineIndex :: t -> Text -> Int
startLineIndex t
0 Text
_ = Int
0
startLineIndex t
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
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ t -> Text -> Int
startLineIndex (t
line t -> t -> t
forall a. Num a => a -> a -> a
- t
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
0
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