get names of data constructors
[ghc-hetmet.git] / utils / ghctags / GhcTags.hs
index 2defe75..88c2dcb 100644 (file)
@@ -201,12 +201,10 @@ graphData session graph =
     where foundthings ms =
               let filename = msHsFilePath ms
               in  do mod <- checkModule session (moduleName $ ms_mod ms)
-                     return $ case mod of
-                       Nothing -> FileData filename []
-                       Just m -> case renamedSource m of
-                                   Nothing -> FileData filename []
-                                   Just s -> fileData filename s
-
+                     return $ maybe (FileData filename []) id $ do
+                       m <- mod
+                       s <- renamedSource m
+                       return $ fileData filename s
 
 fileData :: FileName -> RenamedSource -> FileData
 fileData filename (group, imports, lie) =
@@ -222,7 +220,8 @@ boundValues group =
       tys = concat $ map tyBound (hs_tyclds group)
             where tyBound ltcd = case unLoc ltcd of
                                    ForeignType { tcdLName = n } -> [foundOfLName n]
-                                   TyData { tcdLName = n } -> [foundOfLName n]
+                                   TyData { tcdLName = tycon, tcdCons = cons } ->
+                                       dataNames tycon cons
                                    TySynonym { tcdLName = n } -> [foundOfLName n]
                                    ClassDecl { tcdLName = n } -> [foundOfLName n]
       fors = concat $ map forBound (hs_fords group)
@@ -230,6 +229,8 @@ boundValues group =
                                       ForeignImport n _ _ -> [foundOfLName n]
                                       ForeignExport { } -> []
   in vals ++ tys ++ fors
+  where dataNames tycon cons = foundOfLName tycon : map conName cons
+        conName td = foundOfLName $ con_name $ unLoc td
 
 posOfLocated :: Located a -> Pos
 posOfLocated lHs = srcLocToPos $ srcSpanStart $ getLoc lHs
@@ -245,3 +246,4 @@ boundThings lbinding =
         PatBind { pat_lhs = lhs } -> panic "Pattern at top level"
         VarBind { var_id = id } -> [FoundThing (getOccString id) (posOfLocated lbinding)]
         AbsBinds { } -> [] -- nothing interesting in a type abstraction
+