mirror of
https://github.com/haskell/ghcide.git
synced 2024-12-02 08:53:07 +03:00
PR feedback
This commit is contained in:
parent
9cfb9aa9ab
commit
963cb7f647
@ -272,7 +272,7 @@ parseFileContents
|
||||
-> FilePath -- ^ the filename (for source locations)
|
||||
-> Maybe SB.StringBuffer -- ^ Haskell module source text (full Unicode is supported)
|
||||
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], ParsedModule)
|
||||
parseFileContents sourcePlugin filename mbContents = do
|
||||
parseFileContents customPreprocessor filename mbContents = do
|
||||
(contents, dflags) <- preprocessor filename mbContents
|
||||
let loc = mkRealSrcLoc (mkFastString filename) 1 1
|
||||
case unP Parser.parseModule (mkPState dflags contents loc) of
|
||||
@ -299,7 +299,7 @@ parseFileContents sourcePlugin filename mbContents = do
|
||||
throwE $ diagFromErrMsgs "parser" dflags $ snd $ getMessages pst dflags
|
||||
|
||||
-- Ok, we got here. It's safe to continue.
|
||||
let (errs, parsed) = sourcePlugin rdr_module
|
||||
let (errs, parsed) = customPreprocessor rdr_module
|
||||
unless (null errs) $ throwE $ diagFromStrings "parser" errs
|
||||
ms <- getModSummaryFromBuffer filename contents dflags parsed
|
||||
let pm =
|
||||
|
@ -31,14 +31,15 @@ import Data.Maybe
|
||||
preprocessor :: GhcMonad m => FilePath -> Maybe StringBuffer -> ExceptT [FileDiagnostic] m (StringBuffer, DynFlags)
|
||||
preprocessor filename mbContents = do
|
||||
-- Perform unlit
|
||||
(isOnDisk, contents) <- if isLiterate filename then do
|
||||
dflags <- getDynFlags
|
||||
newcontent <- liftIO $ runLhs dflags filename mbContents
|
||||
return (False, newcontent)
|
||||
else do
|
||||
contents <- liftIO $ maybe (hGetStringBuffer filename) return mbContents
|
||||
let isOnDisk = isNothing mbContents
|
||||
return (isOnDisk, contents)
|
||||
(isOnDisk, contents) <-
|
||||
if isLiterate filename then do
|
||||
dflags <- getDynFlags
|
||||
newcontent <- liftIO $ runLhs dflags filename mbContents
|
||||
return (False, newcontent)
|
||||
else do
|
||||
contents <- liftIO $ maybe (hGetStringBuffer filename) return mbContents
|
||||
let isOnDisk = isNothing mbContents
|
||||
return (isOnDisk, contents)
|
||||
|
||||
-- Perform cpp
|
||||
dflags <- ExceptT $ parsePragmasIntoDynFlags filename contents
|
||||
|
Loading…
Reference in New Issue
Block a user