@@ -165,6 +165,7 @@ data Log
165
165
| LogLoadingHieFileFail ! FilePath ! SomeException
166
166
| LogLoadingHieFileSuccess ! FilePath
167
167
| LogExactPrint ExactPrint. Log
168
+ | LogTypecheckedFOI ! NormalizedFilePath
168
169
deriving Show
169
170
170
171
instance Pretty Log where
@@ -182,6 +183,14 @@ instance Pretty Log where
182
183
LogLoadingHieFileSuccess path ->
183
184
" SUCCEEDED LOADING HIE FILE FOR" <+> pretty path
184
185
LogExactPrint log -> pretty log
186
+ LogTypecheckedFOI path -> vcat
187
+ [ " WARNING: Typechecked a file which is not currently open in the editor:" <+> pretty (fromNormalizedFilePath path)
188
+ , " This can indicate a bug which results in excessive memory usage."
189
+ , " This may be a spurious warning if you have recently closed the file."
190
+ , " If you haven't opened this file recently, please file a report on the issue tracker mentioning"
191
+ <+> " the HLS version being used, the plugins enabled, and if possible the codebase and file which"
192
+ <+> " triggered this warning."
193
+ ]
185
194
186
195
templateHaskellInstructions :: T. Text
187
196
templateHaskellInstructions = " https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html#static-binaries"
@@ -650,6 +659,12 @@ typeCheckRule :: Recorder (WithPriority Log) -> Rules ()
650
659
typeCheckRule recorder = define (cmapWithPrio LogShake recorder) $ \ TypeCheck file -> do
651
660
pm <- use_ GetParsedModule file
652
661
hsc <- hscEnv <$> use_ GhcSessionDeps file
662
+ foi <- use_ IsFileOfInterest file
663
+ -- We should only call the typecheck rule for files of interest.
664
+ -- Keeping typechecked modules in memory for other files is
665
+ -- very expensive.
666
+ when (foi == NotFOI ) $
667
+ logWith recorder Logger. Warning $ LogTypecheckedFOI file
653
668
typeCheckRuleDefinition hsc pm
654
669
655
670
knownFilesRule :: Recorder (WithPriority Log ) -> Rules ()
0 commit comments