Skip to content

Commit c225c64

Browse files
committed
Use runtime ghc version check
1 parent 981635d commit c225c64

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,9 @@ getParsedModuleRule =
218218
mainParse = getParsedModuleDefinition hsc opt file ms
219219
reset_ms pm = pm { pm_mod_summary = ms' }
220220

221-
#if MIN_VERSION_ghc(9,0,1)
222-
-- We no longer need to parse again if GHC version is above 9.0
223-
-- https://github.com/haskell/haskell-language-server/issues/1892
224-
res@(_,pmod) <- liftIO $ (fmap.fmap.fmap) reset_ms mainParse
225-
#else
226221
-- Parse again (if necessary) to capture Haddock parse errors
227-
res@(_,pmod) <- if gopt Opt_Haddock dflags
222+
-- We no longer need to parse again if GHC version is above 9.0. https://github.com/haskell/haskell-language-server/issues/1892
223+
res@(_,pmod) <- if Compat.ghcVersion >= Compat.GHC90 || gopt Opt_Haddock dflags
228224
then
229225
liftIO $ (fmap.fmap.fmap) reset_ms mainParse
230226
else do
@@ -250,7 +246,6 @@ getParsedModuleRule =
250246
-- This seems to be the correct behaviour because the Haddock flag is added
251247
-- by us and not the user, so our IDE shouldn't stop working because of it.
252248
_ -> pure (diagsM, res)
253-
#endif
254249
-- Add dependencies on included files
255250
_ <- uses GetModificationTime $ map toNormalizedFilePath' (maybe [] pm_extra_src_files pmod)
256251
pure res
@@ -898,17 +893,14 @@ regenerateHiFile sess f ms compNeeded = do
898893

899894
-- Embed haddocks in the interface file
900895
(diags, mb_pm) <- liftIO $ getParsedModuleDefinition hsc opt f (withOptHaddock ms)
901-
#if MIN_VERSION_ghc(9,0,1)
902-
-- We no longer need to parse again if GHC version is above 9.0
903-
-- https://github.com/haskell/haskell-language-server/issues/1892
904-
#else
905-
(diags, mb_pm) <- case mb_pm of
906-
Just _ -> return (diags, mb_pm)
907-
Nothing -> do
896+
(diags, mb_pm) <-
897+
-- We no longer need to parse again if GHC version is above 9.0. https://github.com/haskell/haskell-language-server/issues/1892
898+
if Compat.ghcVersion >= Compat.GHC90 || isJust mb_pm then do
899+
return (diags, mb_pm)
900+
else do
908901
-- if parsing fails, try parsing again with Haddock turned off
909902
(diagsNoHaddock, mb_pm) <- liftIO $ getParsedModuleDefinition hsc opt f ms
910903
return (mergeParseErrorsHaddock diagsNoHaddock diags, mb_pm)
911-
#endif
912904
case mb_pm of
913905
Nothing -> return (diags, Nothing)
914906
Just pm -> do

0 commit comments

Comments
 (0)