on master help sign in
PR feedback
963cb7fNeil Mitchell
src/Development/IDE/Core/Compile.hs+2−2
@@ -272,7 +272,7 @@ parseFileContents
272 -> FilePath -- ^ the filename (for source locations)
272 -> FilePath -- ^ the filename (for source locations)
273 -> Maybe SB.StringBuffer -- ^ Haskell module source text (full Unicode is supported)
273 -> Maybe SB.StringBuffer -- ^ Haskell module source text (full Unicode is supported)
274 -> ExceptT [FileDiagnostic] m ([FileDiagnostic], ParsedModule)
274 -> ExceptT [FileDiagnostic] m ([FileDiagnostic], ParsedModule)
275−parseFileContents sourcePlugin filename mbContents = do
275+parseFileContents customPreprocessor filename mbContents = do
276 (contents, dflags) <- preprocessor filename mbContents
276 (contents, dflags) <- preprocessor filename mbContents
277 let loc = mkRealSrcLoc (mkFastString filename) 1 1
277 let loc = mkRealSrcLoc (mkFastString filename) 1 1
278 case unP Parser.parseModule (mkPState dflags contents loc) of
278 case unP Parser.parseModule (mkPState dflags contents loc) of
@@ -299,7 +299,7 @@ parseFileContents sourcePlugin filename mbContents = do
299 throwE $ diagFromErrMsgs "parser" dflags $ snd $ getMessages pst dflags
299 throwE $ diagFromErrMsgs "parser" dflags $ snd $ getMessages pst dflags
300
300
301 -- Ok, we got here. It's safe to continue.
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 unless (null errs) $ throwE $ diagFromStrings "parser" errs
303 unless (null errs) $ throwE $ diagFromStrings "parser" errs
304 ms <- getModSummaryFromBuffer filename contents dflags parsed
304 ms <- getModSummaryFromBuffer filename contents dflags parsed
305 let pm =
305 let pm =
src/Development/IDE/Core/Preprocessor.hs+9−8
@@ -31,14 +31,15 @@ import Data.Maybe
31preprocessor :: GhcMonad m => FilePath -> Maybe StringBuffer -> ExceptT [FileDiagnostic] m (StringBuffer, DynFlags)
31preprocessor :: GhcMonad m => FilePath -> Maybe StringBuffer -> ExceptT [FileDiagnostic] m (StringBuffer, DynFlags)
32preprocessor filename mbContents = do
32preprocessor filename mbContents = do
33 -- Perform unlit
33 -- Perform unlit
34+ (isOnDisk, contents) <-
34− (isOnDisk, contents) <- if isLiterate filename then do
35+ if isLiterate filename then do
35− dflags <- getDynFlags
36+ dflags <- getDynFlags
36− newcontent <- liftIO $ runLhs dflags filename mbContents
37+ newcontent <- liftIO $ runLhs dflags filename mbContents
37− return (False, newcontent)
38+ return (False, newcontent)
38− else do
39+ else do
39− contents <- liftIO $ maybe (hGetStringBuffer filename) return mbContents
40+ contents <- liftIO $ maybe (hGetStringBuffer filename) return mbContents
40− let isOnDisk = isNothing mbContents
41+ let isOnDisk = isNothing mbContents
41− return (isOnDisk, contents)
42+ return (isOnDisk, contents)
42
43
43 -- Perform cpp
44 -- Perform cpp
44 dflags <- ExceptT $ parsePragmasIntoDynFlags filename contents
45 dflags <- ExceptT $ parsePragmasIntoDynFlags filename contents