- FileData filename (boundValues group)
-
-boundValues :: HsGroup Name -> [FoundThing]
-boundValues group =
- case hs_valds group of
- ValBindsOut nest sigs ->
- [ x | (_rec, binds) <- nest, bind <- bagToList binds, x <- boundThings bind ]
-
-posOfLocated :: Located a -> Pos
-posOfLocated lHs = srcLocToPos $ srcSpanStart $ getLoc lHs
-
-boundThings :: LHsBind Name -> [FoundThing]
-boundThings lbinding =
- let thing id = FoundThing (getOccString $ unLoc id) (posOfLocated id)
+ FileData filename (boundValues modname group)
+
+boundValues :: ModuleName -> HsGroup Name -> [FoundThing]
+boundValues mod group =
+ let vals = case hs_valds group of
+ ValBindsOut nest sigs ->
+ [ x | (_rec, binds) <- nest, bind <- bagToList binds,
+ x <- boundThings mod bind ]
+ tys = concat $ map tyBound (hs_tyclds group)
+ where tyBound ltcd = case unLoc ltcd of
+ ForeignType { tcdLName = n } -> [found n]
+ TyData { tcdLName = tycon, tcdCons = cons } ->
+ dataNames tycon cons
+ TySynonym { tcdLName = n } -> [found n]
+ ClassDecl { tcdLName = n } -> [found n]
+ fors = concat $ map forBound (hs_fords group)
+ where forBound lford = case unLoc lford of
+ ForeignImport n _ _ -> [found n]
+ ForeignExport { } -> []
+ in vals ++ tys ++ fors
+ where dataNames tycon cons = found tycon : map conName cons
+ conName td = found $ con_name $ unLoc td
+ found = foundOfLName mod
+
+startOfLocated :: Located a -> SrcLoc
+startOfLocated lHs = srcSpanStart $ getLoc lHs
+
+foundOfLName :: ModuleName -> Located Name -> FoundThing
+foundOfLName mod id = FoundThing mod (getOccString $ unLoc id) (startOfLocated id)
+
+boundThings :: ModuleName -> LHsBind Name -> [FoundThing]
+boundThings modname lbinding =
+ let thing = foundOfLName modname