Don't rely on ghc-mod being in PATH
This commit is contained in:
parent
c3b959a8e5
commit
3c04e78ba7
@ -27,12 +27,13 @@ import Exception (ghandle, handleIO)
|
|||||||
import qualified GHC as G
|
import qualified GHC as G
|
||||||
import Language.Haskell.GhcMod.Convert
|
import Language.Haskell.GhcMod.Convert
|
||||||
import Language.Haskell.GhcMod.Monad
|
import Language.Haskell.GhcMod.Monad
|
||||||
|
import Language.Haskell.GhcMod.Utils
|
||||||
import Language.Haskell.GhcMod.Types
|
import Language.Haskell.GhcMod.Types
|
||||||
import Name (getOccString)
|
import Name (getOccString)
|
||||||
import System.Directory (doesDirectoryExist, getAppUserDataDirectory, doesFileExist, getModificationTime)
|
import System.Directory (doesDirectoryExist, getAppUserDataDirectory, doesFileExist, getModificationTime)
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process (readProcess)
|
import System.Environment (getExecutablePath)
|
||||||
|
|
||||||
#ifndef MIN_VERSION_containers
|
#ifndef MIN_VERSION_containers
|
||||||
#define MIN_VERSION_containers(x,y,z) 1
|
#define MIN_VERSION_containers(x,y,z) 1
|
||||||
@ -84,9 +85,18 @@ lookupSymbol opt sym db = convert opt $ lookupSymbol' sym db
|
|||||||
loadSymbolDb :: IO SymbolDb
|
loadSymbolDb :: IO SymbolDb
|
||||||
loadSymbolDb = SymbolDb <$> readSymbolDb
|
loadSymbolDb = SymbolDb <$> readSymbolDb
|
||||||
|
|
||||||
|
ghcModExecutable :: IO FilePath
|
||||||
|
ghcModExecutable =
|
||||||
|
#ifndef SPEC
|
||||||
|
getExecutablePath
|
||||||
|
#else
|
||||||
|
return "dist/build/ghc-mod/ghc-mod"
|
||||||
|
#endif
|
||||||
|
|
||||||
readSymbolDb :: IO (Map Symbol [ModuleString])
|
readSymbolDb :: IO (Map Symbol [ModuleString])
|
||||||
readSymbolDb = handle (\(SomeException _) -> return M.empty) $ do
|
readSymbolDb = handle (\(SomeException _) -> return M.empty) $ do
|
||||||
file <- chop <$> readProcess "ghc-mod" ["dumpsym"] []
|
ghcMod <- ghcModExecutable
|
||||||
|
file <- chop <$> readProcess' ghcMod ["dumpsym"]
|
||||||
M.fromAscList . map conv . lines <$> readFile file
|
M.fromAscList . map conv . lines <$> readFile file
|
||||||
where
|
where
|
||||||
conv :: String -> (Symbol,[ModuleString])
|
conv :: String -> (Symbol,[ModuleString])
|
||||||
|
Loading…
Reference in New Issue
Block a user