Skip to content

Commit adee00c

Browse files
enable gadt for ghc-9.12
1 parent de8ef08 commit adee00c

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

docs/support/ghc-version-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Support status (see the support policy below for more details):
1717

1818
| GHC version | Last supporting HLS version | Support status |
1919
| ------------ | ------------------------------------------------------------------------------------ | -------------- |
20-
| 9.12.2 | [latest](https://github.com/haskell/haskell-language-server/releases/latest) | basic support |
20+
| 9.12.2 | [latest](https://github.com/haskell/haskell-language-server/releases/latest) | full support |
2121
| 9.10.1 | [latest](https://github.com/haskell/haskell-language-server/releases/latest) | full support |
2222
| 9.8.4 | [latest](https://github.com/haskell/haskell-language-server/releases/latest) | full support |
2323
| 9.8.2 | [2.9.0.1](https://github.com/haskell/haskell-language-server/releases/tag/2.9.0.1) | deprecated |

docs/support/plugin-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ For example, a plugin to provide a formatter which has itself been abandoned has
5454
| `hls-explicit-fixity-plugin` | 2 | |
5555
| `hls-explicit-record-fields-plugin` | 2 | |
5656
| `hls-fourmolu-plugin` | 2 | |
57-
| `hls-gadt-plugin` | 2 | 9.12.2 |
57+
| `hls-gadt-plugin` | 2 | |
5858
| `hls-hlint-plugin` | 2 | 9.10.1 |
5959
| `hls-module-name-plugin` | 2 | |
6060
| `hls-notes-plugin` | 2 | |

plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs

+22-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import Development.IDE.GHC.Compat.ExactPrint
1818
import 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
2124
import Ide.PluginUtils (subRange)
2225
import 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+
263283
wrap :: forall a. WrapXRec GP a => a -> XRec GP a
264284
wrap = wrapXRec @GP
265285
wrapCtxt = id

0 commit comments

Comments
 (0)