Skip to content

Commit ec29ef4

Browse files
committed
Stop using CPP and adds ad-hoc version discover logic in Development.IDE.GHC.Util
1 parent edc9b5f commit ec29ef4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

ghcide/src/Development/IDE/GHC/Util.hs

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
module Development.IDE.GHC.Util(
77
modifyDynFlags,
88
evalGhcEnv,
9+
isOverGhc9,
910
-- * GHC wrappers
1011
prettyPrint,
1112
unsafePrintSDoc,
@@ -280,3 +281,10 @@ ioe_dupHandlesNotCompatible :: Handle -> IO a
280281
ioe_dupHandlesNotCompatible h =
281282
ioException (IOError (Just h) IllegalOperation "hDuplicateTo"
282283
"handles are incompatible" Nothing Nothing)
284+
285+
isOverGhc9 :: Bool
286+
#if MIN_VERSION_ghc(9,0,1)
287+
isOverGhc9 = True
288+
#else
289+
isOverGhc9 = False
290+
#endif

ghcide/src/Development/IDE/Main.hs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# OPTIONS_GHC -Wno-orphans #-}
2-
{-# LANGUAGE CPP #-}
32
module Development.IDE.Main
43
(Arguments(..)
54
,Command(..)
@@ -24,7 +23,8 @@ import Data.Maybe (catMaybes, isJust)
2423
import qualified Data.Text as T
2524
import qualified Data.Text.IO as T
2625
import Development.IDE (Action, Rules,
27-
hDuplicateTo')
26+
hDuplicateTo',
27+
isOverGhc9)
2828
import Development.IDE.Core.Debouncer (Debouncer,
2929
newAsyncDebouncer)
3030
import Development.IDE.Core.FileStore (isWatchSupported,
@@ -77,9 +77,7 @@ import Ide.PluginUtils (allLspCmdIds',
7777
pluginDescToIdePlugins)
7878
import Ide.Types (IdePlugins)
7979
import qualified Language.LSP.Server as LSP
80-
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)))
8180
import qualified Language.LSP.Types as LSP
82-
#endif
8381
import Options.Applicative hiding (action)
8482
import qualified System.Directory.Extra as IO
8583
import System.Exit (ExitCode (ExitFailure),
@@ -233,14 +231,13 @@ defaultMain Arguments{..} = do
233231
, optRunSubset = runSubset
234232
}
235233
caps = LSP.resClientCapabilities env
236-
-- FIXME: Remove this after GHC 9 gets fully supported
237-
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)))
238-
LSP.runLspT env $
234+
-- FIXME: Remove this after GHC 9 gets fully supported
235+
when isOverGhc9 $
236+
LSP.runLspT env $
239237
LSP.sendNotification LSP.SWindowShowMessage $
240238
LSP.ShowMessageParams LSP.MtWarning $
241239
"Currently, HLS supports GHC 9 only partially. "
242240
<> "See [issue #297](https://github.com/haskell/haskell-language-server/issues/297) for more detail."
243-
#endif
244241
initialise
245242
argsDefaultHlsConfig
246243
rules

0 commit comments

Comments
 (0)