Skip to content

Commit a55699f

Browse files
committed
[new-hs-indexer] Index exports
1 parent d9ef7f4 commit a55699f

File tree

4 files changed

+400
-3
lines changed

4 files changed

+400
-3
lines changed

glean/lang/haskell/HieIndexer/Index.hs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Control.Monad.Extra (findM, whenJust)
3636

3737
import qualified GHC
3838
import GHC.Utils.Outputable (ppr)
39+
import qualified GHC.Types.Avail as GHC (availNames)
3940
import qualified GHC.Types.Basic as GHC (TupleSort(..), isPromoted)
4041
import qualified GHC.Iface.Type as GHC (
4142
IfaceTyLit(..), IfaceTyConSort(..), IfaceTyCon(..), IfaceTyConInfo(..))
@@ -81,8 +82,7 @@ import Glean.Util.Range
8182
Haddock's Interface type has all the ASTs for the declarations
8283
in addition to the Hie.
8384
84-
- index exports
85-
- can we tag Names correctly with exportedness?
85+
- map Name to exportedness?
8686
8787
- exclude generated names in a cleaner way
8888
@@ -350,10 +350,19 @@ indexHieFile writer srcPaths path hie = do
350350
nameMap :: Map GHC.Name Hs.Name
351351
nameMap = Map.fromList names
352352

353+
eNames <- forM (concatMap GHC.availNames (hie_exports hie)) $ \name ->
354+
case Map.lookup name nameMap of
355+
Just hsName -> return $ Just hsName
356+
Nothing -> case nameModule_maybe name of
357+
Nothing -> return Nothing -- shouldn't happen
358+
Just m -> do
359+
mod <- if m == smod then return modfact else mkModule m
360+
Just <$> mkName name mod (Hs.NameSort_external def)
361+
353362
produceDeclInfo nameMap declInfo
354363

355364
Glean.makeFact_ @Hs.ModuleDeclarations $ Hs.ModuleDeclarations_key
356-
modfact (map snd names)
365+
modfact (map snd names) (catMaybes eNames)
357366

358367
let refs = Map.fromListWith (Map.unionWith (++))
359368
[ (n, Map.singleton kind [span])

0 commit comments

Comments
 (0)