Skip to content

Commit f38beda

Browse files
committed
Add support for the multi unit argument syntax introduced in GHC 9.4: https://downloads.haskell.org/ghc/9.4.4/docs/users_guide/using.html#multiple-home-units
We now support arguments of the form ``` -unit @unitA -unit @unitb ``` where the response files `unitA` and `unitB` contain the actual list of arguments for that unit: ``` -this-unit-id a-0.1.0.0 -i -isrc A1 A2 ``` Also refactor the session loader and simplify it. Also adds error messages on GHC 9.4 if the units are not closed (#3422). fixes Fix closure check session-loader: override old units with new in multi-unit support Remove implicit-hie session-loader: remember which files caused old components to be loaded, and also pass them on to hie-bios so it can in turn pass them to `cabal repl` when loading newer components. This allows us to create valid set of build flags encompassing both the old and new components, and the closure of all components in between. The observation is that if you want to load some components X, Y, Z and so on, cabal repl X Y Z ... will be more likely to give you a valid multi component build plan/flags than cabal repl all, or any way of combining the results of cabal repl X, cabal repl Y ... Use new hie-bios Move implicit cradles to HLS Fix build on 9.0 Werror Improve handling of specialTarget
1 parent c3fcc3e commit f38beda

File tree

20 files changed

+557
-212
lines changed

20 files changed

+557
-212
lines changed

cabal.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ packages:
3535
./plugins/hls-refactor-plugin
3636
./plugins/hls-overloaded-record-dot-plugin
3737

38-
index-state: 2023-11-13T12:07:58Z
38+
index-state: 2023-11-14T11:26:13Z
3939

4040
tests: True
4141
test-show-details: direct

exe/Wrapper.hs

+13-13
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ main = do
8383
putStrLn "Tool versions found on the $PATH"
8484
putStrLn $ showProgramVersionOfInterest programsOfInterest
8585
putStrLn "Tool versions in your project"
86-
cradle <- findProjectCradle' False
86+
cradle <- findProjectCradle' recorder False
8787
ghcVersion <- runExceptT $ getRuntimeGhcVersion' recorder cradle
8888
putStrLn $ showProgramVersion "ghc" $ mkVersion =<< eitherToMaybe ghcVersion
8989

@@ -94,10 +94,10 @@ main = do
9494
putStrLn haskellLanguageServerNumericVersion
9595

9696
BiosMode PrintCradleType ->
97-
print =<< findProjectCradle
97+
print =<< findProjectCradle recorder
9898
PrintLibDir -> do
99-
cradle <- findProjectCradle' False
100-
(CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir (toCologActionWithPrio (cmapWithPrio pretty recorder)) cradle
99+
cradle <- findProjectCradle' recorder False
100+
(CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle
101101
putStr libdir
102102
_ -> launchHaskellLanguageServer recorder args >>= \case
103103
Right () -> pure ()
@@ -116,7 +116,7 @@ launchHaskellLanguageServer recorder parsedArgs = do
116116
d <- getCurrentDirectory
117117

118118
-- search for the project cradle type
119-
cradle <- findProjectCradle
119+
cradle <- findProjectCradle recorder
120120

121121
-- Get the root directory from the cradle
122122
setCurrentDirectory $ cradleRootDir cradle
@@ -172,10 +172,10 @@ launchHaskellLanguageServer recorder parsedArgs = do
172172

173173
let cradleName = actionName (cradleOptsProg cradle)
174174
-- we need to be compatible with NoImplicitPrelude
175-
ghcBinary <- liftIO (fmap trim <$> runGhcCmd (toCologActionWithPrio (cmapWithPrio pretty recorder)) ["-v0", "-package-env=-", "-ignore-dot-ghci", "-e", "Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)"])
175+
ghcBinary <- liftIO (fmap trim <$> runGhcCmd ["-v0", "-package-env=-", "-ignore-dot-ghci", "-e", "Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)"])
176176
>>= cradleResult cradleName
177177

178-
libdir <- liftIO (HieBios.getRuntimeGhcLibDir (toCologActionWithPrio (cmapWithPrio pretty recorder)) cradle)
178+
libdir <- liftIO (HieBios.getRuntimeGhcLibDir cradle)
179179
>>= cradleResult cradleName
180180

181181
env <- Map.fromList <$> liftIO getEnvironment
@@ -204,7 +204,7 @@ getRuntimeGhcVersion' recorder cradle = do
204204
Direct -> checkToolExists "ghc"
205205
_ -> pure ()
206206

207-
ghcVersionRes <- liftIO $ HieBios.getRuntimeGhcVersion (toCologActionWithPrio (cmapWithPrio pretty recorder)) cradle
207+
ghcVersionRes <- liftIO $ HieBios.getRuntimeGhcVersion cradle
208208
cradleResult cradleName ghcVersionRes
209209

210210
where
@@ -214,11 +214,11 @@ getRuntimeGhcVersion' recorder cradle = do
214214
Just _ -> pure ()
215215
Nothing -> throwE $ ToolRequirementMissing exe (actionName (cradleOptsProg cradle))
216216

217-
findProjectCradle :: IO (Cradle Void)
218-
findProjectCradle = findProjectCradle' True
217+
findProjectCradle :: Recorder (WithPriority (Doc ())) -> IO (Cradle Void)
218+
findProjectCradle recorder = findProjectCradle' recorder True
219219

220-
findProjectCradle' :: Bool -> IO (Cradle Void)
221-
findProjectCradle' log = do
220+
findProjectCradle' :: Recorder (WithPriority (Doc ())) -> Bool -> IO (Cradle Void)
221+
findProjectCradle' recorder log = do
222222
d <- getCurrentDirectory
223223

224224
let initialFp = d </> "a"
@@ -230,7 +230,7 @@ findProjectCradle' log = do
230230
Just yaml -> hPutStrLn stderr $ "Found \"" ++ yaml ++ "\" for \"" ++ initialFp ++ "\""
231231
Nothing -> hPutStrLn stderr "No 'hie.yaml' found. Try to discover the project type!"
232232

233-
Session.loadCradle def hieYaml d
233+
Session.loadCradle def (cmapWithPrio pretty recorder) hieYaml d
234234

235235
trim :: String -> String
236236
trim s = case lines s of

ghcide/ghcide.cabal

+4-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ library
7676
, Glob
7777
, haddock-library >=1.8 && <1.12
7878
, hashable
79-
, hie-bios ==0.12.1
79+
, hie-bios ==0.13.1
8080
, hie-compat ^>=0.3.0.0
8181
, hiedb >=0.4.4 && <0.4.5
8282
, hls-graph ==2.4.0.0
8383
, hls-plugin-api ==2.4.0.0
84-
, implicit-hie <0.1.3
85-
, implicit-hie-cradle ^>=0.3.0.5 || ^>=0.5
84+
, implicit-hie >= 0.1.4.0 && < 0.1.5
8685
, lens
8786
, list-t
8887
, lsp ^>=2.3.0.0
@@ -111,10 +110,6 @@ library
111110
, unordered-containers >=0.2.10.0
112111
, vector
113112

114-
-- implicit-hie 0.1.3.0 introduced an unexpected behavioral change.
115-
-- https://github.com/Avi-D-coder/implicit-hie/issues/50
116-
-- to make sure ghcide behaves in a desirable way, we put implicit-hie
117-
-- fake dependency here.
118113
if os(windows)
119114
build-depends: Win32
120115

@@ -165,6 +160,7 @@ library
165160
Development.IDE.Core.UseStale
166161
Development.IDE.GHC.Compat
167162
Development.IDE.GHC.Compat.Core
163+
Development.IDE.GHC.Compat.CmdLine
168164
Development.IDE.GHC.Compat.Env
169165
Development.IDE.GHC.Compat.Iface
170166
Development.IDE.GHC.Compat.Logger
@@ -197,6 +193,7 @@ library
197193
Development.IDE.Plugin.TypeLenses
198194
Development.IDE.Session
199195
Development.IDE.Session.Diagnostics
196+
Development.IDE.Session.Implicit
200197
Development.IDE.Spans.AtPoint
201198
Development.IDE.Spans.Common
202199
Development.IDE.Spans.Documentation

0 commit comments

Comments
 (0)