File tree 2 files changed +12
-2
lines changed
ghcide/src/Development/IDE/Plugin
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
10
10
-- * Utilities
11
11
appendConstraint ,
12
12
extendImport ,
13
- )
13
+ rewriteToWEdit )
14
14
where
15
15
16
16
import Control.Applicative
@@ -32,6 +32,7 @@ import OccName
32
32
import Outputable (ppr , showSDocUnsafe )
33
33
import Data.Generics (listify )
34
34
import Development.IDE.Spans.Common (showNameWithoutUniques )
35
+ import GHC.Exts (IsList (fromList ))
35
36
36
37
------------------------------------------------------------------------------
37
38
@@ -61,6 +62,15 @@ rewriteToEdit dflags anns (Rewrite dst f) = do
61
62
]
62
63
pure editMap
63
64
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
+
64
74
srcSpanToRange :: SrcSpan -> Maybe Range
65
75
srcSpanToRange (UnhelpfulSpan _) = Nothing
66
76
srcSpanToRange (RealSrcSpan real) = Just $ realSrcSpanToRange real
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ extendImportHandler' ideState ExtendImport {..}
178
178
imp <- liftMaybe $ find (isWantedModule wantedModule) imps
179
179
wedit <-
180
180
liftEither $
181
- rewriteToEdit df doc (annsA ps) $
181
+ rewriteToWEdit df doc (annsA ps) $
182
182
extendImport (T. unpack <$> thingParent) (T. unpack newThing) imp
183
183
return (WorkspaceApplyEdit , ApplyWorkspaceEditParams wedit)
184
184
| otherwise =
You can’t perform that action at this time.
0 commit comments