Skip to content

Commit 3906a1a

Browse files
committed
Bump class plugin to work with GHC 9.0.1
1 parent 07b9310 commit 3906a1a

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
name: Test hls-brittany-plugin
180180
run: cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-brittany-plugin --test-options="$TEST_OPTS"
181181

182-
- if: matrix.test && matrix.ghc != '9.0.1'
182+
- if: matrix.test
183183
name: Test hls-class-plugin
184184
run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-class-plugin --test-options="$TEST_OPTS"
185185

cabal-ghc901.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ index-state: 2021-11-29T08:11:07Z
4141

4242
constraints:
4343
-- These plugins don't work on GHC9 yet
44-
haskell-language-server +ignore-plugins-ghc-bounds -brittany -class -stylishhaskell -tactic,
44+
haskell-language-server +ignore-plugins-ghc-bounds -brittany -stylishhaskell -tactic,
4545
ghc-lib-parser ^>= 9.0
4646

4747
-- although we are not building all plugins cabal solver phase is run for all packages

configuration-ghc-901.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ let
77
"hls-brittany-plugin"
88
"hls-stylish-haskell-plugin"
99
"hls-fourmolu-plugin"
10-
"hls-class-plugin"
1110
];
1211

1312
hpkgsOverride = hself: hsuper:
@@ -27,7 +26,6 @@ let
2726
hself.callCabal2nixWithOptions "haskell-language-server" ./.
2827
(pkgs.lib.concatStringsSep " " [
2928
"-f-brittany"
30-
"-f-class"
3129
"-f-fourmolu"
3230
"-f-stylishhaskell"
3331
"-f-tactic"

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
with haskell.lib; {
7171
# Patches don't apply
7272
github = overrideCabal hsuper.github (drv: { patches = []; });
73-
# We need an older version
73+
# We need an older version
7474
hiedb = hself.hiedb_0_4_1_0;
7575

7676
implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle"

plugins/hls-class-plugin/src/Ide/Plugin/Class.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveAnyClass #-}
23
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE OverloadedStrings #-}
@@ -32,6 +33,7 @@ import Ide.Types
3233
import Language.Haskell.GHC.ExactPrint
3334
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl)
3435
import Language.Haskell.GHC.ExactPrint.Types hiding (GhcPs, Parens)
36+
import Language.Haskell.GHC.ExactPrint.Utils (rs)
3537
import Language.LSP.Server
3638
import Language.LSP.Types
3739
import qualified Language.LSP.Types.Lens as J
@@ -85,20 +87,19 @@ addMethodPlaceholders state AddMinimalMethodsParams{..} = do
8587
Right (ann, d) -> Just (setPrecedingLines d 1 indent ann, d)
8688
Left _ -> Nothing
8789

88-
addMethodDecls :: ParsedSource -> [LHsDecl GhcPs] -> Transform (Located (HsModule GhcPs))
8990
addMethodDecls ps mDecls = do
9091
d <- findInstDecl ps
9192
newSpan <- uniqueSrcSpanT
9293
let
9394
annKey = mkAnnKey d
94-
newAnnKey = AnnKey newSpan (CN "HsValBinds")
95+
newAnnKey = AnnKey (rs newSpan) (CN "HsValBinds")
9596
addWhere mkds@(Map.lookup annKey -> Just ann)
9697
= Map.insert newAnnKey ann2 mkds2
9798
where
9899
ann1 = ann
99100
{ annsDP = annsDP ann ++ [(G AnnWhere, DP (0, 1))]
100101
, annCapturedSpan = Just newAnnKey
101-
, annSortKey = Just (fmap getLoc mDecls)
102+
, annSortKey = Just (fmap (rs . getLoc) mDecls)
102103
}
103104
mkds2 = Map.insert annKey ann1 mkds
104105
ann2 = annNone
@@ -168,9 +169,15 @@ codeAction state plId (CodeActionParams _ _ docId _ context) = liftIO $ fmap (fr
168169
pure
169170
$ head . head
170171
$ pointCommand hf (fromJust (fromCurrentRange pmap range) ^. J.start & J.character -~ 1)
172+
#if !MIN_VERSION_ghc(9,0,0)
171173
( (Map.keys . Map.filter isClassNodeIdentifier . nodeIdentifiers . nodeInfo)
172174
<=< nodeChildren
173175
)
176+
#else
177+
( (Map.keys . Map.filter isClassNodeIdentifier . sourcedNodeIdents . sourcedNodeInfo)
178+
<=< nodeChildren
179+
)
180+
#endif
174181

175182
findClassFromIdentifier docPath (Right name) = do
176183
(hscEnv -> hscenv, _) <- MaybeT . runAction "classplugin" state $ useWithStale GhcSessionDeps docPath

stack-9.0.1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages:
99
- ./hls-test-utils
1010
- ./shake-bench
1111
- ./plugins/hls-call-hierarchy-plugin
12-
# - ./plugins/hls-class-plugin
12+
- ./plugins/hls-class-plugin
1313
- ./plugins/hls-haddock-comments-plugin
1414
- ./plugins/hls-eval-plugin
1515
- ./plugins/hls-explicit-imports-plugin

0 commit comments

Comments
 (0)