Skip to content

Commit a94a2f3

Browse files
committed
WIP
1 parent 5e0c302 commit a94a2f3

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

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

+22-7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ import Development.IDE.GHC.Compat.Util (emptyUDFM, plusUDFM)
110110
import qualified Language.LSP.Server as LSP
111111
import qualified Language.LSP.Types as LSP
112112
import Unsafe.Coerce
113+
import Data.Tuple.Extra (first)
113114

114115
-- | Given a string buffer, return the string (after preprocessing) and the 'ParsedModule'.
115116
parseModule
@@ -996,22 +997,36 @@ getDocsBatch
996997
-> IO (Either ErrorMessages (Map.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))))
997998
-- ^ Return a 'Map' of 'Name's to 'Either' (no docs messages) (general doc body & arg docs)
998999
getDocsBatch hsc_env _mod _names = do
999-
((_warns,errs), res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ Map.fromList <$> traverse findNameInfo _names
1000+
((_warns,errs), res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ Map.fromList <$> traverse findNameInfo undefined
10001001
pure $ maybeToEither errs res
10011002
where
1002-
findNameInfo :: Name -> IOEnv (Env TcGblEnv TcLclEnv) (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))
1003-
findNameInfo name =
1004-
case nameModule_maybe name of
1005-
Nothing -> return (name, Left $ NameHasNoModule name)
1006-
Just mod -> do
1003+
namesGroupedByModule :: [(Maybe Module, [Name])]
1004+
namesGroupedByModule =
1005+
groupSort $ fmap (first nameModule_maybe . dupe) _names
1006+
1007+
fun :: [(Maybe Module, [Name])] -> undefined
1008+
fun a = undefined
1009+
1010+
1011+
loadModuleInterfaceOnce :: Module -> TcRn ModIface
1012+
loadModuleInterfaceOnce =
1013+
loadModuleInterface "getModuleInterface"
1014+
1015+
loadedInterfaces :: [(Maybe (TcRn ModIface), [Name])]
1016+
loadedInterfaces =
1017+
fmap (first (fmap loadModuleInterfaceOnce)) namesGroupedByModule
1018+
1019+
-- 2021-11-18: NOTE: This code initially was taken from: https://hackage.haskell.org/package/ghc-9.2.1/docs/src/GHC.Runtime.Eval.html#getDocs
1020+
findNameInfo :: Maybe Module -> Name -> IOEnv (Env TcGblEnv TcLclEnv) (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))
1021+
findNameInfo Nothing name = return (name, Left $ NameHasNoModule name)
1022+
findNameInfo (Just mod) name = do
10071023
ModIface
10081024
{ mi_doc_hdr = mb_doc_hdr
10091025
, mi_decl_docs = DeclDocMap dmap
10101026
, mi_arg_docs = ArgDocMap amap
10111027
}
10121028
<- loadModuleInterface "getModuleInterface" mod
10131029
pure . (name,) $
1014-
-- 2021-11-17: NOTE: one does not simply check into Mordor (not 1 mode)
10151030
if isNothing mb_doc_hdr && Map.null dmap && Map.null amap
10161031
then Left $ NoDocsInIface mod $ isCompiled name
10171032
else Right (Map.lookup name dmap, Map.lookup name amap)

0 commit comments

Comments
 (0)