@@ -18,6 +18,9 @@ import Development.IDE.GHC.Compat.ExactPrint
1818import GHC.Parser.Annotation (DeltaPos (.. ),
1919 EpAnn (.. ),
2020 EpAnnComments (EpaComments ))
21+ #if MIN_VERSION_ghc(9,11,0)
22+ import GHC.Parser.Annotation (EpToken (.. ))
23+ #endif
2124import Ide.PluginUtils (subRange )
2225import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl )
2326
@@ -217,7 +220,11 @@ prettyGADTDecl df decl =
217220 adjustDataDecl DataDecl {.. } = DataDecl
218221 { tcdDExt = adjustWhere tcdDExt
219222 , 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 =
221228 fmap adjustCon (dd_cons tcdDataDefn)
222229 }
223230 , ..
@@ -228,7 +235,7 @@ prettyGADTDecl df decl =
228235 adjustCon :: LConDecl GP -> LConDecl GP
229236#if MIN_VERSION_ghc(9,11,0)
230237 adjustCon (L _ r) =
231- let delta = EpaDelta (UnhelpfulSpan UnhelpfulNoLocationInfo ) (DifferentLine 1 3 ) []
238+ let delta = EpaDelta (UnhelpfulSpan UnhelpfulNoLocationInfo ) (DifferentLine 1 2 ) []
232239 in L (EpAnn delta (AnnListItem [] ) (EpaComments [] )) r
233240#elif MIN_VERSION_ghc(9,9,0)
234241 adjustCon (L _ r) =
@@ -255,11 +262,24 @@ prettyGADTDecl df decl =
255262 else AddEpAnn ann l
256263 )
257264#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
258274 -- Remove the first extra line if exist
259275 removeExtraEmptyLine s = case stripInfix " \n\n " s of
260276 Just (x, xs) -> x <> " \n " <> xs
261277 Nothing -> s
262278
279+ #if MIN_VERSION_ghc(9,11,0)
280+
281+ #endif
282+
263283wrap :: forall a . WrapXRec GP a => a -> XRec GP a
264284wrap = wrapXRec @ GP
265285wrapCtxt = id
0 commit comments