Skip to content

Commit 4f65222

Browse files
committed
[fix] make syntactic tokens work with ghc 9.12
1 parent bc4ed9a commit 4f65222

File tree

2 files changed

+32
-25
lines changed
  • ghcide/src/Development/IDE/GHC/Compat
  • plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens

2 files changed

+32
-25
lines changed

ghcide/src/Development/IDE/GHC/Compat/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ instance HasSrcSpan GHC.EpaLocation where
653653
getLoc loc = GHC.getHasLoc loc
654654
#endif
655655

656-
#if !MIN_VERSION_ghc(9,11,0)
656+
#if MIN_VERSION_ghc(9,9,0)
657657
instance HasSrcSpan GHC.LEpaComment where
658658
getLoc :: GHC.LEpaComment -> SrcSpan
659659
getLoc (GHC.L l _) = case l of

plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE BlockArguments #-}
2+
{-# LANGUAGE CPP #-}
23
{-# LANGUAGE DataKinds #-}
34
{-# LANGUAGE DerivingStrategies #-}
45
{-# LANGUAGE ImpredicativeTypes #-}
@@ -47,7 +48,6 @@ import Development.IDE (Action,
4748
cmapWithPrio, define,
4849
hieKind,
4950
srcSpanToRange,
50-
toNormalizedUri,
5151
useWithStale)
5252
import Development.IDE.Core.PluginUtils (runActionE, useE,
5353
useWithStaleE)
@@ -193,11 +193,11 @@ computeRangeHsSyntacticTokenTypeList ParsedModule {pm_parsed_source} =
193193
let toks = astTraversalWith pm_parsed_source \node -> mconcat
194194
[ maybeToList $ mkFromLocatable TKeyword . (\k -> k \x k' -> k' x) =<< extractTyToTy @EpToken node
195195
-- FIXME: probably needs to be commented out for ghc > 9.10
196-
, maybeToList $ mkFromLocatable TKeyword . (\x k -> k x) =<< extractTy @AddEpAnn node
197-
, do
198-
EpAnnImportDecl i p s q pkg a <- maybeToList $ extractTy @EpAnnImportDecl node
196+
-- , maybeToList $ mkFromLocatable TKeyword . (\x k -> k x) =<< extractTy node
197+
-- , do
198+
-- EpAnnImportDecl i p s q pkg a <- maybeToList $ extractTy @EpAnnImportDecl node
199199

200-
mapMaybe (mkFromLocatable TKeyword . (\x k -> k x)) $ catMaybes $ [Just i, s, q, pkg, a] <> foldMap (\(l, l') -> [Just l, Just l']) p
200+
-- mapMaybe (mkFromLocatable TKeyword . (\x k -> k x)) $ catMaybes $ [Just i, s, q, pkg, a] <> foldMap (\(l, l') -> [Just l, Just l']) p
201201
, maybeToList $ mkFromLocatable TComment . (\x k -> k x) =<< extractTy @LEpaComment node
202202
, do
203203
L loc expr <- maybeToList $ extractTy @(LHsExpr GhcPs) node
@@ -210,29 +210,36 @@ computeRangeHsSyntacticTokenTypeList ParsedModule {pm_parsed_source} =
210210

211211
HsIsString {} -> TStringLit
212212
HsLit _ lit -> fromSimple case lit of
213-
HsChar {} -> TCharLit
214-
HsCharPrim {} -> TCharLit
213+
HsChar {} -> TCharLit
214+
HsCharPrim {} -> TCharLit
215215

216-
HsInt {} -> TNumberLit
217-
HsInteger {} -> TNumberLit
218-
HsIntPrim {} -> TNumberLit
219-
HsWordPrim {} -> TNumberLit
220-
HsWord8Prim {} -> TNumberLit
221-
HsWord16Prim {} -> TNumberLit
222-
HsWord32Prim {} -> TNumberLit
223-
HsWord64Prim {} -> TNumberLit
224-
HsInt8Prim {} -> TNumberLit
225-
HsInt16Prim {} -> TNumberLit
226-
HsInt32Prim {} -> TNumberLit
227-
HsInt64Prim {} -> TNumberLit
228-
HsFloatPrim {} -> TNumberLit
229-
HsDoublePrim {} -> TNumberLit
230-
HsRat {} -> TNumberLit
216+
HsInt {} -> TNumberLit
217+
HsInteger {} -> TNumberLit
218+
HsIntPrim {} -> TNumberLit
219+
HsWordPrim {} -> TNumberLit
220+
HsWord8Prim {} -> TNumberLit
221+
HsWord16Prim {} -> TNumberLit
222+
HsWord32Prim {} -> TNumberLit
223+
HsWord64Prim {} -> TNumberLit
224+
HsInt8Prim {} -> TNumberLit
225+
HsInt16Prim {} -> TNumberLit
226+
HsInt32Prim {} -> TNumberLit
227+
HsInt64Prim {} -> TNumberLit
228+
HsFloatPrim {} -> TNumberLit
229+
HsDoublePrim {} -> TNumberLit
230+
HsRat {} -> TNumberLit
231231

232-
HsString {} -> TStringLit
233-
HsStringPrim {} -> TStringLit
232+
HsString {} -> TStringLit
233+
HsStringPrim {} -> TStringLit
234+
#if MIN_VERSION_ghc(9,11,0)
235+
HsMultilineString {} -> TStringLit
236+
#endif
234237
HsGetField _ _ field -> maybeToList $ mkFromLocatable TRecordSelector \k -> k field
238+
#if MIN_VERSION_ghc(9,11,0)
239+
HsProjection _ projs -> foldMap (\dotFieldOcc -> maybeToList $ mkFromLocatable TRecordSelector \k -> k dotFieldOcc.dfoLabel) projs
240+
#else
235241
HsProjection _ projs -> foldMap (\proj -> maybeToList $ mkFromLocatable TRecordSelector \k -> k proj) projs
242+
#endif
236243
_ -> []
237244
]
238245
in RangeHsSyntacticTokenTypes toks

0 commit comments

Comments
 (0)