File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
ghcide/src/Development/IDE/Plugin Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ module Development.IDE.Plugin.CodeAction.ExactPrint
1010 -- * Utilities
1111 appendConstraint ,
1212 extendImport ,
13- )
13+ rewriteToWEdit )
1414where
1515
1616import Control.Applicative
@@ -32,6 +32,7 @@ import OccName
3232import Outputable (ppr , showSDocUnsafe )
3333import Data.Generics (listify )
3434import 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+
6474srcSpanToRange :: SrcSpan -> Maybe Range
6575srcSpanToRange (UnhelpfulSpan _) = Nothing
6676srcSpanToRange (RealSrcSpan real) = Just $ realSrcSpanToRange real
Original file line number Diff line number Diff 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 =
You can’t perform that action at this time.
0 commit comments