@@ -45,18 +45,22 @@ import qualified Data.Text as T
45
45
import Data.Time (getCurrentTime )
46
46
import Data.Typeable (Typeable )
47
47
import Development.IDE (GetModSummary (.. ),
48
+ GetDependencyInformation (.. ),
49
+ GetLinkable (.. ),
48
50
GhcSessionIO (.. ), IdeState ,
49
51
ModSummaryResult (.. ),
50
52
NeedsCompilation (NeedsCompilation ),
51
53
VFSModified (.. ), evalGhcEnv ,
52
54
hscEnvWithImportPaths ,
53
55
printOutputable , runAction ,
56
+ linkableHomeMod ,
54
57
textToStringBuffer ,
55
58
toNormalizedFilePath' ,
56
59
uriToFilePath' , useNoFile_ ,
57
- useWithStale_ , use_ )
60
+ useWithStale_ , use_ , uses_ )
58
61
import Development.IDE.Core.Rules (GhcSessionDepsConfig (.. ),
59
62
ghcSessionDepsDefinition )
63
+ import Development.IDE.Import.DependencyInformation ( reachableModules )
60
64
import Development.IDE.GHC.Compat hiding (typeKind , unitState )
61
65
import qualified Development.IDE.GHC.Compat as Compat
62
66
import qualified Development.IDE.GHC.Compat as SrcLoc
@@ -294,10 +298,19 @@ runEvalCmd plId st EvalParams{..} =
294
298
setContext [Compat. IIModule modName]
295
299
Right <$> getSession
296
300
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
+
297
310
edits <-
298
311
perf " edits" $
299
312
liftIO $
300
- evalGhcEnv hscEnv' $
313
+ evalGhcEnv hscEnv'' $
301
314
runTests
302
315
evalCfg
303
316
(st, fp)
0 commit comments