Skip to content

Commit c62e42f

Browse files
konnjneira
authored andcommitted
Stop using CPP and adds ad-hoc version discover logic in Development.IDE.GHC.Util
1 parent ef9d871 commit c62e42f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 5 additions & 8 deletions
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(..)
@@ -27,7 +26,8 @@ import qualified Data.Text.IO as T
2726
import Data.Text.Lazy.Encoding (decodeUtf8)
2827
import qualified Data.Text.Lazy.IO as LT
2928
import Development.IDE (Action, Rules,
30-
hDuplicateTo')
29+
hDuplicateTo',
30+
isOverGhc9)
3131
import Development.IDE.Core.Debouncer (Debouncer,
3232
newAsyncDebouncer)
3333
import Development.IDE.Core.FileStore (isWatchSupported,
@@ -86,9 +86,7 @@ import Ide.Types (IdeCommand (IdeCommand),
8686
PluginId (PluginId),
8787
ipMap)
8888
import qualified Language.LSP.Server as LSP
89-
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)))
9089
import qualified Language.LSP.Types as LSP
91-
#endif
9290
import Options.Applicative hiding (action)
9391
import qualified System.Directory.Extra as IO
9492
import System.Exit (ExitCode (ExitFailure),
@@ -260,14 +258,13 @@ defaultMain Arguments{..} = do
260258
, optRunSubset = runSubset
261259
}
262260
caps = LSP.resClientCapabilities env
263-
-- FIXME: Remove this after GHC 9 gets fully supported
264-
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)))
265-
LSP.runLspT env $
261+
-- FIXME: Remove this after GHC 9 gets fully supported
262+
when isOverGhc9 $
263+
LSP.runLspT env $
266264
LSP.sendNotification LSP.SWindowShowMessage $
267265
LSP.ShowMessageParams LSP.MtWarning $
268266
"Currently, HLS supports GHC 9 only partially. "
269267
<> "See [issue #297](https://github.com/haskell/haskell-language-server/issues/297) for more detail."
270-
#endif
271268
initialise
272269
argsDefaultHlsConfig
273270
rules

0 commit comments

Comments
 (0)