Skip to content

Commit c48bdb9

Browse files
committed
Make eval plugin compile at 94
This is work in progress, it will likely not compile for older ghc version, and so far it doesn't handle unit ids at all. It is hardcoded for package "blah" version 0.1.0.0 now. Proper solutions for those issues will show up in separate commits
1 parent 595c527 commit c48bdb9

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Development.IDE.GHC.Compat.Util (
2424
LBooleanFormula,
2525
BooleanFormula(..),
2626
-- * OverridingBool
27-
#if !MIN_VERSION_ghc(9,3,0)
27+
#if !MIN_VERSION_ghc(9,5,0)
2828
OverridingBool(..),
2929
#endif
3030
-- * Maybes
@@ -73,6 +73,10 @@ module Development.IDE.GHC.Compat.Util (
7373
atEnd,
7474
) where
7575

76+
#if MIN_VERSION_ghc(9,4,0)
77+
import GHC.Data.Bool (OverridingBool(..))
78+
#endif
79+
7680
#if MIN_VERSION_ghc(9,0,0)
7781
import Control.Exception.Safe (MonadCatch, catch, try)
7882
import GHC.Data.Bag

haskell-language-server.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ common haddockComments
216216
cpp-options: -Dhls_haddockComments
217217

218218
common eval
219-
if flag(eval) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds))
219+
if flag(eval) && (impl(ghc < 9.5) || flag(ignore-plugins-ghc-bounds))
220220
build-depends: hls-eval-plugin ^>= 1.3
221221
cpp-options: -Dhls_eval
222222

plugins/hls-eval-plugin/hls-eval-plugin.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ source-repository head
3737
location: https://github.com/haskell/haskell-language-server
3838

3939
library
40-
if impl(ghc >= 9.3)
40+
if impl(ghc >= 9.5)
4141
buildable: False
4242
else
4343
buildable: True

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ runEvalCmd plId st EvalParams{..} =
250250
Target
251251
(TargetFile fp Nothing)
252252
False
253+
(stringToUnitId "blah-0.1.0.0-inplace")
253254
(Just (textToStringBuffer mdlText, now))
254255

255256
-- Setup environment for evaluation
@@ -331,7 +332,8 @@ runEvalCmd plId st EvalParams{..} =
331332
lbs <- liftIO $ runAction "eval: GetLinkables" st $ do
332333
linkables_needed <- reachableModules <$> use_ GetDependencyInformation nfp
333334
uses_ GetLinkable (filter (/= nfp) linkables_needed) -- We don't need the linkable for the current module
334-
let hscEnv'' = hscEnv' { hsc_HPT = addListToHpt (hsc_HPT hscEnv') [(moduleName $ mi_module $ hm_iface hm, hm) | lb <- lbs, let hm = linkableHomeMod lb] }
335+
--let hscEnv'' = hscEnv' { hsc_HPT = addListToHpt (hsc_HPT hscEnv') [(moduleName $ mi_module $ hm_iface hm, hm) | lb <- lbs, let hm = linkableHomeMod lb] }
336+
let hscEnv'' =hscUpdateHPT (flip addListToHpt [(moduleName $ mi_module $ hm_iface hm, hm) | lb <- lbs, let hm = linkableHomeMod lb] ) hscEnv'
335337

336338
edits <-
337339
perf "edits" $
@@ -703,20 +705,20 @@ doKindCmd :: Bool -> DynFlags -> Text -> Ghc (Maybe Text)
703705
doKindCmd False df arg = do
704706
let input = T.strip arg
705707
(_, kind) <- typeKind False $ T.unpack input
706-
let kindText = text (T.unpack input) <+> "::" <+> pprTypeForUser kind
708+
let kindText = text (T.unpack input) <+> "::" <+> pprSigmaType kind
707709
pure $ Just $ T.pack (showSDoc df kindText)
708710
doKindCmd True df arg = do
709711
let input = T.strip arg
710712
(ty, kind) <- typeKind True $ T.unpack input
711-
let kindDoc = text (T.unpack input) <+> "::" <+> pprTypeForUser kind
712-
tyDoc = "=" <+> pprTypeForUser ty
713+
let kindDoc = text (T.unpack input) <+> "::" <+> pprSigmaType kind
714+
tyDoc = "=" <+> pprSigmaType ty
713715
pure $ Just $ T.pack (showSDoc df $ kindDoc $$ tyDoc)
714716

715717
doTypeCmd :: DynFlags -> Text -> Ghc (Maybe Text)
716718
doTypeCmd dflags arg = do
717719
let (emod, expr) = parseExprMode arg
718720
ty <- GHC.exprType emod $ T.unpack expr
719-
let rawType = T.strip $ T.pack $ showSDoc dflags $ pprTypeForUser ty
721+
let rawType = T.strip $ T.pack $ showSDoc dflags $ pprSigmaType ty
720722
broken = T.any (\c -> c == '\r' || c == '\n') rawType
721723
pure $
722724
Just $
@@ -725,7 +727,7 @@ doTypeCmd dflags arg = do
725727
T.pack $
726728
showSDoc dflags $
727729
text (T.unpack expr)
728-
$$ nest 2 ("::" <+> pprTypeForUser ty)
730+
$$ nest 2 ("::" <+> pprSigmaType ty)
729731
else expr <> " :: " <> rawType <> "\n"
730732

731733
parseExprMode :: Text -> (TcRnExprMode, T.Text)

0 commit comments

Comments
 (0)