Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cd42bcf

Browse files
enable gadt for ghc-9.12 (#4568)
1 parent cf259df commit cd42bcf

File tree

7 files changed

+56
-11
lines changed

7 files changed

+56
-11
lines changed

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
name: Test hls-change-type-signature test suite
214214
run: cabal test hls-change-type-signature-plugin-tests || cabal test hls-change-type-signature-plugin-tests
215215

216-
- if: matrix.test && matrix.ghc != '9.12'
216+
- if: matrix.test
217217
name: Test hls-gadt-plugin test suit
218218
run: cabal test hls-gadt-plugin-tests || cabal test hls-gadt-plugin-tests
219219

‎docs/support/ghc-version-support.md‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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 | |

‎haskell-language-server.cabal‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,13 +1208,13 @@ flag gadt
12081208
manual: True
12091209

12101210
common gadt
1211-
if flag(gadt)&& (impl(ghc <9.11) || flag(ignore-plugins-ghc-bounds))
1211+
if flag(gadt)
12121212
build-depends: haskell-language-server:hls-gadt-plugin
12131213
cpp-options: -Dhls_gadt
12141214

12151215
library hls-gadt-plugin
12161216
import: defaults, pedantic, warnings
1217-
if !flag(gadt) || (impl(ghc >9.11) && !flag(ignore-plugins-ghc-bounds))
1217+
if !flag(gadt)
12181218
buildable: False
12191219
exposed-modules: Ide.Plugin.GADT
12201220
other-modules: Ide.Plugin.GHC
@@ -1238,7 +1238,7 @@ library hls-gadt-plugin
12381238

12391239
test-suite hls-gadt-plugin-tests
12401240
import: defaults, pedantic, test-defaults, warnings
1241-
if !flag(gadt) || (impl(ghc >9.11) && !flag(ignore-plugins-ghc-bounds))
1241+
if !flag(gadt)
12421242
buildable: False
12431243
type: exitcode-stdio-1.0
12441244
hs-source-dirs: plugins/hls-gadt-plugin/test

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

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
{-# OPTIONS_GHC -Wno-overlapping-patterns #-}
88
module Ide.Plugin.GHC where
99

10+
#if !MIN_VERSION_ghc(9,11,0)
1011
import Data.Functor ((<&>))
12+
#endif
1113
import Data.List.Extra (stripInfix)
1214
import qualified Data.Text as T
1315
import Development.IDE
1416
import Development.IDE.GHC.Compat
1517
import Development.IDE.GHC.Compat.ExactPrint
16-
import GHC.Parser.Annotation (AddEpAnn (..),
17-
DeltaPos (..),
18+
import GHC.Parser.Annotation (DeltaPos (..),
1819
EpAnn (..),
1920
EpAnnComments (EpaComments))
21+
#if MIN_VERSION_ghc(9,11,0)
22+
import GHC.Parser.Annotation (EpToken (..))
23+
#endif
2024
import Ide.PluginUtils (subRange)
2125
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl)
2226

@@ -44,6 +48,11 @@ import GHC.Parser.Annotation (EpUniToken (..),
4448
import Language.Haskell.GHC.ExactPrint.Utils (showAst)
4549
#endif
4650

51+
#if MIN_VERSION_ghc(9,11,0)
52+
import GHC.Types.SrcLoc (UnhelpfulSpanReason (..))
53+
#else
54+
import GHC.Parser.Annotation (AddEpAnn (..))
55+
#endif
4756

4857
type GP = GhcPass Parsed
4958

@@ -97,7 +106,9 @@ h98ToGADTConDecl ::
97106
h98ToGADTConDecl dataName tyVars ctxt = \case
98107
ConDeclH98{..} ->
99108
ConDeclGADT
100-
#if MIN_VERSION_ghc(9,9,0)
109+
#if MIN_VERSION_ghc(9,11,0)
110+
(AnnConDeclGADT [] [] NoEpUniTok)
111+
#elif MIN_VERSION_ghc(9,9,0)
101112
(NoEpUniTok, con_ext)
102113
#else
103114
con_ext
@@ -209,7 +220,11 @@ prettyGADTDecl df decl =
209220
adjustDataDecl DataDecl{..} = DataDecl
210221
{ tcdDExt = adjustWhere tcdDExt
211222
, tcdDataDefn = tcdDataDefn
212-
{ dd_cons =
223+
{
224+
#if MIN_VERSION_ghc(9,11,0)
225+
dd_ext = adjustDefnWhere (dd_ext tcdDataDefn),
226+
#endif
227+
dd_cons =
213228
fmap adjustCon (dd_cons tcdDataDefn)
214229
}
215230
, ..
@@ -218,7 +233,11 @@ prettyGADTDecl df decl =
218233

219234
-- Make every data constructor start with a new line and 2 spaces
220235
adjustCon :: LConDecl GP -> LConDecl GP
221-
#if MIN_VERSION_ghc(9,9,0)
236+
#if MIN_VERSION_ghc(9,11,0)
237+
adjustCon (L _ r) =
238+
let delta = EpaDelta (UnhelpfulSpan UnhelpfulNoLocationInfo) (DifferentLine 1 2) []
239+
in L (EpAnn delta (AnnListItem []) (EpaComments [])) r
240+
#elif MIN_VERSION_ghc(9,9,0)
222241
adjustCon (L _ r) =
223242
let delta = EpaDelta (DifferentLine 1 3) []
224243
in L (EpAnn delta (AnnListItem []) (EpaComments [])) r
@@ -229,6 +248,10 @@ prettyGADTDecl df decl =
229248
#endif
230249

231250
-- Adjust where annotation to the same line of the type constructor
251+
#if MIN_VERSION_ghc(9,11,0)
252+
-- tcdDext is just a placeholder in ghc-9.12
253+
adjustWhere = id
254+
#else
232255
adjustWhere tcdDExt = tcdDExt <&>
233256
#if !MIN_VERSION_ghc(9,9,0)
234257
map
@@ -238,7 +261,16 @@ prettyGADTDecl df decl =
238261
then AddEpAnn AnnWhere d1
239262
else AddEpAnn ann l
240263
)
264+
#endif
241265

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
242274
-- Remove the first extra line if exist
243275
removeExtraEmptyLine s = case stripInfix "\n\n" s of
244276
Just (x, xs) -> x <> "\n" <> xs
@@ -257,6 +289,10 @@ noUsed = EpAnnNotUsed
257289
#endif
258290

259291
pattern UserTyVar' :: LIdP pass -> HsTyVarBndr flag pass
292+
#if MIN_VERSION_ghc(9,11,0)
293+
pattern UserTyVar' s <- HsTvb _ _ (HsBndrVar _ s) _
294+
#else
260295
pattern UserTyVar' s <- UserTyVar _ _ s
296+
#endif
261297

262298
implicitTyVars = wrapXRec @GP mkHsOuterImplicit

‎test/testdata/schema/ghc912/default-config.golden.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
"path": "fourmolu"
6060
}
6161
},
62+
"gadt": {
63+
"globalOn": true
64+
},
6265
"ghcide-code-actions-bindings": {
6366
"globalOn": true
6467
},

‎test/testdata/schema/ghc912/vscode-extension-schema.golden.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@
131131
"scope": "resource",
132132
"type": "string"
133133
},
134+
"haskell.plugin.gadt.globalOn": {
135+
"default": true,
136+
"description": "Enables gadt plugin",
137+
"scope": "resource",
138+
"type": "boolean"
139+
},
134140
"haskell.plugin.ghcide-code-actions-bindings.globalOn": {
135141
"default": true,
136142
"description": "Enables ghcide-code-actions-bindings plugin",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /