File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
ghcide/src/Development/IDE/Plugin Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 6
6
module Development.IDE.Plugin.CodeAction.ExactPrint
7
7
( Rewrite (.. ),
8
8
rewriteToEdit ,
9
+ rewriteToWEdit ,
9
10
transferAnn ,
10
11
11
12
-- * Utilities
@@ -41,6 +42,7 @@ import Development.IDE.Spans.Common
41
42
import Development.IDE.GHC.Error
42
43
import Safe (lastMay )
43
44
import Data.Generics (listify )
45
+ import GHC.Exts (IsList (fromList ))
44
46
45
47
------------------------------------------------------------------------------
46
48
@@ -57,7 +59,7 @@ data Rewrite where
57
59
58
60
------------------------------------------------------------------------------
59
61
60
- -- | Convert a 'Rewrite' into a 'WorkspaceEdit '.
62
+ -- | Convert a 'Rewrite' into a list of '[TextEdit] '.
61
63
rewriteToEdit ::
62
64
DynFlags ->
63
65
Anns ->
@@ -72,6 +74,16 @@ rewriteToEdit dflags anns (Rewrite dst f) = do
72
74
]
73
75
pure editMap
74
76
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
+
75
87
------------------------------------------------------------------------------
76
88
77
89
-- | Fix the parentheses around a type context
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