@@ -171,11 +171,11 @@ typecheckModule :: IdeDefer
171
171
typecheckModule (IdeDefer defer) hsc tc_helpers pm = do
172
172
let modSummary = pm_mod_summary pm
173
173
dflags = ms_hspp_opts modSummary
174
- mmodSummary' <- catchSrcErrors (hsc_dflags hsc) " typecheck (initialize plugins)"
174
+ initialized <- catchSrcErrors (hsc_dflags hsc) " typecheck (initialize plugins)"
175
175
(initPlugins hsc modSummary)
176
- case mmodSummary' of
176
+ case initialized of
177
177
Left errs -> return (errs, Nothing )
178
- Right modSummary' -> do
178
+ Right ( modSummary', hsc) -> do
179
179
(warnings, etcm) <- withWarnings " typecheck" $ \ tweak ->
180
180
let
181
181
session = tweak (hscSetFlags dflags hsc)
@@ -482,7 +482,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
482
482
Nothing
483
483
#endif
484
484
485
- #else
485
+ #else
486
486
let ! partial_iface = force (mkPartialIface session details simplified_guts)
487
487
final_iface' <- mkFullIface session partial_iface
488
488
#endif
@@ -574,11 +574,6 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
574
574
. ((" Error during " ++ T. unpack source) ++ ) . show @ SomeException
575
575
]
576
576
577
- initPlugins :: HscEnv -> ModSummary -> IO ModSummary
578
- initPlugins session modSummary = do
579
- session1 <- liftIO $ initializePlugins (hscSetFlags (ms_hspp_opts modSummary) session)
580
- return modSummary{ms_hspp_opts = hsc_dflags session1}
581
-
582
577
-- | Whether we should run the -O0 simplifier when generating core.
583
578
--
584
579
-- This is required for template Haskell to work but we disable this in DAML.
@@ -1106,7 +1101,9 @@ getModSummaryFromImports
1106
1101
-> Maybe Util. StringBuffer
1107
1102
-> ExceptT [FileDiagnostic ] IO ModSummaryResult
1108
1103
getModSummaryFromImports env fp modTime contents = do
1109
- (contents, opts, dflags) <- preprocessor env fp contents
1104
+ (contents, opts, env) <- preprocessor env fp contents
1105
+
1106
+ let dflags = hsc_dflags env
1110
1107
1111
1108
-- The warns will hopefully be reported when we actually parse the module
1112
1109
(_warns, L main_loc hsmod) <- parseHeader dflags fp contents
@@ -1165,9 +1162,9 @@ getModSummaryFromImports env fp modTime contents = do
1165
1162
then mkHomeModLocation dflags (pathToModuleName fp) fp
1166
1163
else mkHomeModLocation dflags mod fp
1167
1164
1168
- let modl = mkHomeModule (hscHomeUnit (hscSetFlags dflags env) ) mod
1165
+ let modl = mkHomeModule (hscHomeUnit env) mod
1169
1166
sourceType = if " -boot" `isSuffixOf` takeExtension fp then HsBootFile else HsSrcFile
1170
- msrModSummary =
1167
+ msrModSummary2 =
1171
1168
ModSummary
1172
1169
{ ms_mod = modl
1173
1170
, ms_hie_date = Nothing
@@ -1192,7 +1189,8 @@ getModSummaryFromImports env fp modTime contents = do
1192
1189
, ms_textual_imps = textualImports
1193
1190
}
1194
1191
1195
- msrFingerprint <- liftIO $ computeFingerprint opts msrModSummary
1192
+ msrFingerprint <- liftIO $ computeFingerprint opts msrModSummary2
1193
+ (msrModSummary, msrHscEnv) <- liftIO $ initPlugins env msrModSummary2
1196
1194
return ModSummaryResult {.. }
1197
1195
where
1198
1196
-- Compute a fingerprint from the contents of `ModSummary`,
@@ -1233,7 +1231,7 @@ parseHeader dflags filename contents = do
1233
1231
PFailedWithErrorMessages msgs ->
1234
1232
throwE $ diagFromErrMsgs " parser" dflags $ msgs dflags
1235
1233
POk pst rdr_module -> do
1236
- let (warns, errs) = getMessages' pst dflags
1234
+ let (warns, errs) = renderMessages $ getPsMessages pst dflags
1237
1235
1238
1236
-- Just because we got a `POk`, it doesn't mean there
1239
1237
-- weren't errors! To clarify, the GHC parser
@@ -1268,9 +1266,18 @@ parseFileContents env customPreprocessor filename ms = do
1268
1266
POk pst rdr_module ->
1269
1267
let
1270
1268
hpm_annotations = mkApiAnns pst
1271
- (warns, errs) = getMessages' pst dflags
1269
+ psMessages = getPsMessages pst dflags
1272
1270
in
1273
1271
do
1272
+ let IdePreprocessedSource preproc_warns errs parsed = customPreprocessor rdr_module
1273
+
1274
+ unless (null errs) $
1275
+ throwE $ diagFromStrings " parser" DsError errs
1276
+
1277
+ let preproc_warnings = diagFromStrings " parser" DsWarning preproc_warns
1278
+ (parsed', msgs) <- liftIO $ applyPluginsParsedResultAction env dflags ms hpm_annotations parsed psMessages
1279
+ let (warns, errs) = renderMessages msgs
1280
+
1274
1281
-- Just because we got a `POk`, it doesn't mean there
1275
1282
-- weren't errors! To clarify, the GHC parser
1276
1283
-- distinguishes between fatal and non-fatal
@@ -1283,14 +1290,6 @@ parseFileContents env customPreprocessor filename ms = do
1283
1290
unless (null errs) $
1284
1291
throwE $ diagFromErrMsgs " parser" dflags errs
1285
1292
1286
- -- Ok, we got here. It's safe to continue.
1287
- let IdePreprocessedSource preproc_warns errs parsed = customPreprocessor rdr_module
1288
-
1289
- unless (null errs) $
1290
- throwE $ diagFromStrings " parser" DsError errs
1291
-
1292
- let preproc_warnings = diagFromStrings " parser" DsWarning preproc_warns
1293
- parsed' <- liftIO $ applyPluginsParsedResultAction env dflags ms hpm_annotations parsed
1294
1293
1295
1294
-- To get the list of extra source files, we take the list
1296
1295
-- that the parser gave us,
0 commit comments