@@ -18,6 +18,9 @@ import Development.IDE.GHC.Compat.ExactPrint
18
18
import GHC.Parser.Annotation (DeltaPos (.. ),
19
19
EpAnn (.. ),
20
20
EpAnnComments (EpaComments ))
21
+ #if MIN_VERSION_ghc(9,11,0)
22
+ import GHC.Parser.Annotation (EpToken (.. ))
23
+ #endif
21
24
import Ide.PluginUtils (subRange )
22
25
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl )
23
26
@@ -217,7 +220,11 @@ prettyGADTDecl df decl =
217
220
adjustDataDecl DataDecl {.. } = DataDecl
218
221
{ tcdDExt = adjustWhere tcdDExt
219
222
, tcdDataDefn = tcdDataDefn
220
- { dd_cons =
223
+ {
224
+ #if MIN_VERSION_ghc(9,11,0)
225
+ dd_ext = adjustDefnWhere (dd_ext tcdDataDefn),
226
+ #endif
227
+ dd_cons =
221
228
fmap adjustCon (dd_cons tcdDataDefn)
222
229
}
223
230
, ..
@@ -228,7 +235,7 @@ prettyGADTDecl df decl =
228
235
adjustCon :: LConDecl GP -> LConDecl GP
229
236
#if MIN_VERSION_ghc(9,11,0)
230
237
adjustCon (L _ r) =
231
- let delta = EpaDelta (UnhelpfulSpan UnhelpfulNoLocationInfo ) (DifferentLine 1 3 ) []
238
+ let delta = EpaDelta (UnhelpfulSpan UnhelpfulNoLocationInfo ) (DifferentLine 1 2 ) []
232
239
in L (EpAnn delta (AnnListItem [] ) (EpaComments [] )) r
233
240
#elif MIN_VERSION_ghc(9,9,0)
234
241
adjustCon (L _ r) =
@@ -255,11 +262,24 @@ prettyGADTDecl df decl =
255
262
else AddEpAnn ann l
256
263
)
257
264
#endif
265
+
266
+ #if MIN_VERSION_ghc(9,11,0)
267
+ adjustDefnWhere annDataDefn
268
+ | andd_where annDataDefn == NoEpTok = annDataDefn
269
+ | otherwise = annDataDefn {andd_where = andd_where'}
270
+ where
271
+ (EpTok (EpaSpan aw)) = andd_where annDataDefn
272
+ andd_where' = EpTok (EpaDelta aw (SameLine 1 ) [] )
273
+ #endif
258
274
-- Remove the first extra line if exist
259
275
removeExtraEmptyLine s = case stripInfix " \n\n " s of
260
276
Just (x, xs) -> x <> " \n " <> xs
261
277
Nothing -> s
262
278
279
+ #if MIN_VERSION_ghc(9,11,0)
280
+
281
+ #endif
282
+
263
283
wrap :: forall a . WrapXRec GP a => a -> XRec GP a
264
284
wrap = wrapXRec @ GP
265
285
wrapCtxt = id
0 commit comments