@@ -45,18 +45,22 @@ import qualified Data.Text as T
4545import Data.Time (getCurrentTime )
4646import Data.Typeable (Typeable )
4747import Development.IDE (GetModSummary (.. ),
48+ GetDependencyInformation (.. ),
49+ GetLinkable (.. ),
4850 GhcSessionIO (.. ), IdeState ,
4951 ModSummaryResult (.. ),
5052 NeedsCompilation (NeedsCompilation ),
5153 VFSModified (.. ), evalGhcEnv ,
5254 hscEnvWithImportPaths ,
5355 printOutputable , runAction ,
56+ linkableHomeMod ,
5457 textToStringBuffer ,
5558 toNormalizedFilePath' ,
5659 uriToFilePath' , useNoFile_ ,
57- useWithStale_ , use_ )
60+ useWithStale_ , use_ , uses_ )
5861import Development.IDE.Core.Rules (GhcSessionDepsConfig (.. ),
5962 ghcSessionDepsDefinition )
63+ import Development.IDE.Import.DependencyInformation ( reachableModules )
6064import Development.IDE.GHC.Compat hiding (typeKind , unitState )
6165import qualified Development.IDE.GHC.Compat as Compat
6266import qualified Development.IDE.GHC.Compat as SrcLoc
@@ -294,10 +298,19 @@ runEvalCmd plId st EvalParams{..} =
294298 setContext [Compat. IIModule modName]
295299 Right <$> getSession
296300 evalCfg <- lift $ getEvalConfig plId
301+
302+ -- Get linkables for all modules below us
303+ -- This can be optimised to only get the linkables for the symbols depended on by
304+ -- the statement we are parsing
305+ lbs <- liftIO $ runAction " eval: GetLinkables" st $ do
306+ linkables_needed <- reachableModules <$> use_ GetDependencyInformation nfp
307+ uses_ GetLinkable linkables_needed
308+ let hscEnv'' = hscEnv' { hsc_HPT = addListToHpt (hsc_HPT hscEnv') [(moduleName $ mi_module $ hm_iface hm, hm) | lb <- lbs, let hm = linkableHomeMod lb] }
309+
297310 edits <-
298311 perf " edits" $
299312 liftIO $
300- evalGhcEnv hscEnv' $
313+ evalGhcEnv hscEnv'' $
301314 runTests
302315 evalCfg
303316 (st, fp)
0 commit comments