-
-
Notifications
You must be signed in to change notification settings - Fork 392
Skip parsing without haddock for above GHC9.0 #2338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
981635d
c225c64
50a50b8
afde479
7ce5681
946812b
5406cf9
d7b8e18
760a730
44bdb81
2c7bc24
ac06a10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,38 +213,43 @@ getParsedModuleRule = | |
opt <- getIdeOptions | ||
modify_dflags <- getModifyDynFlags dynFlagsModifyParser | ||
let ms = ms' { ms_hspp_opts = modify_dflags $ ms_hspp_opts ms' } | ||
|
||
let dflags = ms_hspp_opts ms | ||
mainParse = getParsedModuleDefinition hsc opt file ms | ||
reset_ms pm = pm { pm_mod_summary = ms' } | ||
|
||
-- Parse again (if necessary) to capture Haddock parse errors | ||
res@(_,pmod) <- if gopt Opt_Haddock dflags | ||
then | ||
liftIO $ (fmap.fmap.fmap) reset_ms mainParse | ||
else do | ||
let haddockParse = getParsedModuleDefinition hsc opt file (withOptHaddock ms) | ||
|
||
-- parse twice, with and without Haddocks, concurrently | ||
-- we cannot ignore Haddock parse errors because files of | ||
-- non-interest are always parsed with Haddocks | ||
-- If we can parse Haddocks, might as well use them | ||
-- | ||
-- HLINT INTEGRATION: might need to save the other parsed module too | ||
((diags,res),(diagsh,resh)) <- liftIO $ (fmap.fmap.fmap.fmap) reset_ms $ concurrently mainParse haddockParse | ||
|
||
-- Merge haddock and regular diagnostics so we can always report haddock | ||
-- parse errors | ||
let diagsM = mergeParseErrorsHaddock diags diagsh | ||
case resh of | ||
Just _ | ||
| HaddockParse <- optHaddockParse opt | ||
-> pure (diagsM, resh) | ||
-- If we fail to parse haddocks, report the haddock diagnostics as well and | ||
-- return the non-haddock parse. | ||
-- This seems to be the correct behaviour because the Haddock flag is added | ||
-- by us and not the user, so our IDE shouldn't stop working because of it. | ||
_ -> pure (diagsM, res) | ||
-- We still parse with Haddocks whether Opt_Haddock is True or False to collect information | ||
-- but we no longer need to parse with and without Haddocks separately for above GHC90. | ||
res@(_,pmod) <- if Compat.ghcVersion >= Compat.GHC90 then | ||
liftIO $ (fmap.fmap.fmap) reset_ms $ getParsedModuleDefinition hsc opt file (withOptHaddock ms) | ||
else do | ||
let dflags = ms_hspp_opts ms | ||
mainParse = getParsedModuleDefinition hsc opt file ms | ||
|
||
-- Parse again (if necessary) to capture Haddock parse errors | ||
if gopt Opt_Haddock dflags | ||
then | ||
liftIO $ (fmap.fmap.fmap) reset_ms mainParse | ||
else do | ||
let haddockParse = getParsedModuleDefinition hsc opt file (withOptHaddock ms) | ||
|
||
-- parse twice, with and without Haddocks, concurrently | ||
-- we cannot ignore Haddock parse errors because files of | ||
-- non-interest are always parsed with Haddocks | ||
-- If we can parse Haddocks, might as well use them | ||
-- | ||
-- HLINT INTEGRATION: might need to save the other parsed module too | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment is confusing , I think it can be deleted since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, it was even not hlint specific and can be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed this comment 👍 |
||
((diags,res),(diagsh,resh)) <- liftIO $ (fmap.fmap.fmap.fmap) reset_ms $ concurrently mainParse haddockParse | ||
|
||
-- Merge haddock and regular diagnostics so we can always report haddock | ||
-- parse errors | ||
let diagsM = mergeParseErrorsHaddock diags diagsh | ||
case resh of | ||
Just _ | ||
| HaddockParse <- optHaddockParse opt | ||
-> pure (diagsM, resh) | ||
-- If we fail to parse haddocks, report the haddock diagnostics as well and | ||
-- return the non-haddock parse. | ||
-- This seems to be the correct behaviour because the Haddock flag is added | ||
-- by us and not the user, so our IDE shouldn't stop working because of it. | ||
_ -> pure (diagsM, res) | ||
-- Add dependencies on included files | ||
_ <- uses GetModificationTime $ map toNormalizedFilePath' (maybe [] pm_extra_src_files pmod) | ||
pure res | ||
|
@@ -896,9 +901,11 @@ regenerateHiFile sess f ms compNeeded = do | |
|
||
-- Embed haddocks in the interface file | ||
(diags, mb_pm) <- liftIO $ getParsedModuleDefinition hsc opt f (withOptHaddock ms) | ||
(diags, mb_pm) <- case mb_pm of | ||
Just _ -> return (diags, mb_pm) | ||
Nothing -> do | ||
(diags, mb_pm) <- | ||
-- We no longer need to parse again if GHC version is above 9.0. https://github.com/haskell/haskell-language-server/issues/1892 | ||
if Compat.ghcVersion >= Compat.GHC90 || isJust mb_pm then do | ||
return (diags, mb_pm) | ||
else do | ||
-- if parsing fails, try parsing again with Haddock turned off | ||
(diagsNoHaddock, mb_pm) <- liftIO $ getParsedModuleDefinition hsc opt f ms | ||
return (mergeParseErrorsHaddock diagsNoHaddock diags, mb_pm) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed my code to collect haddock information even if Opt_Haddock returns False.
It seems to do so for display haddock information in the hover as the failed test suites indicated.
(for question 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, with GHC >9.0 we want to parse with
Opt_Haddock
on always