From b455abf0132b109512f967af917cd516b69d1c01 Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Wed, 27 Aug 2014 13:49:31 +0100 Subject: Changes due to ghc api changes in package representation Also fix a bug with finding the package name and version given a module. This had become wrong due to the package key changes (it was very hacky in the first place). We now look up the package key in the package db to get the package info properly. Conflicts: haddock-api/src/Haddock.hs --- haddock-api/src/Haddock/GhcUtils.hs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'haddock-api/src/Haddock/GhcUtils.hs') diff --git a/haddock-api/src/Haddock/GhcUtils.hs b/haddock-api/src/Haddock/GhcUtils.hs index 33d92131..2c7b79a1 100644 --- a/haddock-api/src/Haddock/GhcUtils.hs +++ b/haddock-api/src/Haddock/GhcUtils.hs @@ -22,8 +22,6 @@ import Control.Arrow import Data.Foldable hiding (concatMap) import Data.Function import Data.Traversable -import Distribution.Compat.ReadP -import Distribution.Text import Exception import Outputable @@ -43,24 +41,11 @@ moduleString = moduleNameString . moduleName -- return the (name,version) of the package -modulePackageInfo :: Module -> (String, [Char]) -modulePackageInfo modu = case unpackPackageKey pkg of - Nothing -> (packageKeyString pkg, "") - Just x -> (display $ pkgName x, showVersion (pkgVersion x)) - where pkg = modulePackageKey modu - - --- This was removed from GHC 6.11 --- XXX we shouldn't be using it, probably - --- | Try and interpret a GHC 'PackageKey' as a cabal 'PackageIdentifer'. Returns @Nothing@ if --- we could not parse it as such an object. -unpackPackageKey :: PackageKey -> Maybe PackageIdentifier -unpackPackageKey p - = case [ pid | (pid,"") <- readP_to_S parse str ] of - [] -> Nothing - (pid:_) -> Just pid - where str = packageKeyString p +modulePackageInfo :: DynFlags -> Module -> (PackageName, Version) +modulePackageInfo dflags modu = + (packageName pkg, packageVersion pkg) + where + pkg = getPackageDetails dflags (modulePackageKey modu) lookupLoadedHomeModuleGRE :: GhcMonad m => ModuleName -> m (Maybe GlobalRdrEnv) -- cgit v1.2.3