Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/StaticLS/ProtoLSP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import Data.HashMap.Strict (HashMap)
import Data.HashMap.Strict qualified as HashMap
import Data.LineCol (LineCol (..))
import Data.LineColRange
import Data.Map qualified as Map
import Data.Path (AbsPath)
import Data.Path qualified as Path
import Data.Pos
Expand Down Expand Up @@ -154,23 +155,18 @@ editToProto rope edit =
changeToProto rope <$> Edit.getChanges edit

-- TODO: convert fsEdits

sourceEditToProto :: SourceEdit -> StaticLsM LSP.WorkspaceEdit
sourceEditToProto SourceEdit {fileEdits} = do
documentChanges <- for (HashMap.toList fileEdits) \(path, edit) -> do
changesKVs <- for (HashMap.toList fileEdits) $ \(path, edit) -> do
rope <- IDE.Monad.getSourceRope path
pure
LSP.TextDocumentEdit
{ _textDocument =
LSP.OptionalVersionedTextDocumentIdentifier
{ _uri = absPathToUri path
, _version = LSP.InR LSP.Null
}
, _edits = LSP.InL <$> editToProto rope edit
}
let edits = editToProto rope edit
pure (absPathToUri path, edits)

pure
LSP.WorkspaceEdit
{ _changes = Nothing
, _documentChanges = Just (fmap LSP.InL documentChanges)
{ _changes = Just (Map.fromList changesKVs)
, _documentChanges = Nothing
, _changeAnnotations = Nothing
}

Expand Down
Loading