This repository was archived by the owner on Oct 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 206
Find the libdir directory of ghc at run-time #1496
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f77fa4c
Find the libdir directory of ghc at run-time
fendor fd66fa7
Update tests to select libdir based on cradle
fendor b5290e0
Express getProjectGhcVersion with execProjectGhc
fendor 21f894a
Move version check into `onInitialisation`
fendor 5741038
Cleanup code, comments and old variable names
fendor c3ca30e
Improve error message of unparsable hie.yaml
fendor fde449b
Use new lsp-test to fix hieBiosError test case
lukel97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ library | |
, unliftio | ||
, monad-control | ||
, mtl | ||
, process | ||
, stm | ||
, syb | ||
, text | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,8 @@ import qualified Data.SortedList as SL | |
import qualified Data.Text as T | ||
import Data.Text.Encoding | ||
import qualified Data.Yaml as Yaml | ||
import Haskell.Ide.Engine.Cradle (findLocalCradle, cradleDisplay) | ||
import Haskell.Ide.Engine.Cradle (findLocalCradle, cradleDisplay | ||
, isCabalCradle) | ||
import Haskell.Ide.Engine.Config | ||
import qualified Haskell.Ide.Engine.Ghc as HIE | ||
import Haskell.Ide.Engine.CodeActions | ||
|
@@ -151,12 +152,64 @@ run scheduler _origDir plugins captureFp = flip E.catches handlers $ do | |
(Debounce.forMonoid $ react . dispatchDiagnostics) | ||
(Debounce.def { Debounce.delay = debounceDuration, Debounce.alwaysResetTimer = True }) | ||
|
||
|
||
let lspRootDir = Core.rootPath lf | ||
currentDir <- liftIO getCurrentDirectory | ||
|
||
-- Check for mismatching GHC versions | ||
let dummyCradleFile = fromMaybe currentDir lspRootDir </> "File.hs" | ||
debugm $ "Dummy Cradle file result: " ++ dummyCradleFile | ||
cradleRes <- liftIO $ E.try (findLocalCradle dummyCradleFile) | ||
let sf = Core.sendFunc lf | ||
|
||
case cradleRes of | ||
Right cradle -> do | ||
projGhcVersion <- liftIO $ getProjectGhcVersion cradle | ||
when (projGhcVersion /= hieGhcVersion) $ do | ||
let msg = T.pack $ "Mismatching GHC versions: " ++ cradleDisplay cradle ++ | ||
" is " ++ projGhcVersion ++ ", HIE is " ++ hieGhcVersion | ||
++ "\nYou may want to use hie-wrapper. Check the README for more information" | ||
sf $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning msg | ||
sf $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning msg | ||
|
||
-- Check cabal is installed | ||
when (isCabalCradle cradle) $ do | ||
hasCabal <- liftIO checkCabalInstall | ||
unless hasCabal $ do | ||
let cabalMsg = T.pack "cabal-install is not installed. Check the README for more information" | ||
sf $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning cabalMsg | ||
sf $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning cabalMsg | ||
|
||
Left (e :: Yaml.ParseException) -> do | ||
logm $ "Failed to parse `hie.yaml`: " ++ show e | ||
sf $ NotShowMessage $ fmServerShowMessageNotification J.MtError ("Couldn't parse hie.yaml: \n" <> T.pack (show e)) | ||
|
||
let mcradle = case cradleRes of | ||
Left _ -> Nothing | ||
Right c -> Just c | ||
|
||
-- haskell lsp sets the current directory to the project root in the InitializeRequest | ||
-- We launch the dispatcher after that so that the default cradle is | ||
-- recognized properly by ghc-mod | ||
flip labelThread "scheduler" =<< (forkIO $ Scheduler.runScheduler scheduler errorHandler callbackHandler (Just lf)) | ||
flip labelThread "reactor" =<< (forkIO reactorFunc) | ||
flip labelThread "diagnostics" =<< (forkIO $ diagnosticsQueue tr) | ||
flip labelThread "scheduler" =<< | ||
(forkIO ( | ||
Scheduler.runScheduler scheduler errorHandler callbackHandler (Just lf) mcradle | ||
`E.catch` \(e :: E.SomeException) -> | ||
(errorm $ "Scheduler thread exited unexpectedly: " ++ show e) | ||
)) | ||
flip labelThread "reactor" =<< | ||
(forkIO ( | ||
reactorFunc | ||
`E.catch` \(e :: E.SomeException) -> | ||
(errorm $ "Reactor thread exited unexpectedly: " ++ show e) | ||
)) | ||
flip labelThread "diagnostics" =<< | ||
(forkIO ( | ||
diagnosticsQueue tr | ||
`E.catch` \(e :: E.SomeException) -> | ||
(errorm $ "Diagnostic thread exited unexpectedly: " ++ show e) | ||
)) | ||
|
||
Comment on lines
+194
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some future date we should go back to launching these threads with |
||
return Nothing | ||
|
||
diagnosticProviders :: Map.Map DiagnosticTrigger [(PluginId,DiagnosticProviderFunc)] | ||
|
@@ -396,35 +449,6 @@ reactor inp diagIn = do | |
reactorSend $ NotLogMessage $ | ||
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack hieVersion | ||
|
||
lspRootDir <- asksLspFuncs Core.rootPath | ||
currentDir <- liftIO getCurrentDirectory | ||
|
||
-- Check for mismatching GHC versions | ||
-- Ignore hie.yaml parse errors. They get reported in ModuleCache.hs | ||
let parseErrorHandler (_ :: Yaml.ParseException) = return Nothing | ||
dummyCradleFile = (fromMaybe currentDir lspRootDir) </> "File.hs" | ||
cradleRes <- liftIO $ E.catch (Just <$> findLocalCradle dummyCradleFile) parseErrorHandler | ||
|
||
case cradleRes of | ||
Just cradle -> do | ||
projGhcVersion <- liftIO $ getProjectGhcVersion cradle | ||
when (projGhcVersion /= hieGhcVersion) $ do | ||
let msg = T.pack $ "Mismatching GHC versions: " ++ cradleDisplay cradle ++ | ||
" is " ++ projGhcVersion ++ ", HIE is " ++ hieGhcVersion | ||
++ "\nYou may want to use hie-wrapper. Check the README for more information" | ||
reactorSend $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning msg | ||
reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning msg | ||
|
||
-- Check cabal is installed | ||
-- TODO: only do this check if its a cabal cradle | ||
hasCabal <- liftIO checkCabalInstall | ||
unless hasCabal $ do | ||
let cabalMsg = T.pack "cabal-install is not installed. Check the README for more information" | ||
reactorSend $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning cabalMsg | ||
reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning cabalMsg | ||
|
||
Nothing -> return () | ||
|
||
renv <- ask | ||
let hreq = GReq tn "init-hoogle" Nothing Nothing Nothing callback Nothing $ IdeResultOk <$> Hoogle.initializeHoogleDb | ||
callback Nothing = flip runReaderT renv $ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.