Skip to content

Commit 284e6c9

Browse files
committed
Follow changes in rewriteToEdit
1 parent 11630ad commit 284e6c9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Development.IDE.Plugin.CodeAction.ExactPrint
1010
-- * Utilities
1111
appendConstraint,
1212
extendImport,
13-
)
13+
rewriteToWEdit)
1414
where
1515

1616
import Control.Applicative
@@ -32,6 +32,7 @@ import OccName
3232
import Outputable (ppr, showSDocUnsafe)
3333
import Data.Generics (listify)
3434
import Development.IDE.Spans.Common (showNameWithoutUniques)
35+
import GHC.Exts (IsList (fromList))
3536

3637
------------------------------------------------------------------------------
3738

@@ -61,6 +62,15 @@ rewriteToEdit dflags anns (Rewrite dst f) = do
6162
]
6263
pure editMap
6364

65+
rewriteToWEdit :: DynFlags -> Uri -> Anns -> Rewrite -> Either String WorkspaceEdit
66+
rewriteToWEdit dflags uri anns r = do
67+
edits <- rewriteToEdit dflags anns r
68+
return $
69+
WorkspaceEdit
70+
{ _changes = Just (fromList [(uri, List edits)])
71+
, _documentChanges = Nothing
72+
}
73+
6474
srcSpanToRange :: SrcSpan -> Maybe Range
6575
srcSpanToRange (UnhelpfulSpan _) = Nothing
6676
srcSpanToRange (RealSrcSpan real) = Just $ realSrcSpanToRange real

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

+1-1
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)