Skip to content

Commit 25935cd

Browse files
committed
Follow changes in rewriteToEdit
1 parent e03815f commit 25935cd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ghcide/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
module Development.IDE.Plugin.CodeAction.ExactPrint
77
( Rewrite (..),
88
rewriteToEdit,
9+
rewriteToWEdit,
910
transferAnn,
1011

1112
-- * Utilities
@@ -41,6 +42,7 @@ import Development.IDE.Spans.Common
4142
import Development.IDE.GHC.Error
4243
import Safe (lastMay)
4344
import Data.Generics (listify)
45+
import GHC.Exts (IsList (fromList))
4446

4547
------------------------------------------------------------------------------
4648

@@ -57,7 +59,7 @@ data Rewrite where
5759

5860
------------------------------------------------------------------------------
5961

60-
-- | Convert a 'Rewrite' into a 'WorkspaceEdit'.
62+
-- | Convert a 'Rewrite' into a list of '[TextEdit]'.
6163
rewriteToEdit ::
6264
DynFlags ->
6365
Anns ->
@@ -72,6 +74,16 @@ rewriteToEdit dflags anns (Rewrite dst f) = do
7274
]
7375
pure editMap
7476

77+
-- | Convert a 'Rewrite' into a 'WorkspaceEdit'
78+
rewriteToWEdit :: DynFlags -> Uri -> Anns -> Rewrite -> Either String WorkspaceEdit
79+
rewriteToWEdit dflags uri anns r = do
80+
edits <- rewriteToEdit dflags anns r
81+
return $
82+
WorkspaceEdit
83+
{ _changes = Just (fromList [(uri, List edits)])
84+
, _documentChanges = Nothing
85+
}
86+
7587
------------------------------------------------------------------------------
7688

7789
-- | Fix the parentheses around a type context

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ extendImportHandler' ideState ExtendImport {..}
178178
imp <- liftMaybe $ find (isWantedModule wantedModule) imps
179179
wedit <-
180180
liftEither $
181-
rewriteToEdit df doc (annsA ps) $
181+
rewriteToWEdit df doc (annsA ps) $
182182
extendImport (T.unpack <$> thingParent) (T.unpack newThing) imp
183183
return (WorkspaceApplyEdit, ApplyWorkspaceEditParams wedit)
184184
| otherwise =

0 commit comments

Comments
 (0)