on master help sign in
GHC 8.6 compat for the IDE (#955)
c0e9c90Neil Mitchell
src/Development/IDE/Functions/Compile.hs+10
@@ -3,6 +3,7 @@
3
3
4{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE RankNTypes #-}
6+{-# LANGUAGE CPP #-}
6
7
7-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
8-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
8-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
9-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
@@ -414,7 +415,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
414 { ml_hs_file = Just fp
415 { ml_hs_file = Just fp
415 , ml_hi_file = replaceExtension fp "hi"
416 , ml_hi_file = replaceExtension fp "hi"
416 , ml_obj_file = replaceExtension fp "o"
417 , ml_obj_file = replaceExtension fp "o"
418+#ifndef USE_GHC
417 , ml_hie_file = replaceExtension fp "hie"
419 , ml_hie_file = replaceExtension fp "hie"
420+#endif
418 -- This does not consider the dflags configuration
421 -- This does not consider the dflags configuration
419 -- (-osuf and -hisuf, object and hi dir.s).
422 -- (-osuf and -hisuf, object and hi dir.s).
420 -- However, we anyway don't want to generate them.
423 -- However, we anyway don't want to generate them.
@@ -433,7 +436,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
433 , ms_hsc_src = HsSrcFile
436 , ms_hsc_src = HsSrcFile
434 , ms_obj_date = Nothing
437 , ms_obj_date = Nothing
435 , ms_iface_date = Nothing
438 , ms_iface_date = Nothing
439+#ifndef USE_GHC
436 , ms_hie_date = Nothing
440 , ms_hie_date = Nothing
441+#endif
437 , ms_srcimps = [] -- source imports are not allowed
442 , ms_srcimps = [] -- source imports are not allowed
438 , ms_parsed_mod = Nothing
443 , ms_parsed_mod = Nothing
439 }
444 }
@@ -450,8 +455,13 @@ parseFileContents preprocessor filename (time, contents) = do
450 let loc = mkRealSrcLoc (mkFastString filename) 1 1
455 let loc = mkRealSrcLoc (mkFastString filename) 1 1
451 dflags <- parsePragmasIntoDynFlags filename contents
456 dflags <- parsePragmasIntoDynFlags filename contents
452 case unP Parser.parseModule (mkPState dflags contents loc) of
457 case unP Parser.parseModule (mkPState dflags contents loc) of
458+#ifdef USE_GHC
459+ PFailed getMessages _ _ ->
460+ Ex.throwE $ toDiagnostics dflags $ snd $ getMessages dflags
461+#else
453 PFailed s ->
462 PFailed s ->
454 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
463 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
464+#endif
455 POk pst rdr_module ->
465 POk pst rdr_module ->
456 let hpm_annotations =
466 let hpm_annotations =
457 (Map.fromListWith (++) $ annotations pst,
467 (Map.fromListWith (++) $ annotations pst,
src/Development/IDE/Functions/Documentation.hs+1−1
@@ -80,7 +80,7 @@ getDocumentation targetName tcs = fromMaybe [] $ do
80-- | Shows this part of the documentation
80-- | Shows this part of the documentation
81docHeaders :: [RealLocated AnnotationComment]
81docHeaders :: [RealLocated AnnotationComment]
82 -> [T.Text]
82 -> [T.Text]
83−docHeaders = mapMaybe (wrk . unRealSrcSpan)
83+docHeaders = mapMaybe (\(L _ x) -> wrk x)
84 where
84 where
85 wrk = \case
85 wrk = \case
86 AnnDocCommentNext s -> Just $ T.pack s
86 AnnDocCommentNext s -> Just $ T.pack s
src/Development/IDE/Functions/SpanInfo.hs+1−1
@@ -36,7 +36,7 @@ getSpanInfo mods tcm =
36 do let tcs = tm_typechecked_source tcm
36 do let tcs = tm_typechecked_source tcm
37 bs = listifyAllSpans tcs :: [LHsBind GhcTc]
37 bs = listifyAllSpans tcs :: [LHsBind GhcTc]
38 es = listifyAllSpans tcs :: [LHsExpr GhcTc]
38 es = listifyAllSpans tcs :: [LHsExpr GhcTc]
39− ps = listifyAllSpans' tcs :: [LPat GhcTc]
39+ ps = listifyAllSpans' tcs :: [Pat GhcTc]
40 bts <- mapM (getTypeLHsBind tcm) bs -- binds
40 bts <- mapM (getTypeLHsBind tcm) bs -- binds
41 ets <- mapM (getTypeLHsExpr tcm) es -- expressions
41 ets <- mapM (getTypeLHsExpr tcm) es -- expressions
42 pts <- mapM (getTypeLPat tcm) ps -- patterns
42 pts <- mapM (getTypeLPat tcm) ps -- patterns