Skip to content

Commit e5357f8

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

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

Diff for: .github/workflows/test.yml

+1-1
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

Diff for: cabal-ghc901.project

+1-1
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

Diff for: configuration-ghc-901.nix

-2
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"

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

+11-3
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,20 @@ 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))
90+
-- addMethodDecls :: ParsedSource -> [LHsDecl GhcPs] -> Transform (Located (HsModule GhcPs))
8991
addMethodDecls ps mDecls = do
9092
d <- findInstDecl ps
9193
newSpan <- uniqueSrcSpanT
9294
let
9395
annKey = mkAnnKey d
94-
newAnnKey = AnnKey newSpan (CN "HsValBinds")
96+
newAnnKey = AnnKey (rs newSpan) (CN "HsValBinds")
9597
addWhere mkds@(Map.lookup annKey -> Just ann)
9698
= Map.insert newAnnKey ann2 mkds2
9799
where
98100
ann1 = ann
99101
{ annsDP = annsDP ann ++ [(G AnnWhere, DP (0, 1))]
100102
, annCapturedSpan = Just newAnnKey
101-
, annSortKey = Just (fmap getLoc mDecls)
103+
, annSortKey = Just (fmap (rs . getLoc) mDecls)
102104
}
103105
mkds2 = Map.insert annKey ann1 mkds
104106
ann2 = annNone
@@ -168,9 +170,15 @@ codeAction state plId (CodeActionParams _ _ docId _ context) = liftIO $ fmap (fr
168170
pure
169171
$ head . head
170172
$ pointCommand hf (fromJust (fromCurrentRange pmap range) ^. J.start & J.character -~ 1)
173+
#if !MIN_VERSION_ghc(9,0,0)
171174
( (Map.keys . Map.filter isClassNodeIdentifier . nodeIdentifiers . nodeInfo)
172175
<=< nodeChildren
173176
)
177+
#else
178+
( (Map.keys . Map.filter isClassNodeIdentifier . sourcedNodeIdents . sourcedNodeInfo)
179+
<=< nodeChildren
180+
)
181+
#endif
174182

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

Diff for: stack-9.0.1.yaml

+1-1
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)