Skip to content

Commit 567ab4e

Browse files
committed
ghcide: Compile: {initTypecheckEnv, getDocs{NonInteractive,Batch}}
upd to GHC 9.2 types
1 parent 8ee6a9f commit 567ab4e

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

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

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ import Data.Binary
106106
import Data.Coerce
107107
import Data.Functor
108108
import qualified Data.HashMap.Strict as HashMap
109-
import Data.Map (Map)
110109
import qualified Data.Map as ML
111110
import Data.Tuple.Extra (dupe)
112111
import Data.Either.Extra (maybeToEither)
@@ -993,7 +992,17 @@ mkDetailsFromIface session iface linkable = do
993992
initIfaceLoad hsc' (typecheckIface iface)
994993
return (HomeModInfo iface details linkable)
995994

996-
initTypecheckEnv :: HscEnv -> Module -> TcRn r -> IO (Messages, Maybe r)
995+
initTypecheckEnv
996+
:: HscEnv
997+
-> Module
998+
-> TcRn r
999+
-> IO
1000+
( Messages
1001+
#if MIN_VERSION_ghc(9,2,1)
1002+
DecoratedSDoc
1003+
#endif
1004+
, Maybe r
1005+
)
9971006
initTypecheckEnv hsc_env mod = initTc hsc_env HsSrcFile False mod fakeSpan
9981007
where
9991008
fakeSpan :: RealSrcSpan
@@ -1038,23 +1047,50 @@ getDocsNonInteractive' name =
10381047
else Right (MS.lookup name dmap, MS.lookup name amap')
10391048

10401049
-- | Non-interactive modification of 'GHC.Runtime.Eval.getDocs'.
1041-
getDocsNonInteractive :: HscEnv -> Module -> Name -> IO (Either GHC.ErrorMessages (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (IntMap HsDocString))))
1042-
getDocsNonInteractive hsc_env mod name = do
1043-
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ getDocsNonInteractive' name
1044-
pure $ maybeToEither errs res
1050+
getDocsNonInteractive
1051+
:: HscEnv
1052+
-> Module
1053+
-> Name
1054+
-> IO
1055+
( Either
1056+
GHC.ErrorMessages
1057+
( Name
1058+
, Either
1059+
GetDocsFailure
1060+
( Maybe HsDocString
1061+
, Maybe (IntMap HsDocString)
1062+
)
1063+
)
1064+
)
1065+
getDocsNonInteractive hsc_env mod name =
1066+
do
1067+
let
1068+
init = initTypecheckEnv hsc_env mod $ getDocsNonInteractive' name
1069+
#if MIN_VERSION_ghc (9,2,1)
1070+
(Error.getErrorMessages -> errs, res) <- init
1071+
#else
1072+
((_warns,errs), res) <- init
1073+
#endif
1074+
pure $ maybeToEither errs res
10451075

10461076

10471077
-- | Non-interactive, batch version of 'GHC.Runtime.Eval.getDocs'.
10481078
getDocsBatch
10491079
:: HscEnv
10501080
-> Module -- ^ a moudle where the names are in scope
10511081
-> [Name]
1052-
-- 2021-11-18: NOTE: Map Int would become IntMap if next GHCs.
1053-
-> IO (Either GHC.ErrorMessages (MS.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (IntMap HsDocString)))))
1082+
-> IO(Either GHC.ErrorMessages (MS.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (IntMap HsDocString)))))
10541083
-- ^ Return a 'Map' of 'Name's to 'Either' (no docs messages) (general doc body & arg docs)
1055-
getDocsBatch hsc_env mod names = do
1056-
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ MS.fromList <$> traverse getDocsNonInteractive' names
1057-
pure $ maybeToEither errs res
1084+
getDocsBatch hsc_env mod names =
1085+
do
1086+
let
1087+
init = initTypecheckEnv hsc_env mod $ MS.fromList <$> traverse getDocsNonInteractive' names
1088+
#if MIN_VERSION_ghc (9,2,1)
1089+
(Error.getErrorMessages -> errs, res) <- init
1090+
#else
1091+
((_warns,errs), res) <- init
1092+
#endif
1093+
pure $ maybeToEither errs res
10581094

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

0 commit comments

Comments
 (0)