File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ parseFileContents
272
272
-> FilePath -- ^ the filename (for source locations)
273
273
-> Maybe SB. StringBuffer -- ^ Haskell module source text (full Unicode is supported)
274
274
-> ExceptT [FileDiagnostic ] m ([FileDiagnostic ], ParsedModule )
275
- parseFileContents sourcePlugin filename mbContents = do
275
+ parseFileContents customPreprocessor filename mbContents = do
276
276
(contents, dflags) <- preprocessor filename mbContents
277
277
let loc = mkRealSrcLoc (mkFastString filename) 1 1
278
278
case unP Parser. parseModule (mkPState dflags contents loc) of
@@ -299,7 +299,7 @@ parseFileContents sourcePlugin filename mbContents = do
299
299
throwE $ diagFromErrMsgs " parser" dflags $ snd $ getMessages pst dflags
300
300
301
301
-- Ok, we got here. It's safe to continue.
302
- let (errs, parsed) = sourcePlugin rdr_module
302
+ let (errs, parsed) = customPreprocessor rdr_module
303
303
unless (null errs) $ throwE $ diagFromStrings " parser" errs
304
304
ms <- getModSummaryFromBuffer filename contents dflags parsed
305
305
let pm =
Original file line number Diff line number Diff line change @@ -31,14 +31,15 @@ import Data.Maybe
31
31
preprocessor :: GhcMonad m => FilePath -> Maybe StringBuffer -> ExceptT [FileDiagnostic ] m (StringBuffer , DynFlags )
32
32
preprocessor filename mbContents = do
33
33
-- Perform unlit
34
- (isOnDisk, contents) <- if isLiterate filename then do
35
- dflags <- getDynFlags
36
- newcontent <- liftIO $ runLhs dflags filename mbContents
37
- return (False , newcontent)
38
- else do
39
- contents <- liftIO $ maybe (hGetStringBuffer filename) return mbContents
40
- let isOnDisk = isNothing mbContents
41
- return (isOnDisk, contents)
34
+ (isOnDisk, contents) <-
35
+ if isLiterate filename then do
36
+ dflags <- getDynFlags
37
+ newcontent <- liftIO $ runLhs dflags filename mbContents
38
+ return (False , newcontent)
39
+ else do
40
+ contents <- liftIO $ maybe (hGetStringBuffer filename) return mbContents
41
+ let isOnDisk = isNothing mbContents
42
+ return (isOnDisk, contents)
42
43
43
44
-- Perform cpp
44
45
dflags <- ExceptT $ parsePragmasIntoDynFlags filename contents
You can’t perform that action at this time.
0 commit comments