Skip to content

Commit 9129475

Browse files
fendorcocreature
andauthored
Update to hie-bios 0.5.0 (#552)
* Update to hie-bios 0.5.0 * Fix test-cases due to changes in the direct cradle * Update test/exe/Main.hs comment Co-authored-by: Moritz Kiefer <[email protected]> Co-authored-by: Moritz Kiefer <[email protected]>
1 parent ec0bbd1 commit 9129475

9 files changed

+21
-21
lines changed

exe/RuleTypes.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type instance RuleResult GetHscEnv = HscEnvEq
1414

1515
data GetHscEnv = GetHscEnv
1616
{ hscenvOptions :: [String] -- componentOptions from hie-bios
17+
, hscenvRoot :: FilePath -- componentRoot from hie-bios
1718
, hscenvDependencies :: [FilePath] -- componentDependencies from hie-bios
1819
}
1920
deriving (Eq, Show, Typeable, Generic)

exe/Rules.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import GHC
2626
import GHC.Check (VersionCheck(..), makeGhcVersionChecker)
2727
import HIE.Bios
2828
import HIE.Bios.Cradle
29-
import HIE.Bios.Environment (addCmdOpts)
29+
import HIE.Bios.Environment (addCmdOpts, makeDynFlagsAbsolute)
3030
import HIE.Bios.Types
3131
import Linker (initDynLinker)
3232
import RuleTypes
@@ -55,8 +55,8 @@ loadGhcSession =
5555
-- This rule is for caching the GHC session. E.g., even when the cabal file
5656
-- changed, if the resulting flags did not change, we would continue to use
5757
-- the existing session.
58-
defineNoFile $ \(GetHscEnv opts deps) ->
59-
liftIO $ createSession $ ComponentOptions opts deps
58+
defineNoFile $ \(GetHscEnv opts optRoot deps) ->
59+
liftIO $ createSession $ ComponentOptions opts optRoot deps
6060

6161
cradleToSession :: Rules ()
6262
cradleToSession = define $ \LoadCradle nfp -> do
@@ -79,13 +79,14 @@ cradleToSession = define $ \LoadCradle nfp -> do
7979
cmpOpts <- liftIO $ mask $ \_ -> getComponentOptions cradle
8080
let opts = componentOptions cmpOpts
8181
deps = componentDependencies cmpOpts
82+
root = componentRoot cmpOpts
8283
deps' = case mbYaml of
8384
-- For direct cradles, the hie.yaml file itself must be watched.
8485
Just yaml | isDirectCradle cradle -> yaml : deps
8586
_ -> deps
8687
existingDeps <- filterM doesFileExist deps'
8788
need existingDeps
88-
([],) . pure <$> useNoFile_ (GetHscEnv opts deps)
89+
([],) . pure <$> useNoFile_ (GetHscEnv opts root deps)
8990

9091
cradleLoadedMethod :: Text
9192
cradleLoadedMethod = "ghcide/cradle/loaded"
@@ -118,7 +119,7 @@ checkGhcVersion = do
118119
return Nothing
119120

120121
createSession :: ComponentOptions -> IO HscEnvEq
121-
createSession (ComponentOptions theOpts _) = do
122+
createSession (ComponentOptions theOpts compRoot _) = do
122123
libdir <- getLibdir
123124

124125
cacheDir <- getCacheDir theOpts
@@ -127,7 +128,8 @@ createSession (ComponentOptions theOpts _) = do
127128

128129
runGhc (Just libdir) $ do
129130
dflags <- getSessionDynFlags
130-
(dflags', _targets) <- addCmdOpts theOpts dflags
131+
(dflags_, _targets) <- addCmdOpts theOpts dflags
132+
let dflags' = makeDynFlagsAbsolute compRoot dflags_
131133
setupDynFlags cacheDir dflags'
132134
versionMismatch <- liftIO checkGhcVersion
133135
case versionMismatch of

ghcide.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ executable ghcide
204204
hashable,
205205
haskell-lsp,
206206
haskell-lsp-types,
207-
hie-bios >= 0.4.0 && < 0.5,
207+
hie-bios >= 0.5.0 && < 0.6,
208208
ghcide,
209209
optparse-applicative,
210210
shake,

stack-ghc-lib.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extra-deps:
55
- haskell-lsp-0.22.0.0
66
- haskell-lsp-types-0.22.0.0
77
- lsp-test-0.10.3.0
8-
- hie-bios-0.4.0
8+
- hie-bios-0.5.0
99
- ghc-lib-parser-8.8.1
1010
- ghc-lib-8.8.1
1111
- fuzzy-0.1.0.0

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extra-deps:
55
- haskell-lsp-0.22.0.0
66
- haskell-lsp-types-0.22.0.0
77
- lsp-test-0.11.0.1
8-
- hie-bios-0.4.0
8+
- hie-bios-0.5.0
99
- fuzzy-0.1.0.0
1010
- regex-pcre-builtin-0.95.1.1.8.43
1111
- regex-base-0.94.0.0

stack810.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extra-deps:
88
- haskell-lsp-types-0.22.0.0
99
- lsp-test-0.11.0.1
1010
- ghc-check-0.3.0.1
11+
- hie-bios-0.5.0
1112

1213
# for ghc-8.10
1314
- Cabal-3.2.0.0

stack84.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extra-deps:
1111
- rope-utf16-splay-0.3.1.0
1212
- filepattern-0.1.1
1313
- js-dgtable-0.5.2
14-
- hie-bios-0.4.0
14+
- hie-bios-0.5.0
1515
- fuzzy-0.1.0.0
1616
- shake-0.18.5
1717
- time-compat-1.9.2.2

stack88.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ extra-deps:
66
- haskell-lsp-types-0.22.0.0
77
- lsp-test-0.11.0.1
88
- ghc-check-0.3.0.1
9-
9+
- hie-bios-0.5.0
1010
nix:
1111
packages: [zlib]

test/exe/Main.hs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -482,26 +482,22 @@ watchedFilesTests = testGroup "watched files"
482482
_doc <- createDoc "A.hs" "haskell" "{-#LANGUAGE NoImplicitPrelude #-}\nmodule A where\nimport WatchedFilesMissingModule"
483483
watchedFileRegs <- getWatchedFilesSubscriptionsUntil @PublishDiagnosticsNotification
484484

485-
-- Expect 6 subscriptions (A does not get any because it's VFS):
485+
-- Expect 4 subscriptions (A does not get any because it's VFS):
486486
-- - /path-to-workspace/WatchedFilesMissingModule.hs
487487
-- - /path-to-workspace/WatchedFilesMissingModule.lhs
488-
-- - WatchedFilesMissingModule.hs
489-
-- - WatchedFilesMissingModule.lhs
490-
-- - src/WatchedFilesMissingModule.hs
491-
-- - src/WatchedFilesMissingModule.lhs
492-
liftIO $ length watchedFileRegs @?= 6
488+
-- - /path-to-workspace/src/WatchedFilesMissingModule.hs
489+
-- - /path-to-workspace/src/WatchedFilesMissingModule.lhs
490+
liftIO $ length watchedFileRegs @?= 4
493491

494492
, testSession' "non workspace file" $ \sessionDir -> do
495493
liftIO $ writeFile (sessionDir </> "hie.yaml") "cradle: {direct: {arguments: [\"-i/tmp\"]}}"
496494
_doc <- createDoc "A.hs" "haskell" "{-# LANGUAGE NoImplicitPrelude#-}\nmodule A where\nimport WatchedFilesMissingModule"
497495
watchedFileRegs <- getWatchedFilesSubscriptionsUntil @PublishDiagnosticsNotification
498496

499-
-- Expect 4 subscriptions (/tmp does not get any as it is out of the workspace):
497+
-- Expect 2 subscriptions (/tmp does not get any as it is out of the workspace):
500498
-- - /path-to-workspace/WatchedFilesMissingModule.hs
501499
-- - /path-to-workspace/WatchedFilesMissingModule.lhs
502-
-- - WatchedFilesMissingModule.hs
503-
-- - WatchedFilesMissingModule.lhs
504-
liftIO $ length watchedFileRegs @?= 4
500+
liftIO $ length watchedFileRegs @?= 2
505501

506502
-- TODO add a test for didChangeWorkspaceFolder
507503
]

0 commit comments

Comments
 (0)