Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Enable -haddock at parsing time #350

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ parseModule
-> Maybe SB.StringBuffer
-> IO ([FileDiagnostic], Maybe ParsedModule)
parseModule IdeOptions{..} env file =
let env' = env { hsc_dflags = hsc_dflags env `gopt_set` Opt_Haddock } in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GHC has both Opt_KeepRawTokenStream and Opt_Haddock which are mutually incompatible. We need Opt_KeepRawTokenStream in DAML since HLint will otherwise miss some hints and we’ll need the same in ghcide if we start integrating HLint.

So hardcoding this to Opt_Haddock isn’t really an option. Sadly, I don’t have a great answer for what the right option would be. I guess for now, we could add a ForceHadock field to IdeOptions and then set this to True for ghcide and if we do integrate HLint we accept that we miss some hints since docs are probably more useful. Long-term this should really get fixed in GHC so that the two are not exclusive (iirc the long-term plan is to build haddock on top of Opt_KeepRawTokenStream).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that seemed too easy to not have been tried earlier.

fmap (either (, Nothing) (second Just)) .
-- We need packages since imports fail to resolve otherwise.
runGhcEnv env . runExceptT . parseFileContents optPreprocessor file
runGhcEnv env' . runExceptT . parseFileContents optPreprocessor file


-- | Given a package identifier, what packages does it depend on
Expand Down
2 changes: 1 addition & 1 deletion test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ findDefinitionAndHoverTests = let
, test yes yes mclL36 mcl "top-level fn 1st clause"
, test yes yes mclL37 mcl "top-level fn 2nd clause #246"
, test yes yes spaceL37 space "top-level fn on space #315"
, test no broken docL41 doc "documentation #7"
, test no yes docL41 doc "documentation #7"
, test no yes eitL40 kindE "kind of Either #273"
, test no yes intL40 kindI "kind of Int #273"
, test no broken tvrL40 kindV "kind of (* -> *) type variable #273"
Expand Down