summaryrefslogtreecommitdiff
path: root/utils/ghctags
diff options
context:
space:
mode:
authorNorman Ramsey <nr@eecs.harvard.edu>2006-09-17 00:24:30 +0000
committerNorman Ramsey <nr@eecs.harvard.edu>2006-09-17 00:24:30 +0000
commit56b37cae901f6a013f6fe8b29d7db9e7c896d6f7 (patch)
treed30f19262f44e904517a3b2096ec3a5ebe57edc0 /utils/ghctags
parent8d76268bfe3046dda8a07f3cb72c720242eebefe (diff)
downloadhaskell-56b37cae901f6a013f6fe8b29d7db9e7c896d6f7.tar.gz
load all files at once and compute tags for all
Diffstat (limited to 'utils/ghctags')
-rw-r--r--utils/ghctags/GhcTags.hs47
1 files changed, 24 insertions, 23 deletions
diff --git a/utils/ghctags/GhcTags.hs b/utils/ghctags/GhcTags.hs
index 65f53f8a59..2defe7515f 100644
--- a/utils/ghctags/GhcTags.hs
+++ b/utils/ghctags/GhcTags.hs
@@ -56,7 +56,16 @@ main = do
GHC.defaultCleanupHandler flags $ do
flags <- initPackages flags
setSessionDynFlags session flags
- filedata <- mapM (findthings session) filenames
+ setTargets session (map fileTarget filenames)
+ print "set targets"
+ success <- load session LoadAllTargets --- bring module graph up to date
+ filedata <- case success of
+ Failed -> do { putStr "Load failed"; exitWith (ExitFailure 2) }
+ Succeeded -> do
+ print "loaded all targets"
+ graph <- getModuleGraph session
+ print "got modules graph"
+ graphData session graph
if mode == BothTags || mode == CTags
then do
ctagsfile <- openFile "tags" openFileMode
@@ -183,28 +192,20 @@ modsummary graph n =
modname :: ModSummary -> ModuleName
modname summary = moduleName $ ms_mod $ summary
-findthings :: Session -> FileName -> IO FileData
-findthings session filename = do
- setTargets session [Target (TargetFile filename Nothing) Nothing]
- print "set targets"
- success <- load session LoadAllTargets --- bring module graph up to date
- case success of
- Failed -> do { print "load failed"; return emptyFileData }
- Succeeded ->
- do print "loaded all targets"
- graph <- getModuleGraph session
- print "got modules graph"
- case modsummary graph filename of
- Nothing -> panic "loaded a module from a file but then could not find its summary"
- Just ms -> do
- mod <- checkModule session (modname ms)
- print "got the module"
- case mod of
- Nothing -> return emptyFileData
- Just m -> case renamedSource m of
- Nothing -> return emptyFileData
- Just s -> return $ fileData filename s
- where emptyFileData = FileData filename []
+fileTarget :: FileName -> Target
+fileTarget filename = Target (TargetFile filename Nothing) Nothing
+
+graphData :: Session -> ModuleGraph -> IO [FileData]
+graphData session graph =
+ mapM foundthings 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
fileData :: FileName -> RenamedSource -> FileData