Skip to content

Commit 5c3b3d6

Browse files
committed
Fix eval plugin
1 parent 5c3f941 commit 5c3b3d6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,22 @@ import qualified Data.Text as T
4545
import Data.Time (getCurrentTime)
4646
import Data.Typeable (Typeable)
4747
import 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_)
5861
import Development.IDE.Core.Rules (GhcSessionDepsConfig (..),
5962
ghcSessionDepsDefinition)
63+
import Development.IDE.Import.DependencyInformation ( reachableModules )
6064
import Development.IDE.GHC.Compat hiding (typeKind, unitState)
6165
import qualified Development.IDE.GHC.Compat as Compat
6266
import 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

Comments
 (0)