Skip to content

Commit 5c5744d

Browse files
committed
ghcide: Core.Compile: use previous IO throw
This allows without dependency import husle to support both 8.10 & 9.0.
1 parent 2f6553e commit 5c5744d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1029,10 +1029,10 @@ getDocsNonInteractive' name =
10291029
-- | Non-interactive modification of 'GHC.Runtime.Eval.getDocs'.
10301030
-- The interactive paths create problems in ghc-lib builds
10311031
--- and lead to fun errors like "Cannot continue after interface file error".
1032-
getDocsNonInteractive :: HscEnv -> Module -> Name -> IO (Either ErrorMessages (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString))))
1032+
getDocsNonInteractive :: HscEnv -> Module -> Name -> IO (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))
10331033
getDocsNonInteractive hsc_env mod name = do
10341034
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ getDocsNonInteractive' name
1035-
pure $ maybeToEither errs res
1035+
maybe (liftIO . throwIO . mkSrcErr $ errs) pure res
10361036

10371037

10381038
-- | Non-interactive, batch version of 'GHC.Runtime.Eval.getDocs'.
@@ -1041,11 +1041,11 @@ getDocsBatch
10411041
-> Module -- ^ a moudle where the names are in scope
10421042
-> [Name]
10431043
-- 2021-11-18: NOTE: Map Int would become IntMap if next GHCs.
1044-
-> IO (Either ErrorMessages (Map.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))))
1044+
-> IO (Map.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString))))
10451045
-- ^ Return a 'Map' of 'Name's to 'Either' (no docs messages) (general doc body & arg docs)
10461046
getDocsBatch hsc_env mod names = do
10471047
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ Map.fromList <$> traverse getDocsNonInteractive' names
1048-
pure $ maybeToEither errs res
1048+
maybe (liftIO . throwIO . mkSrcErr $ errs) pure res
10491049

10501050
-- | Non-interactive, batch version of 'InteractiveEval.lookupNames'.
10511051
-- The interactive paths create problems in ghc-lib builds

ghcide/src/Development/IDE/Spans/Documentation.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ intoSpanDoc env name a = extractDocString a <$> getSpanDocUris name
9494

9595
getDocumentationTryGhc :: HscEnv -> Module -> Name -> IO SpanDoc
9696
getDocumentationTryGhc env mod name = do
97-
res <- getDocsNonInteractive env mod name
97+
res <- catchSrcErrors (hsc_dflags env) "docs" $ getDocsNonInteractive env mod name
9898
case res of
9999
Left _ -> pure emptySpanDoc
100100
Right res -> uncurry (intoSpanDoc env) res
101101

102102
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO (M.Map Name SpanDoc)
103103
getDocumentationsTryGhc env mod names = do
104-
res <- getDocsBatch env mod names
104+
res <- catchSrcErrors (hsc_dflags env) "docs" $ getDocsBatch env mod names
105105
case res of
106106
Left _ -> return mempty
107107
Right res -> sequenceA $ M.mapWithKey (intoSpanDoc env) res

0 commit comments

Comments
 (0)