@@ -27,6 +27,7 @@ module StaticLS.ProtoLSP (
2727)
2828where
2929
30+ import Data.Map qualified as Map
3031import Control.Monad ((<=<) )
3132import Control.Monad.Catch
3233import Data.Aeson qualified as Aeson
@@ -154,25 +155,19 @@ editToProto rope edit =
154155 changeToProto rope <$> Edit. getChanges edit
155156
156157-- TODO: convert fsEdits
158+
157159sourceEditToProto :: SourceEdit -> StaticLsM LSP. WorkspaceEdit
158- sourceEditToProto SourceEdit {fileEdits} = do
159- documentChanges <- for (HashMap. toList fileEdits) \ (path, edit) -> do
160- rope <- IDE.Monad. getSourceRope path
161- pure
162- LSP. TextDocumentEdit
163- { _textDocument =
164- LSP. OptionalVersionedTextDocumentIdentifier
165- { _uri = absPathToUri path
166- , _version = LSP. InR LSP. Null
167- }
168- , _edits = LSP. InL <$> editToProto rope edit
169- }
170- pure
171- LSP. WorkspaceEdit
172- { _changes = Nothing
173- , _documentChanges = Just (fmap LSP. InL documentChanges)
174- , _changeAnnotations = Nothing
175- }
160+ sourceEditToProto SourceEdit { fileEdits } = do
161+ changesKVs <- for (HashMap. toList fileEdits) $ \ (path, edit) -> do
162+ rope <- IDE.Monad. getSourceRope path
163+ let edits = editToProto rope edit
164+ pure (absPathToUri path, edits)
165+
166+ pure LSP. WorkspaceEdit
167+ { _changes = Just (Map. fromList changesKVs)
168+ , _documentChanges = Nothing
169+ , _changeAnnotations = Nothing
170+ }
176171
177172assistToCodeAction :: Assist -> StaticLsM LSP. CodeAction
178173assistToCodeAction Assist {label, sourceEdit} = do
0 commit comments