Skip to content

Commit 84384d1

Browse files
committed
rename
1 parent f6e47c6 commit 84384d1

File tree

1 file changed

+3
-71
lines changed

1 file changed

+3
-71
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
595595
-- For GHC's supporting multi component sessions, we create a shared
596596
-- HscEnv but set the active component accordingly
597597
hscEnv <- emptyHscEnv ideNc _libDir
598-
let new_cache = newComponentCache' recorder optExtensions cfps hscEnv
598+
let new_cache = newComponentCache recorder optExtensions cfps hscEnv
599599
all_target_details <- new_cache old_deps new_deps
600600
let all_targets' = concat all_target_details
601601
flags_map' = HM.fromList (concatMap toFlagsMap all_targets')
@@ -944,15 +944,15 @@ checkHomeUnitsClosed' ue home_id_set
944944
-- This combines all the components we know about into
945945
-- an appropriate session, which is a multi component
946946
-- session on GHC 9.4+
947-
newComponentCache'
947+
newComponentCache
948948
:: Recorder (WithPriority Log)
949949
-> [String] -- ^ File extensions to consider
950950
-> [NormalizedFilePath] -- ^ Path to file that caused the creation of this component
951951
-> HscEnv -- ^ An empty HscEnv
952952
-> [ComponentInfo] -- ^ New components to be loaded
953953
-> [ComponentInfo] -- ^ old, already existing components
954954
-> IO [ [TargetDetails] ]
955-
newComponentCache' recorder exts cfps hsc_env old_cis new_cis = do
955+
newComponentCache recorder exts cfps hsc_env old_cis new_cis = do
956956
let cis = Map.unionWith unionCIs (mkMap new_cis) (mkMap old_cis)
957957
-- When we have multiple components with the same uid,
958958
-- prefer the new one over the old.
@@ -1008,74 +1008,6 @@ newComponentCache' recorder exts cfps hsc_env old_cis new_cis = do
10081008

10091009
return (L.nubOrdOn targetTarget ctargets)
10101010

1011-
-- | Create a mapping from FilePaths to HscEnvEqs
1012-
-- This combines all the components we know about into
1013-
-- an appropriate session, which is a multi component
1014-
-- session on GHC 9.4+
1015-
newComponentCache
1016-
:: Recorder (WithPriority Log)
1017-
-> [String] -- ^ File extensions to consider
1018-
-> NormalizedFilePath -- ^ Path to file that caused the creation of this component
1019-
-> HscEnv -- ^ An empty HscEnv
1020-
-> [ComponentInfo] -- ^ New components to be loaded
1021-
-> [ComponentInfo] -- ^ old, already existing components
1022-
-> IO [ [TargetDetails] ]
1023-
newComponentCache recorder exts _cfp hsc_env old_cis new_cis = do
1024-
let cis = Map.unionWith unionCIs (mkMap new_cis) (mkMap old_cis)
1025-
-- When we have multiple components with the same uid,
1026-
-- prefer the new one over the old.
1027-
-- However, we might have added some targets to the old unit
1028-
-- (see special target), so preserve those
1029-
unionCIs new_ci old_ci = new_ci { componentTargets = componentTargets new_ci ++ componentTargets old_ci }
1030-
mkMap = Map.fromListWith unionCIs . map (\ci -> (componentUnitId ci, ci))
1031-
let dfs = map componentDynFlags $ Map.elems cis
1032-
uids = Map.keys cis
1033-
logWith recorder Info $ LogMakingNewHscEnv uids
1034-
hscEnv' <- -- Set up a multi component session with the other units on GHC 9.4
1035-
Compat.initUnits dfs hsc_env
1036-
1037-
let closure_errs = checkHomeUnitsClosed' (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv')
1038-
multi_errs = map (ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Warning) _cfp . T.pack . Compat.printWithoutUniques) closure_errs
1039-
bad_units = OS.fromList $ concat $ do
1040-
x <- bagToList $ mapBag errMsgDiagnostic $ unionManyBags $ map Compat.getMessages closure_errs
1041-
DriverHomePackagesNotClosed us <- pure x
1042-
pure us
1043-
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units
1044-
-- Whenever we spin up a session on Linux, dynamically load libm.so.6
1045-
-- in. We need this in case the binary is statically linked, in which
1046-
-- case the interactive session will fail when trying to load
1047-
-- ghc-prim, which happens whenever Template Haskell is being
1048-
-- evaluated or haskell-language-server's eval plugin tries to run
1049-
-- some code. If the binary is dynamically linked, then this will have
1050-
-- no effect.
1051-
-- See https://github.com/haskell/haskell-language-server/issues/221
1052-
-- We need to do this after the call to setSessionDynFlags initialises
1053-
-- the loader
1054-
when (os == "linux") $ do
1055-
initObjLinker hscEnv'
1056-
res <- loadDLL hscEnv' "libm.so.6"
1057-
case res of
1058-
Nothing -> pure ()
1059-
Just err -> logWith recorder Error $ LogDLLLoadError err
1060-
1061-
forM (Map.elems cis) $ \ci -> do
1062-
let df = componentDynFlags ci
1063-
thisEnv <- do
1064-
-- In GHC 9.4 we have multi component support, and we have initialised all the units
1065-
-- above.
1066-
-- We just need to set the current unit here
1067-
pure $ hscSetActiveUnitId (homeUnitId_ df) hscEnv'
1068-
henv <- newHscEnvEq thisEnv
1069-
let targetEnv = (if isBad ci then multi_errs else [], Just henv)
1070-
targetDepends = componentDependencyInfo ci
1071-
logWith recorder Debug $ LogNewComponentCache (targetEnv, targetDepends)
1072-
evaluate $ liftRnf rwhnf $ componentTargets ci
1073-
1074-
let mk t = fromTargetId (importPaths df) exts (targetId t) targetEnv targetDepends
1075-
ctargets <- concatMapM mk (componentTargets ci)
1076-
1077-
return (L.nubOrdOn targetTarget ctargets)
1078-
10791011
{- Note [Avoiding bad interface files]
10801012
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10811013
Originally, we set the cache directory for the various components once

0 commit comments

Comments
 (0)