@@ -111,7 +111,7 @@ import Development.IDE.GHC.Compat hiding
111
111
writeHieFile )
112
112
import Development.IDE.GHC.Error
113
113
import Development.IDE.GHC.ExactPrint
114
- import Development.IDE.GHC.Util
114
+ import Development.IDE.GHC.Util hiding ( modifyDynFlags )
115
115
import Development.IDE.Import.DependencyInformation
116
116
import Development.IDE.Import.FindImports
117
117
import qualified Development.IDE.Spans.AtPoint as AtPoint
@@ -141,7 +141,7 @@ import System.Directory (canonicalizePath)
141
141
import TcRnMonad (tcg_dependent_files )
142
142
143
143
import Ide.Plugin.Properties (HasProperty , KeyNameProxy , Properties , ToHsType , useProperty )
144
- import Ide.Types (PluginId )
144
+ import Ide.Types (PluginId , DynFlagsModifications ( dynFlagsModifyGlobal , dynFlagsModifyParser ) )
145
145
import Data.Default (def )
146
146
import Ide.PluginUtils (configForPlugin )
147
147
import Control.Applicative
@@ -202,18 +202,21 @@ getParsedModuleRule :: Rules ()
202
202
getParsedModuleRule =
203
203
-- this rule does not have early cutoff since all its dependencies already have it
204
204
define $ \ GetParsedModule file -> do
205
- ModSummaryResult {msrModSummary = ms} <- use_ GetModSummary file
205
+ ModSummaryResult {msrModSummary = ms' } <- use_ GetModSummary file
206
206
sess <- use_ GhcSession file
207
207
let hsc = hscEnv sess
208
208
opt <- getIdeOptions
209
+ modify_dflags <- getModifyDynFlags dynFlagsModifyParser
210
+ let ms = ms' { ms_hspp_opts = modify_dflags $ ms_hspp_opts ms' }
209
211
210
212
let dflags = ms_hspp_opts ms
211
213
mainParse = getParsedModuleDefinition hsc opt file ms
214
+ reset_ms pm = pm { pm_mod_summary = ms' }
212
215
213
216
-- Parse again (if necessary) to capture Haddock parse errors
214
217
res@ (_,pmod) <- if gopt Opt_Haddock dflags
215
218
then
216
- liftIO mainParse
219
+ liftIO $ ( fmap . fmap . fmap ) reset_ms mainParse
217
220
else do
218
221
let haddockParse = getParsedModuleDefinition hsc opt file (withOptHaddock ms)
219
222
@@ -223,7 +226,7 @@ getParsedModuleRule =
223
226
-- If we can parse Haddocks, might as well use them
224
227
--
225
228
-- HLINT INTEGRATION: might need to save the other parsed module too
226
- ((diags,res),(diagsh,resh)) <- liftIO $ concurrently mainParse haddockParse
229
+ ((diags,res),(diagsh,resh)) <- liftIO $ ( fmap . fmap . fmap . fmap ) reset_ms $ concurrently mainParse haddockParse
227
230
228
231
-- Merge haddock and regular diagnostics so we can always report haddock
229
232
-- parse errors
@@ -275,8 +278,15 @@ getParsedModuleWithCommentsRule =
275
278
opt <- getIdeOptions
276
279
277
280
let ms' = withoutOption Opt_Haddock $ withOption Opt_KeepRawTokenStream ms
281
+ modify_dflags <- getModifyDynFlags dynFlagsModifyParser
282
+ let ms = ms' { ms_hspp_opts = modify_dflags $ ms_hspp_opts ms' }
283
+ reset_ms pm = pm { pm_mod_summary = ms' }
284
+
285
+ liftIO $ fmap (fmap reset_ms) $ snd <$> getParsedModuleDefinition (hscEnv sess) opt file ms
286
+
287
+ getModifyDynFlags :: (DynFlagsModifications -> a ) -> Action a
288
+ getModifyDynFlags f = f . optModifyDynFlags <$> getIdeOptions
278
289
279
- liftIO $ snd <$> getParsedModuleDefinition (hscEnv sess) opt file ms'
280
290
281
291
getParsedModuleDefinition
282
292
:: HscEnv
@@ -775,7 +785,9 @@ isHiFileStableRule = defineEarlyCutoff $ RuleNoDiagnostics $ \IsHiFileStable f -
775
785
getModSummaryRule :: Rules ()
776
786
getModSummaryRule = do
777
787
defineEarlyCutoff $ Rule $ \ GetModSummary f -> do
778
- session <- hscEnv <$> use_ GhcSession f
788
+ session' <- hscEnv <$> use_ GhcSession f
789
+ modify_dflags <- getModifyDynFlags dynFlagsModifyGlobal
790
+ let session = session' { hsc_dflags = modify_dflags $ hsc_dflags session' }
779
791
(modTime, mFileContent) <- getFileContents f
780
792
let fp = fromNormalizedFilePath f
781
793
modS <- liftIO $ runExceptT $
0 commit comments