Update to use hie-bios 0.3.0 from hackage

This commit is contained in:
fendor 2019-12-15 22:06:43 +01:00 committed by fendor
parent 0d447043f1
commit 3ff767ed1c
18 changed files with 38 additions and 54 deletions

6
.gitmodules vendored
View File

@ -18,8 +18,4 @@
[submodule "submodules/ghc-mod"]
path = submodules/ghc-mod
url = https://github.com/fendor/ghc-mod.git
[submodule "hie-bios"]
path = hie-bios
url = https://github.com/mpickering/hie-bios.git
url = https://github.com/fendor/ghc-mod.git

View File

@ -1,7 +1,6 @@
packages:
./
./hie-plugin-api/
./hie-bios/
-- ./submodules/HaRe
./submodules/cabal-helper/

View File

@ -96,7 +96,7 @@ library
, vector
, versions
, yaml >= 0.8.31
, hie-bios
, hie-bios == 0.3.*
, bytestring-trie
, unliftio
, hlint >= 2.2.2

@ -1 +0,0 @@
Subproject commit c396c5557b111369a66e15e21c17d36a10bbb4a5

View File

@ -45,7 +45,7 @@ findLocalCradle :: FilePath -> IO Cradle
findLocalCradle fp = do
cradleConf <- BIOS.findCradle fp
case cradleConf of
Just yaml -> fixCradle <$> BIOS.loadCradle yaml
Just yaml -> BIOS.loadCradle yaml
Nothing -> cabalHelperCradle fp
-- | Check if the given cradle is a stack cradle.
@ -330,7 +330,7 @@ cabalHelperCradle file = do
Cradle { cradleRootDir = cwd
, cradleOptsProg =
CradleAction { actionName = "Cabal-Helper-None"
, runCradle = \_ -> return CradleNone
, runCradle = \_ _ -> return CradleNone
}
}
Just (Ex proj) -> do
@ -358,7 +358,7 @@ cabalHelperCradle file = do
CradleAction { actionName = "Cabal-Helper-"
++ actionNameSuffix
++ "-None"
, runCradle = \_ -> return CradleNone
, runCradle = \_ _ -> return CradleNone
}
}
Just realPackage -> do
@ -374,10 +374,11 @@ cabalHelperCradle file = do
, cradleOptsProg =
CradleAction { actionName =
"Cabal-Helper-" ++ actionNameSuffix
, runCradle = cabalHelperAction
, runCradle = \_ fp -> cabalHelperAction
env
realPackage
normalisedPackageLocation
fp
}
}
where
@ -394,7 +395,7 @@ cabalHelperCradle file = do
in if not (null dir) && isRelative dir then ("-i" ++ base_dir </> dir)
else arg
else arg
-- | cradle Action to query for the ComponentOptions that are needed
-- to load the given FilePath.
-- This Function is not supposed to throw any exceptions and use
@ -430,7 +431,7 @@ cabalHelperCradle file = do
$ CradleFail
$ CradleError
(ExitFailure 2)
("Could not obtain flags for " ++ fp)
["Could not obtain flags for " ++ fp]
-- | Get the component the given FilePath most likely belongs to.
-- Lazily ask units whether the given FilePath is part of one of their
@ -552,29 +553,6 @@ projectSuffix ProjLocV2File {} = "Cabal-V2"
projectSuffix ProjLocV2Dir {} = "Cabal-V2-Dir"
projectSuffix ProjLocStackYaml {} = "Stack"
-- | The hie-bios stack cradle doesn't return the target as well, so add the
-- FilePath onto the end of the options to make sure at least one target
-- is returned.
fixCradle :: BIOS.Cradle -> BIOS.Cradle
fixCradle cradle =
-- Normally this would also succeed for the 'Cabal-Helper-Stack' cradle.
-- Make sure that the cradle is definitely the one created by "HIE.Bios.Cradle.loadCradle"
if isStackCradle cradle
then
-- We need a lens
cradle { BIOS.cradleOptsProg =
(BIOS.cradleOptsProg
cradle) { BIOS.runCradle = \fp' -> fmap (addOption fp')
<$> BIOS.runCradle
(BIOS.cradleOptsProg cradle)
fp'
}
}
else cradle
where
addOption fp (BIOS.ComponentOptions os ds) =
BIOS.ComponentOptions (os ++ [fp]) ds
-- ----------------------------------------------------------------------------
--
-- Utility functions to manipulate FilePath's

View File

@ -47,7 +47,7 @@ import Haskell.Ide.Engine.GhcCompat as Compat
import Outputable hiding ((<>))
-- This function should be defined in HIE probably, nothing in particular
-- to do with BIOS
import qualified HIE.Bios.Ghc.Api as BIOS (withDynFlags, setDeferTypeErrors)
import qualified HIE.Bios.Ghc.Api as BIOS (withDynFlags)
import qualified HIE.Bios.Ghc.Load as BIOS
import System.Directory
@ -158,8 +158,15 @@ captureDiagnostics rfm action = do
handlers = errorHandlers ghcErrRes to_diag
foldDFlags :: (a -> DynFlags -> DynFlags) -> [a] -> DynFlags -> DynFlags
foldDFlags f xs x = foldr f x xs
setDeferTypeErrors =
foldDFlags (flip wopt_set) [Opt_WarnTypedHoles, Opt_WarnDeferredTypeErrors, Opt_WarnDeferredOutOfScopeVariables]
. foldDFlags setGeneralFlag' [Opt_DeferTypedHoles, Opt_DeferTypeErrors, Opt_DeferOutOfScopeVariables]
action' = do
r <- BIOS.withDynFlags (setRawTokenStream . unsetMissingHomeModules . setLogger . BIOS.setDeferTypeErrors . unsetWErr) $
r <- BIOS.withDynFlags (setRawTokenStream . unsetMissingHomeModules . setLogger . setDeferTypeErrors . unsetWErr) $
action
diags <- liftIO $ readIORef diagRef
errs <- liftIO $ readIORef errRef

View File

@ -10,7 +10,7 @@ import GHC
import IOEnv as G
import qualified Data.Text as T
import qualified HIE.Bios.Flags as BIOS (CradleError)
import HIE.Bios.Types (CradleError)
import Haskell.Ide.Engine.PluginUtils (ErrorHandler(..))
@ -55,7 +55,7 @@ errorHandlers onGhcError onSourceError = handlers
onSourceError ex
, ErrorHandler $ \(ex :: IOError) ->
onGhcError (show ex)
, ErrorHandler $ \(ex :: BIOS.CradleError) ->
, ErrorHandler $ \(ex :: CradleError) ->
onGhcError (show ex)
, ErrorHandler $ \(ex :: GhcException) ->
onGhcError (showGhcException ex "")

View File

@ -184,7 +184,7 @@ loadCradle iniDynFlags (NewCradle fp) def action = do
let onGhcError = return . Left
let onSourceError srcErr = do
logm $ "Source error on cradle initialisation: " ++ show srcErr
return $ Right ()
return $ Right BIOS.Failed
-- We continue setting the cradle in case the file has source errors
-- cause they will be reported to user by diagnostics
init_res <- gcatches
@ -203,9 +203,14 @@ loadCradle iniDynFlags (NewCradle fp) def action = do
-- it on a save whilst there are errors. Subsequent loads won't
-- be that slow, even though the cradle isn't cached because the
-- `.hi` files will be saved.
Right () -> do
Right BIOS.Succeeded -> do
setCurrentCradle cradle
logm $ "Cradle set succesfully"
logm "Cradle set succesfully"
IdeResultOk <$> action
Right BIOS.Failed -> do
setCurrentCradle cradle
logm "Cradle did not load succesfully"
IdeResultOk <$> action
-- | Sets the current cradle for caching.

View File

@ -49,7 +49,7 @@ library
, fingertree
, free
, ghc
, hie-bios
, hie-bios == 0.3.*
, ghc-project-types >= 5.9.0.0
, cabal-helper
, haskell-lsp == 0.19.*

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -24,6 +23,7 @@ extra-deps:
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -24,6 +23,7 @@ extra-deps:
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -23,6 +22,7 @@ extra-deps:
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -27,6 +26,7 @@ extra-deps:
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -23,6 +22,7 @@ extra-deps:
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -22,6 +21,7 @@ extra-deps:
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -21,6 +20,7 @@ extra-deps:
- haskell-lsp-0.19.0.0
- haskell-lsp-types-0.19.0.0
- haskell-src-exts-1.21.1
- hie-bios-0.3.0
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -21,6 +20,7 @@ extra-deps:
- haddock-api-2.22.0
- haskell-lsp-0.19.0.0
- haskell-lsp-types-0.19.0.0
- hie-bios-0.3.0
- hlint-2.2.3
- hsimport-0.11.0
- hoogle-5.0.17.11

View File

@ -4,7 +4,6 @@ packages:
- hie-plugin-api
extra-deps:
- ./hie-bios
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types
@ -21,6 +20,7 @@ extra-deps:
- haddock-api-2.22.0
- haskell-lsp-0.19.0.0
- haskell-lsp-types-0.19.0.0
- hie-bios-0.3.0
- hlint-2.2.3
- hsimport-0.11.0
- lsp-test-0.9.0.0