X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=ghc%2FGhciTags.hs;h=ffec5be64dc26c907d39125a641dde6bdacd4539;hp=c4b52f39c21d5fd36d3e02186b35d87b8475f7ab;hb=b2bd63f99d643f6b3eb30bb72bb9ae26d4183252;hpb=b78303a8d1b21a562b344fd0c4754969948d2419 diff --git a/ghc/GhciTags.hs b/ghc/GhciTags.hs index c4b52f3..ffec5be 100644 --- a/ghc/GhciTags.hs +++ b/ghc/GhciTags.hs @@ -13,10 +13,12 @@ module GhciTags ( createETagsFileCmd ) where +import Exception import GHC import GhciMonad import Outputable import Util +import SrcLoc -- ToDo: figure out whether we need these, and put something appropriate -- into the GHC API instead @@ -29,7 +31,7 @@ import Panic import Data.List import Control.Monad import System.IO -import System.IO.Error as IO +import System.IO.Error ----------------------------------------------------------------------------- -- create tags file for currently loaded modules. @@ -90,20 +92,21 @@ listModuleTags m = do let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames - return $! [ tagInfo unqual exported kind name loc + return $! [ tagInfo unqual exported kind name realLoc | tyThing <- catMaybes mbTyThings , let name = getName tyThing , let exported = GHC.modInfoIsExportedName mInfo name , let kind = tyThing2TagKind tyThing , let loc = srcSpanStart (nameSrcSpan name) - , isGoodSrcLoc loc + , RealSrcLoc realLoc <- [loc] ] where - tyThing2TagKind (AnId _) = 'v' + tyThing2TagKind (AnId _) = 'v' tyThing2TagKind (ADataCon _) = 'd' - tyThing2TagKind (ATyCon _) = 't' - tyThing2TagKind (AClass _) = 'c' + tyThing2TagKind (ATyCon _) = 't' + tyThing2TagKind (AClass _) = 'c' + tyThing2TagKind (ACoAxiom _) = 'x' data TagInfo = TagInfo @@ -118,7 +121,7 @@ data TagInfo = TagInfo -- get tag info, for later translation into Vim or Emacs style -tagInfo :: PrintUnqualified -> Bool -> Char -> Name -> SrcLoc -> TagInfo +tagInfo :: PrintUnqualified -> Bool -> Char -> Name -> RealSrcLoc -> TagInfo tagInfo unqual exported kind name loc = TagInfo exported kind (showSDocForUser unqual $ pprOccName (nameOccName name)) @@ -130,18 +133,18 @@ collateAndWriteTags :: TagsKind -> FilePath -> [TagInfo] -> IO (Either IOError ( -- ctags style with the Ex exresion being just the line number, Vim et al collateAndWriteTags CTagsWithLineNumbers file tagInfos = do let tags = unlines $ sortLe (<=) $ map showCTag tagInfos - IO.try (writeFile file tags) + tryIO (writeFile file tags) -- ctags style with the Ex exresion being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos let tags = unlines $ sortLe (<=) $ map showCTag $concat tagInfoGroups - IO.try (writeFile file tags) + tryIO (writeFile file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups - IO.try (writeFile file $ concat tagGroups) + tryIO (writeFile file $ concat tagGroups) where processGroup [] = ghcError (CmdLineError "empty tag file group??")