@@ -52,7 +52,7 @@ import Development.IDE (Action, GetDependencies (..),
52
52
HscEnvEq , IdeState ,
53
53
ModSummaryResult (.. ),
54
54
NeedsCompilation (NeedsCompilation ),
55
- evalGhcEnv ,
55
+ evalGhcEnv , hscEnv ,
56
56
hscEnvWithImportPaths ,
57
57
prettyPrint , runAction ,
58
58
textToStringBuffer ,
@@ -61,7 +61,8 @@ import Development.IDE (Action, GetDependencies (..),
61
61
useWithStale_ , use_ , uses_ )
62
62
import Development.IDE.Core.Compile (loadModulesHome ,
63
63
setupFinderCache )
64
- import Development.IDE.Core.Rules (TransitiveDependencies (transitiveModuleDeps ))
64
+ import Development.IDE.Core.Rules (TransitiveDependencies (transitiveModuleDeps ),
65
+ ghcSessionDepsDefinition )
65
66
import Development.IDE.GHC.Compat hiding (typeKind , unitState )
66
67
import qualified Development.IDE.GHC.Compat as Compat
67
68
import qualified Development.IDE.GHC.Compat as SrcLoc
@@ -533,30 +534,17 @@ prettyWarn Warn{..} =
533
534
prettyPrint (SrcLoc. getLoc warnMsg) <> " : warning:\n "
534
535
<> " " <> SrcLoc. unLoc warnMsg
535
536
536
- ghcSessionDepsDefinition :: HscEnvEq -> NormalizedFilePath -> Action HscEnv
537
- ghcSessionDepsDefinition env file = do
538
- let hsc = hscEnvWithImportPaths env
539
- deps <- use_ GetDependencies file
540
- let tdeps = transitiveModuleDeps deps
541
- ifaces <- uses_ GetModIface tdeps
542
- liftIO $ assert (all (isJust . hm_linkable . hirHomeMod) ifaces) $ pure ()
543
-
544
- -- Currently GetDependencies returns things in topological order so A comes before B if A imports B.
545
- -- We need to reverse this as GHC gets very unhappy otherwise and complains about broken interfaces.
546
- -- Long-term we might just want to change the order returned by GetDependencies
547
- let inLoadOrder = reverse (map hirHomeMod ifaces)
548
-
549
- liftIO $ loadModulesHome inLoadOrder <$> setupFinderCache (map hirModSummary ifaces) hsc
550
-
551
537
runGetSession :: MonadIO m => IdeState -> NormalizedFilePath -> m HscEnv
552
538
runGetSession st nfp = liftIO $ runAction " eval" st $ do
553
539
-- Create a new GHC Session rather than reusing an existing one
554
540
-- to avoid interfering with ghcide
541
+ -- UPDATE: I suspect that this doesn't really work, we always get the same Session
542
+ -- we probably cache hscEnvs in the Session state
555
543
IdeGhcSession {loadSessionFun} <- useNoFile_ GhcSessionIO
556
544
let fp = fromNormalizedFilePath nfp
557
545
((_, res),_) <- liftIO $ loadSessionFun fp
558
- let hscEnv = fromMaybe (error $ " Unknown file: " <> fp) res
559
- ghcSessionDepsDefinition hscEnv nfp
546
+ let env = fromMaybe (error $ " Unknown file: " <> fp) res
547
+ hscEnv <$> ghcSessionDepsDefinition False env nfp
560
548
561
549
needsQuickCheck :: [(Section , Test )] -> Bool
562
550
needsQuickCheck = any (isProperty . snd )
0 commit comments