@@ -989,9 +989,33 @@ mkDetailsFromIface session iface linkable = do
989
989
initIfaceLoad hsc' (typecheckIface iface)
990
990
return (HomeModInfo iface details linkable)
991
991
992
- -- | Non-interactive, batch version of 'InteractiveEval.getDocs'.
992
+
993
+ -- | Non-interactive modification of 'GHC.Runtime.Eval.getDocs'.
993
994
-- The interactive paths create problems in ghc-lib builds
994
- --- and leads to fun errors like "Cannot continue after interface file error".
995
+ --- and lead to fun errors like "Cannot continue after interface file error".
996
+ getDocsNonInteractive :: Name -> IOEnv (Env TcGblEnv TcLclEnv ) (Name , Either GetDocsFailure (Maybe HsDocString , Maybe (Map. Map Int HsDocString )))
997
+ getDocsNonInteractive name = do
998
+ case nameModule_maybe name of
999
+ Nothing -> return (name, Left $ NameHasNoModule name)
1000
+ Just mod -> do
1001
+ ModIface
1002
+ { mi_doc_hdr = mb_doc_hdr
1003
+ , mi_decl_docs = DeclDocMap dmap
1004
+ , mi_arg_docs = ArgDocMap amap
1005
+ }
1006
+ <- loadModuleInterface " getModuleInterface" mod
1007
+ let
1008
+ isNameCompiled =
1009
+ -- TODO: Find a more direct indicator.
1010
+ case nameSrcLoc name of
1011
+ RealSrcLoc {} -> False
1012
+ UnhelpfulLoc {} -> True
1013
+ pure . (name,) $
1014
+ if isNothing mb_doc_hdr && Map. null dmap && Map. null amap
1015
+ then Left $ NoDocsInIface mod isNameCompiled
1016
+ else Right (Map. lookup name dmap, Map. lookup name amap)
1017
+
1018
+ -- | Non-interactive, batch version of 'GHC.Runtime.Eval.getDocs'.
995
1019
getDocsBatch
996
1020
:: HscEnv
997
1021
-> Module -- ^ a moudle where the names are in scope
@@ -1000,30 +1024,8 @@ getDocsBatch
1000
1024
-> IO (Either ErrorMessages (Map. Map Name (Either GetDocsFailure (Maybe HsDocString , Maybe (Map. Map Int HsDocString )))))
1001
1025
-- ^ Return a 'Map' of 'Name's to 'Either' (no docs messages) (general doc body & arg docs)
1002
1026
getDocsBatch hsc_env _mod _names = do
1003
- ((_warns,errs), res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ Map. fromList <$> traverse findNameInfo _names
1027
+ ((_warns,errs), res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ Map. fromList <$> traverse getDocsNonInteractive _names
1004
1028
pure $ maybeToEither errs res
1005
- where
1006
- findNameInfo :: Name -> IOEnv (Env TcGblEnv TcLclEnv ) (Name , Either GetDocsFailure (Maybe HsDocString , Maybe (Map. Map Int HsDocString )))
1007
- findNameInfo name =
1008
- case nameModule_maybe name of
1009
- Nothing -> return (name, Left $ NameHasNoModule name)
1010
- Just mod -> do
1011
- ModIface
1012
- { mi_doc_hdr = mb_doc_hdr
1013
- , mi_decl_docs = DeclDocMap dmap
1014
- , mi_arg_docs = ArgDocMap amap
1015
- }
1016
- <- loadModuleInterface " getModuleInterface" mod
1017
- pure . (name,) $
1018
- -- 2021-11-17: NOTE: one does not simply check into Mordor (not 1 mode)
1019
- if isNothing mb_doc_hdr && Map. null dmap && Map. null amap
1020
- then Left $ NoDocsInIface mod $ isCompiled name
1021
- else Right (Map. lookup name dmap, Map. lookup name amap)
1022
- isCompiled n =
1023
- -- TODO: Find a more direct indicator.
1024
- case nameSrcLoc n of
1025
- RealSrcLoc {} -> False
1026
- UnhelpfulLoc {} -> True
1027
1029
1028
1030
fakeSpan :: RealSrcSpan
1029
1031
fakeSpan = realSrcLocSpan $ mkRealSrcLoc (Util. fsLit " <ghcide>" ) 1 1
0 commit comments