Skip to content

Commit a5c7a1e

Browse files
committed
Restore hints in diagnostic messages
1 parent c5ed84a commit a5c7a1e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Development.IDE.GHC.Compat(
1717
NameCacheUpdater(..),
1818
#if MIN_VERSION_ghc(9,3,0)
1919
getMessages,
20-
diagnosticMessage,
20+
renderDiagnosticMessageWithHints,
2121
nameEnvElts,
2222
#else
2323
upNameCache,
@@ -402,7 +402,7 @@ type WarnMsg = MsgEnvelope DecoratedSDoc
402402
getMessages' :: PState -> DynFlags -> (Bag WarnMsg, Bag ErrMsg)
403403
getMessages' pst dflags =
404404
#if MIN_VERSION_ghc(9,3,0)
405-
bimap (fmap (fmap diagnosticMessage) . getMessages) (fmap (fmap diagnosticMessage) . getMessages) $ getPsMessages pst
405+
bimap (fmap (fmap renderDiagnosticMessageWithHints) . getMessages) (fmap (fmap renderDiagnosticMessageWithHints) . getMessages) $ getPsMessages pst
406406
#else
407407
#if MIN_VERSION_ghc(9,2,0)
408408
bimap (fmap pprWarning) (fmap pprError) $
@@ -413,11 +413,16 @@ getMessages' pst dflags =
413413
#endif
414414
#endif
415415

416+
#if MIN_VERSION_ghc(9,3,0)
417+
renderDiagnosticMessageWithHints :: Diagnostic a => a -> DecoratedSDoc
418+
renderDiagnosticMessageWithHints a = unionDecoratedSDoc (diagnosticMessage a) (mkDecorated $ map ppr $ diagnosticHints a)
419+
#endif
420+
416421
#if MIN_VERSION_ghc(9,2,0)
417422
pattern PFailedWithErrorMessages :: forall a b. (b -> Bag (MsgEnvelope DecoratedSDoc)) -> ParseResult a
418423
pattern PFailedWithErrorMessages msgs
419424
#if MIN_VERSION_ghc(9,3,0)
420-
<- PFailed (const . fmap (fmap diagnosticMessage) . getMessages . getPsErrorMessages -> msgs)
425+
<- PFailed (const . fmap (fmap renderDiagnosticMessageWithHints) . getMessages . getPsErrorMessages -> msgs)
421426
#else
422427
<- PFailed (const . fmap pprError . getErrorMessages -> msgs)
423428
#endif

ghcide/src/Development/IDE/GHC/Error.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ catchSrcErrors dflags fromWhere ghcM = do
174174
ghcExceptionToDiagnostics dflags = return . Left . diagFromGhcException fromWhere dflags
175175
sourceErrorToDiagnostics dflags = return . Left . diagFromErrMsgs fromWhere dflags
176176
#if MIN_VERSION_ghc(9,3,0)
177-
. fmap (fmap Compat.diagnosticMessage) . Compat.getMessages
177+
. fmap (fmap Compat.renderDiagnosticMessageWithHints) . Compat.getMessages
178178
#endif
179179
. srcErrorMessages
180180

0 commit comments

Comments
 (0)