@@ -88,7 +88,6 @@ import System.Directory
88
88
import System.FilePath
89
89
import System.IO.Extra (fixIO , newTempFileWithin )
90
90
91
- -- GHC API imports
92
91
-- GHC API imports
93
92
import GHC (GetDocsFailure (.. ),
94
93
mgModSummaries ,
@@ -807,6 +806,8 @@ getModSummaryFromImports env fp modTime contents = do
807
806
, fingerPrintImports
808
807
] ++ map Util. fingerprintString opts
809
808
809
+ diagMsgs :: DynFlags -> Util. Bag (MsgEnvelope DecoratedSDoc ) -> [FileDiagnostic ]
810
+ diagMsgs = diagFromErrMsgs " parser"
810
811
811
812
-- | Parse only the module header
812
813
parseHeader
@@ -824,7 +825,7 @@ parseHeader dflags filename contents = do
824
825
case unP Compat. parseHeader (initParserState (initParserOpts dflags) contents loc) of
825
826
#if MIN_VERSION_ghc(8,10,0)
826
827
PFailed pst ->
827
- throwE $ diagFromErrMsgs " parser " dflags $ getErrorMessages pst dflags
828
+ throwE $ diagMsgs dflags $ getErrorMessages pst dflags
828
829
#else
829
830
PFailed _ locErr msgErr ->
830
831
throwE $ diagFromErrMsg " parser" dflags $ mkPlainErrMsg dflags locErr msgErr
@@ -841,9 +842,9 @@ parseHeader dflags filename contents = do
841
842
-- errors are those from which a parse tree just can't
842
843
-- be produced.
843
844
unless (null errs) $
844
- throwE $ diagFromErrMsgs " parser " dflags (fmap pprError errs)
845
+ throwE $ diagMsgs dflags (fmap pprError errs)
845
846
846
- let warnings = diagFromErrMsgs " parser " dflags (fmap pprWarning warns)
847
+ let warnings = diagMsgs dflags (fmap pprWarning warns)
847
848
return (warnings, rdr_module)
848
849
849
850
-- | Given a buffer, flags, and file path, produce a
@@ -861,7 +862,7 @@ parseFileContents env customPreprocessor filename ms = do
861
862
contents = fromJust $ ms_hspp_buf ms
862
863
case unP Compat. parseModule (initParserState (initParserOpts dflags) contents loc) of
863
864
#if MIN_VERSION_ghc(8,10,0)
864
- PFailed pst -> throwE $ diagFromErrMsgs " parser " dflags $ getErrorMessages pst dflags
865
+ PFailed pst -> throwE $ diagMsgs dflags $ getErrorMessages pst dflags
865
866
#else
866
867
PFailed _ locErr msgErr ->
867
868
throwE $ diagFromErrMsg " parser" dflags $ mkPlainErrMsg dflags locErr msgErr
@@ -882,7 +883,7 @@ parseFileContents env customPreprocessor filename ms = do
882
883
-- errors are those from which a parse tree just can't
883
884
-- be produced.
884
885
unless (null errs) $
885
- throwE $ diagFromErrMsgs " parser " dflags errs
886
+ throwE $ diagMsgs dflags errs
886
887
887
888
-- Ok, we got here. It's safe to continue.
888
889
let IdePreprocessedSource preproc_warns errs parsed = customPreprocessor rdr_module
@@ -920,7 +921,7 @@ parseFileContents env customPreprocessor filename ms = do
920
921
srcs2 <- liftIO $ filterM doesFileExist srcs1
921
922
922
923
let pm = mkParsedModule ms parsed' srcs2 hpm_annotations
923
- warnings = diagFromErrMsgs " parser " dflags warns
924
+ warnings = diagMsgs dflags warns
924
925
pure (warnings ++ preproc_warnings, pm)
925
926
926
927
loadHieFile :: Compat. NameCacheUpdater -> FilePath -> IO GHC. HieFile
0 commit comments