Skip to content

Commit c447f2a

Browse files
committed
[new-hs-indexer] Index exports
1 parent 77681e9 commit c447f2a

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
@@ -35,6 +35,7 @@ import System.FilePath
3535
import Control.Monad.Extra (findM, whenJust)
3636

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

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

354363
Glean.makeFact_ @Hs.ModuleDeclarations $ Hs.ModuleDeclarations_key
355-
modfact (map snd names)
364+
modfact (map snd names) (catMaybes eNames)
356365

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

0 commit comments

Comments
 (0)