Skip to content

Commit b0e79fd

Browse files
committed
Don't use typecheck rule for non FOIs in refine imports plugin
Also add an assertion to check that we never use non-FOI rules Fixes #2962
1 parent 0b8c793 commit b0e79fd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,11 @@ typeCheckRule :: Recorder (WithPriority Log) -> Rules ()
650650
typeCheckRule recorder = define (cmapWithPrio LogShake recorder) $ \TypeCheck file -> do
651651
pm <- use_ GetParsedModule file
652652
hsc <- hscEnv <$> use_ GhcSessionDeps file
653-
typeCheckRuleDefinition hsc pm
653+
foi <- use_ IsFileOfInterest file
654+
-- We should only call the typecheck rule for files of interest.
655+
-- Keeping typechecked modules in memory for other files is
656+
-- very expensive.
657+
assert (foi /= NotFOI) $ typeCheckRuleDefinition hsc pm
654658

655659
knownFilesRule :: Recorder (WithPriority Log) -> Rules ()
656660
knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorder) $ \GetKnownTargets -> do

plugins/hls-refine-imports-plugin/src/Ide/Plugin/RefineImports.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ refineImportsRule recorder = define (cmapWithPrio LogShake recorder) $ \RefineIm
187187
-- second layer is from the imports of first layer to their imports
188188
ImportMap importIm <- use_ GetImportMap path
189189
forM importIm $ \imp_path -> do
190-
imp_tmr <- use_ TypeCheck imp_path
191-
return $ tcg_exports $ tmrTypechecked imp_tmr
190+
imp_hir <- use_ GetModIface imp_path
191+
return $ mi_exports $ hirModIface imp_hir
192192

193193
-- Use the GHC api to extract the "minimal" imports
194194
-- We shouldn't blindly refine imports

0 commit comments

Comments
 (0)