Skip to content

Commit

Permalink
Use the LSP provided root directory to find the cradle
Browse files Browse the repository at this point in the history
When checking for GHC version.  This also removes the redundant check in
MainHie (I'm not sure why were checking twice). This will remove the
check for the JSON transport, but as far as I am aware this is
unmantained anyway.
  • Loading branch information
lukel97 authored and mpickering committed Nov 14, 2019
1 parent 714f42a commit dcf81a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
11 changes: 1 addition & 10 deletions app/MainHie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,13 @@ run opts = do

Core.setupLogger mLogFileName ["hie", "hie-bios"] logLevel

d <- getCurrentDirectory
-- Get the cabal directory from the cradle
cradle <- findLocalCradle (d </> "File.hs")

projGhcVersion <- getProjectGhcVersion cradle
when (projGhcVersion /= hieGhcVersion) $
warningm $ "Mismatching GHC versions: Project is " ++ projGhcVersion
++ ", HIE is " ++ hieGhcVersion

origDir <- getCurrentDirectory

maybe (pure ()) setCurrentDirectory $ projectRoot opts

progName <- getProgName
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version
logm $ "Current directory:" ++ d
logm $ "Current directory:" ++ origDir
args <- getArgs
logm $ "args:" ++ show args

Expand Down
13 changes: 7 additions & 6 deletions src/Haskell/Ide/Engine/Transport/LspStdio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,10 @@ reactor inp diagIn = do
reactorSend $ NotLogMessage $
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack version

d <- liftIO getCurrentDirectory
cradle <- liftIO $ findLocalCradle (d </> "File.hs")
lspRootDir <- asksLspFuncs Core.rootPath
currentDir <- liftIO getCurrentDirectory

cradle <- liftIO $ findLocalCradle ((fromMaybe currentDir lspRootDir) </> "File.hs")
-- Check for mismatching GHC versions
projGhcVersion <- liftIO $ getProjectGhcVersion cradle
when (projGhcVersion /= hieGhcVersion) $ do
Expand All @@ -437,13 +439,12 @@ reactor inp diagIn = do
reactorSend $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning msg
reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning msg


lf <- ask
renv <- ask
let hreq = GReq tn Nothing Nothing Nothing callback Nothing $ IdeResultOk <$> Hoogle.initializeHoogleDb
callback Nothing = flip runReaderT lf $
callback Nothing = flip runReaderT renv $
reactorSend $ NotShowMessage $
fmServerShowMessageNotification J.MtWarning "No hoogle db found. Check the README for instructions to generate one"
callback (Just db) = flip runReaderT lf $ do
callback (Just db) = flip runReaderT renv $ do
reactorSend $ NotLogMessage $
fmServerLogMessageNotification J.MtLog $ "Using hoogle db at: " <> T.pack db
makeRequest hreq
Expand Down

0 comments on commit dcf81a1

Please sign in to comment.