Skip to content

Commit 8a6916f

Browse files
committed
Remove a couple of CPP statements from Wingman
1 parent 705c154 commit 8a6916f

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

ghcide/src/Development/IDE/GHC/Compat/Core.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ module Development.IDE.GHC.Compat.Core (
272272
-- * Role
273273
Role(..),
274274
-- * Panic
275+
PlainGhcException,
275276
panic,
276277
-- * Util Module re-exports
277278
#if MIN_VERSION_ghc(9,0,0)
@@ -293,6 +294,7 @@ module Development.IDE.GHC.Compat.Core (
293294
module GHC.Core.TyCon,
294295
module GHC.Core.TyCo.Ppr,
295296
module GHC.Core.Type,
297+
module GHC.Core.Unify,
296298
module GHC.Core.Utils,
297299

298300
module GHC.HsToCore.Docs,
@@ -301,6 +303,11 @@ module Development.IDE.GHC.Compat.Core (
301303

302304
module GHC.Iface.Tidy,
303305
module GHC.Iface.Syntax,
306+
307+
#if MIN_VERSION_ghc(9,2,0)
308+
module Language.Haskell.Syntax.Expr,
309+
#endif
310+
304311
module GHC.Rename.Names,
305312
module GHC.Rename.Splice,
306313

@@ -371,6 +378,7 @@ module Development.IDE.GHC.Compat.Core (
371378
module TysPrim,
372379
module TysWiredIn,
373380
module Type,
381+
module Unify,
374382
module UniqSupply,
375383
module Var,
376384
#endif
@@ -429,6 +437,7 @@ import GHC.Core.TyCo.Ppr
429437
import qualified GHC.Core.TyCo.Rep as TyCoRep
430438
import GHC.Core.TyCon
431439
import GHC.Core.Type hiding (mkInfForAllTys, mkVisFunTys)
440+
import GHC.Core.Unify
432441
import GHC.Core.Utils
433442

434443
#if MIN_VERSION_ghc(9,2,0)
@@ -525,6 +534,7 @@ import GHC.Unit.Module.ModIface (IfaceExport)
525534
import GHC.Unit.State (ModuleOrigin (..))
526535
import GHC.Utils.Error (Severity (..))
527536
import GHC.Utils.Panic hiding (try)
537+
import qualified GHC.Utils.Panic.Plain as Plain
528538
#else
529539
import qualified Avail
530540
import BasicTypes hiding (Version)
@@ -583,7 +593,13 @@ import NameCache
583593
import NameEnv
584594
import NameSet
585595
import Packages
596+
#if MIN_VERSION_ghc(8,8,0)
586597
import Panic hiding (try)
598+
import qualified PlainPanic as Plain
599+
#else
600+
import Panic hiding (GhcException, try)
601+
import qualified Panic as Plain
602+
#endif
587603
import Parser
588604
import PatSyn
589605
#if MIN_VERSION_ghc(8,8,0)
@@ -614,6 +630,7 @@ import TyCon
614630
import Type hiding (mkVisFunTys)
615631
import TysPrim
616632
import TysWiredIn
633+
import Unify
617634
import UniqSupply
618635
import Var (Var (varName), setTyVarUnique,
619636
setVarUnique, varType)
@@ -822,3 +839,9 @@ pattern NotBoot, IsBoot :: IsBootInterface
822839
pattern NotBoot = False
823840
pattern IsBoot = True
824841
#endif
842+
843+
#if MIN_VERSION_ghc(8,8,0)
844+
type PlainGhcException = Plain.PlainGhcException
845+
#else
846+
type PlainGhcException = Plain.GhcException
847+
#endif

plugins/hls-tactics-plugin/src/Wingman/Debug.hs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ import Control.DeepSeq
1818
import Control.Exception
1919
import Debug.Trace
2020
import Development.IDE.GHC.Compat.Outputable
21+
import Development.IDE.GHC.Compat (PlainGhcException)
2122
import System.IO.Unsafe (unsafePerformIO)
2223

23-
#if __GLASGOW_HASKELL__ >= 808
24-
import PlainPanic (PlainGhcException)
25-
type GHC_EXCEPTION = PlainGhcException
26-
#else
27-
import Panic (GhcException)
28-
type GHC_EXCEPTION = GhcException
29-
#endif
30-
31-
3224
------------------------------------------------------------------------------
3325
-- | Print something
3426
unsafeRender :: Outputable a => a -> String
@@ -40,7 +32,7 @@ unsafeRender' sdoc = unsafePerformIO $ do
4032
let z = showSDocUnsafe sdoc
4133
-- We might not have unsafeGlobalDynFlags (like during testing), in which
4234
-- case GHC panics. Instead of crashing, let's just fail to print.
43-
!res <- try @GHC_EXCEPTION $ evaluate $ deepseq z z
35+
!res <- try @PlainGhcException $ evaluate $ deepseq z z
4436
pure $ either (const "<unsafeRender'>") id res
4537
{-# NOINLINE unsafeRender' #-}
4638

plugins/hls-tactics-plugin/src/Wingman/GHC.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import Development.IDE.GHC.Compat
1818
import Development.IDE.GHC.Compat.Util
1919
import GHC.SourceGen (lambda)
2020
import Generics.SYB (Data, everything, everywhere, listify, mkQ, mkT)
21-
import Unify
2221
import Wingman.StaticPlugin (pattern MetaprogramSyntax)
2322
import Wingman.Types
2423

plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser/Documentation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Data.String (IsString)
88
import Data.Text (Text)
99
import Data.Text.Prettyprint.Doc hiding (parens)
1010
import Data.Text.Prettyprint.Doc.Render.String (renderString)
11-
import GhcPlugins (OccName)
11+
import Development.IDE.GHC.Compat (OccName)
1212
import qualified Text.Megaparsec as P
1313
import Wingman.Metaprogramming.Lexer (Parser, identifier, variable, parens)
1414
import Wingman.Types (TacticsM)

plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ pattern MetaprogramSourceText = SourceText "wingman-meta-program"
4040

4141

4242
pattern WingmanMetaprogram :: FastString -> HsExpr p
43-
pattern WingmanMetaprogram mp
44-
<- HsSCC _ MetaprogramSourceText (StringLiteral NoSourceText mp)
43+
pattern WingmanMetaprogram mp <-
44+
#if __GLASGOW_HASKELL__ >= 900
45+
HsPragE _ (HsPragSCC _ MetaprogramSourceText (StringLiteral NoSourceText mp))
4546
(L _ ( HsVar _ _))
47+
#else
48+
HsSCC _ MetaprogramSourceText (StringLiteral NoSourceText mp)
49+
(L _ ( HsVar _ _))
50+
#endif
51+
4652

4753

4854
enableQuasiQuotes :: DynFlags -> DynFlags
@@ -72,7 +78,11 @@ metaprogramHoleName = mkVarOcc "_$metaprogram"
7278

7379
mkMetaprogram :: SrcSpan -> FastString -> HsExpr GhcPs
7480
mkMetaprogram ss mp =
81+
#if __GLASGOW_HASKELL__ >= 900
82+
HsPragE noExtField (HsPragSCC noExtField MetaprogramSourceText (StringLiteral NoSourceText mp))
83+
#else
7584
HsSCC noExtField MetaprogramSourceText (StringLiteral NoSourceText mp)
85+
#endif
7686
$ L ss
7787
$ HsVar noExtField
7888
$ L ss

0 commit comments

Comments
 (0)