Skip to content

Commit 4c7bcfd

Browse files
committed
findsymbol: add support for ghc 7.10
1 parent 2021083 commit 4c7bcfd

3 files changed

Lines changed: 31 additions & 9 deletions

File tree

hdevtools.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ executable hdevtools
8181
cpp-options: -DENABLE_CABAL
8282

8383
if impl(ghc >= 7.9)
84-
build-depends: Cabal >= 1.22
84+
build-depends: Cabal >= 1.22,
85+
bin-package-db
86+
8587
cpp-options: -DENABLE_CABAL

src/CommandLoop.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module CommandLoop
99

1010
import Control.Monad (when)
1111
import Data.IORef
12-
import Data.List (find)
12+
import Data.List (find, intercalate)
1313
#if __GLASGOW_HASKELL__ < 709
1414
import Data.Traversable (traverse)
1515
#endif
@@ -244,7 +244,7 @@ runCommand state clientSend (CmdFindSymbol symbol files) = do
244244
where
245245
formatModules = intercalate "\n"
246246

247-
247+
248248

249249
#if __GLASGOW_HASKELL__ >= 706
250250
logAction :: IORef State -> ClientSend -> GHC.DynFlags -> GHC.Severity -> GHC.SrcSpan -> Outputable.PprStyle -> ErrUtils.MsgDoc -> IO ()

src/FindSymbol.hs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
{-# Language ScopedTypeVariables #-}
1+
{-# Language ScopedTypeVariables, CPP #-}
22

33
module FindSymbol
44
( findSymbol
55
) where
66

7+
#if __GLASGOW_HASKELL__ < 710
78
import Control.Applicative ((<$>))
9+
import qualified UniqFM
10+
#else
11+
import GHC.PackageDb (exposedName)
12+
import GhcMonad (liftIO)
13+
#endif
14+
815
import Control.Monad (filterM)
916
import Control.Exception
1017
import Data.List (find, nub)
1118
import Data.Maybe (catMaybes, isJust)
12-
import qualified GHC
13-
import qualified UniqFM
19+
import qualified GHC
1420
import qualified Packages as PKG
1521
import qualified Name
1622
import Exception (ghandle)
@@ -57,11 +63,25 @@ findSymbolInPackages symbol =
5763
where
5864
allExposedModules :: GHC.Ghc [GHC.Module]
5965
allExposedModules = do
60-
modNames <- exposedModuleNames <$> GHC.getSessionDynFlags
66+
modNames <- exposedModuleNames
6167
catMaybes <$> mapM findModule modNames
6268
where
63-
exposedModuleNames = concatMap (\pkg -> if PKG.exposed pkg then PKG.exposedModules pkg else [])
64-
. UniqFM.eltsUFM . PKG.pkgIdMap . GHC.pkgState
69+
exposedModuleNames :: GHC.Ghc [GHC.ModuleName]
70+
#if __GLASGOW_HASKELL__ < 710
71+
exposedModuleNames =
72+
concatMap exposedModules
73+
. UniqFM.eltsUFM
74+
. PKG.pkgIdMap
75+
. GHC.pkgState
76+
<$> GHC.getSessionDynFlags
77+
#else
78+
exposedModuleNames = do
79+
dynFlags <- GHC.getSessionDynFlags
80+
pkgConfigs <- liftIO $ PKG.readPackageConfigs dynFlags
81+
return $ map exposedName (concatMap exposedModules pkgConfigs)
82+
#endif
83+
84+
exposedModules pkg = if PKG.exposed pkg then PKG.exposedModules pkg else []
6585

6686
findModule :: GHC.ModuleName -> GHC.Ghc (Maybe GHC.Module)
6787
findModule moduleName =

0 commit comments

Comments
 (0)