From 35173dc45ad08e463cdd9b638c16275677dd4304 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 2 May 2021 12:04:02 +0100 Subject: [PATCH] clean up ghc-api pragmas We no longer depend on ghc-lib so it's cleanup time --- ghcide/ghcide.cabal | 6 +-- ghcide/include/ghc-api-version.h | 12 ------ .../session-loader/Development/IDE/Session.hs | 1 - ghcide/src/Development/IDE/Core/Compile.hs | 21 +++++----- ghcide/src/Development/IDE/Core/Rules.hs | 1 - ghcide/src/Development/IDE/Core/Tracing.hs | 3 +- ghcide/src/Development/IDE/GHC/CPP.hs | 15 ++++--- ghcide/src/Development/IDE/GHC/Compat.hs | 41 +++++++++---------- ghcide/src/Development/IDE/GHC/Orphans.hs | 3 +- .../src/Development/IDE/Import/FindImports.hs | 1 - ghcide/src/Development/IDE/LSP/Outline.hs | 3 +- .../src/Development/IDE/Plugin/CodeAction.hs | 1 - .../src/Development/IDE/Plugin/Completions.hs | 1 - .../IDE/Plugin/Completions/Logic.hs | 5 +-- ghcide/src/Development/IDE/Spans/AtPoint.hs | 3 +- ghcide/src/Development/IDE/Spans/Common.hs | 1 - .../Development/IDE/Spans/Documentation.hs | 1 - ghcide/test/exe/Main.hs | 11 +++-- haskell-language-server.cabal | 1 - include/ghc-api-version.h | 10 ----- .../hls-explicit-imports-plugin.cabal | 1 - .../include/ghc-api-version.h | 4 +- .../src/Ide/Plugin/ExplicitImports.hs | 1 - .../hls-retrie-plugin/hls-retrie-plugin.cabal | 1 - .../include/ghc-api-version.h | 4 +- .../src/Ide/Plugin/Retrie.hs | 5 +-- 26 files changed, 57 insertions(+), 100 deletions(-) delete mode 100644 ghcide/include/ghc-api-version.h delete mode 100644 include/ghc-api-version.h diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 216fb1f5f0..288c535592 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -14,7 +14,7 @@ description: homepage: https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme bug-reports: https://github.com/haskell/haskell-language-server/issues tested-with: GHC == 8.6.4 || == 8.6.5 || == 8.8.2 || == 8.8.3 || == 8.8.4 || == 8.10.2 || == 8.10.3 || == 8.10.4 -extra-source-files: include/ghc-api-version.h README.md CHANGELOG.md +extra-source-files: README.md CHANGELOG.md test/data/**/*.project test/data/**/*.cabal test/data/**/*.yaml @@ -333,9 +333,9 @@ test-suite ghcide-tests extra, filepath, -------------------------------------------------------------- - -- The MIN_GHC_API_VERSION macro relies on MIN_VERSION pragmas + -- The MIN_VERSION_ghc macro relies on MIN_VERSION pragmas -- which require depending on ghc. So the tests need to depend - -- on ghc if they need to use MIN_GHC_API_VERSION. Maybe a + -- on ghc if they need to use MIN_VERSION_ghc. Maybe a -- better solution can be found, but this is a quick solution -- which works for now. ghc, diff --git a/ghcide/include/ghc-api-version.h b/ghcide/include/ghc-api-version.h deleted file mode 100644 index 92580a12f8..0000000000 --- a/ghcide/include/ghc-api-version.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef GHC_API_VERSION_H -#define GHC_API_VERSION_H - -#ifdef GHC_LIB -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib(x,y,z) -#define GHC_API_VERSION VERSION_ghc_lib -#else -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc(x,y,z) -#define GHC_API_VERSION VERSION_ghc -#endif - -#endif diff --git a/ghcide/session-loader/Development/IDE/Session.hs b/ghcide/session-loader/Development/IDE/Session.hs index 3c776cb36b..ac1efb21a8 100644 --- a/ghcide/session-loader/Development/IDE/Session.hs +++ b/ghcide/session-loader/Development/IDE/Session.hs @@ -1,6 +1,5 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} -#include "ghc-api-version.h" {-| The logic for setting up a ghcide session by tapping into hie-bios. diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index ff8f5f1c0c..3d7e0433a7 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -4,7 +4,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} -#include "ghc-api-version.h" -- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API. -- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values. @@ -57,7 +56,7 @@ import LoadIface (loadModuleInterface) import Lexer import qualified Parser -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) import Control.DeepSeq (force, rnf) #else import Control.DeepSeq (rnf) @@ -234,7 +233,7 @@ mkHiFileResultNoCompile session tcm = do tcGblEnv = tmrTypechecked tcm details <- makeSimpleDetails hsc_env_tmp tcGblEnv sf <- finalSafeMode (ms_hspp_opts ms) tcGblEnv -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) iface <- mkIfaceTc hsc_env_tmp sf details tcGblEnv #else (iface, _) <- mkIfaceTc hsc_env_tmp Nothing sf details tcGblEnv @@ -268,7 +267,7 @@ mkHiFileResultCompile session' tcm simplified_guts ltype = catchErrs $ do (guts, details) <- tidyProgram session simplified_guts (diags, linkable) <- genLinkable session ms guts pure (linkable, details, diags) -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) let !partial_iface = force (mkPartialIface session details simplified_guts) final_iface <- mkFullIface session partial_iface #else @@ -330,14 +329,14 @@ generateObjectCode session summary guts = do (warnings, dot_o_fp) <- withWarnings "object" $ \_tweak -> do let summary' = _tweak summary -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) target = defaultObjectTarget $ hsc_dflags session #else target = defaultObjectTarget $ targetPlatform $ hsc_dflags session #endif session' = session { hsc_dflags = updOptLevel 0 $ (ms_hspp_opts summary') { outputFile = Just dot_o , hscTarget = target}} (outputFilename, _mStub, _foreign_files) <- hscGenHardCode session' guts -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) (ms_location summary') #else summary' @@ -360,7 +359,7 @@ generateByteCode hscEnv summary guts = do let summary' = _tweak summary session = hscEnv { hsc_dflags = ms_hspp_opts summary' } hscInteractive session guts -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) (ms_location summary') #else summary' @@ -419,7 +418,7 @@ unnecessaryDeprecationWarningFlags , Opt_WarnUnusedMatches , Opt_WarnUnusedTypePatterns , Opt_WarnUnusedForalls -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) , Opt_WarnUnusedRecordWildcards #endif , Opt_WarnInaccessibleCode @@ -738,7 +737,7 @@ getModSummaryFromImports env fp modTime contents = do msrModSummary = ModSummary { ms_mod = modl -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) , ms_hie_date = Nothing #endif , ms_hs_date = modTime @@ -782,7 +781,7 @@ parseHeader parseHeader dflags filename contents = do let loc = mkRealSrcLoc (mkFastString filename) 1 1 case unP Parser.parseHeader (mkPState dflags contents loc) of -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) PFailed pst -> throwE $ diagFromErrMsgs "parser" dflags $ getErrorMessages pst dflags #else @@ -820,7 +819,7 @@ parseFileContents env customPreprocessor filename ms = do dflags = ms_hspp_opts ms contents = fromJust $ ms_hspp_buf ms case unP Parser.parseModule (mkPState dflags contents loc) of -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) PFailed pst -> throwE $ diagFromErrMsgs "parser" dflags $ getErrorMessages pst dflags #else PFailed _ locErr msgErr -> diff --git a/ghcide/src/Development/IDE/Core/Rules.hs b/ghcide/src/Development/IDE/Core/Rules.hs index f63da383a0..d4525d8dd3 100644 --- a/ghcide/src/Development/IDE/Core/Rules.hs +++ b/ghcide/src/Development/IDE/Core/Rules.hs @@ -5,7 +5,6 @@ {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} -#include "ghc-api-version.h" -- | A Shake implementation of the compiler service, built -- using the "Shaker" abstraction layer for in-memory use. diff --git a/ghcide/src/Development/IDE/Core/Tracing.hs b/ghcide/src/Development/IDE/Core/Tracing.hs index a9ba01eac6..845b9ffdda 100644 --- a/ghcide/src/Development/IDE/Core/Tracing.hs +++ b/ghcide/src/Development/IDE/Core/Tracing.hs @@ -1,6 +1,5 @@ {-# LANGUAGE NoApplicativeDo #-} {-# LANGUAGE CPP #-} -#include "ghc-api-version.h" module Development.IDE.Core.Tracing ( otTracedHandler , otTracedAction @@ -96,7 +95,7 @@ otTracedAction key file success act return res) | otherwise = act -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) otTracedProvider :: MonadUnliftIO m => PluginId -> ByteString -> m a -> m a #else otTracedProvider :: MonadUnliftIO m => PluginId -> String -> m a -> m a diff --git a/ghcide/src/Development/IDE/GHC/CPP.hs b/ghcide/src/Development/IDE/GHC/CPP.hs index 1470fae0c7..e12c4c6481 100644 --- a/ghcide/src/Development/IDE/GHC/CPP.hs +++ b/ghcide/src/Development/IDE/GHC/CPP.hs @@ -12,7 +12,6 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE NondecreasingIndentation #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -#include "ghc-api-version.h" ----------------------------------------------------------------------------- -- @@ -31,12 +30,12 @@ import Module import Packages import Panic import SysTools -#if MIN_GHC_API_VERSION(8,8,2) +#if MIN_VERSION_ghc(8,8,2) import LlvmCodeGen (llvmVersionList) -#elif MIN_GHC_API_VERSION(8,8,0) +#elif MIN_VERSION_ghc(8,8,0) import LlvmCodeGen (LlvmVersion (..)) #endif -#if MIN_GHC_API_VERSION (8,10,0) +#if MIN_VERSION_ghc (8,10,0) import Fingerprint import ToolSettings #endif @@ -66,7 +65,7 @@ doCpp dflags raw input_fn output_fn = do let verbFlags = getVerbFlags dflags let cpp_prog args | raw = SysTools.runCpp dflags args -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) | otherwise = SysTools.runCc Nothing #else | otherwise = SysTools.runCc @@ -150,11 +149,11 @@ getBackendDefs :: DynFlags -> IO [String] getBackendDefs dflags | hscTarget dflags == HscLlvm = do llvmVer <- figureLlvmVersion dflags return $ case llvmVer of -#if MIN_GHC_API_VERSION(8,8,2) +#if MIN_VERSION_ghc(8,8,2) Just v | [m] <- llvmVersionList v -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m, 0) ] | m:n:_ <- llvmVersionList v -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m, n) ] -#elif MIN_GHC_API_VERSION(8,8,0) +#elif MIN_VERSION_ghc(8,8,0) Just (LlvmVersion n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (n,0) ] Just (LlvmVersionOld m n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m,n) ] #else @@ -170,7 +169,7 @@ getBackendDefs _ = return [] addOptP :: String -> DynFlags -> DynFlags -#if MIN_GHC_API_VERSION (8,10,0) +#if MIN_VERSION_ghc (8,10,0) addOptP f = alterToolSettings $ \s -> s { toolSettings_opt_P = f : toolSettings_opt_P s , toolSettings_opt_P_fingerprint = fingerprintStrings (f : toolSettings_opt_P s) diff --git a/ghcide/src/Development/IDE/GHC/Compat.hs b/ghcide/src/Development/IDE/GHC/Compat.hs index f7571a1593..90d579cdf3 100644 --- a/ghcide/src/Development/IDE/GHC/Compat.hs +++ b/ghcide/src/Development/IDE/GHC/Compat.hs @@ -6,7 +6,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} {-# OPTIONS -Wno-dodgy-imports -Wno-incomplete-uni-patterns #-} -#include "ghc-api-version.h" -- | Attempt at hiding the GHC version differences we can. module Development.IDE.GHC.Compat( @@ -23,7 +22,7 @@ module Development.IDE.GHC.Compat( supportsHieFiles, setHieDir, dontWriteHieFiles, -#if !MIN_GHC_API_VERSION(8,8,0) +#if !MIN_VERSION_ghc(8,8,0) ml_hie_file, addBootSuffixLocnOut, #endif @@ -44,7 +43,7 @@ module Development.IDE.GHC.Compat( tcg_exports, pattern FunTy, -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) module GHC.Hs.Extension, module LinkerTypes, #else @@ -62,7 +61,7 @@ module Development.IDE.GHC.Compat( dropForAll ,isQualifiedImport) where -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) import LinkerTypes #endif @@ -83,7 +82,7 @@ import Compat.HieBin import Compat.HieTypes import Compat.HieUtils -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) import GHC.Hs.Extension #else import HsExtension @@ -98,7 +97,7 @@ import GHC hiding ( getLoc ) import Avail -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) import Data.List (foldl') #else import Data.List (foldl', isSuffixOf) @@ -108,11 +107,11 @@ import DynamicLoading import Plugins (Plugin(parsedResultAction), withPlugins) import Data.Map.Strict (Map) -#if !MIN_GHC_API_VERSION(8,8,0) +#if !MIN_VERSION_ghc(8,8,0) import System.FilePath ((-<.>)) #endif -#if !MIN_GHC_API_VERSION(8,8,0) +#if !MIN_VERSION_ghc(8,8,0) import qualified EnumSet import System.IO @@ -126,7 +125,7 @@ hPutStringBuffer hdl (StringBuffer buf len cur) #endif -#if !MIN_GHC_API_VERSION(8,10,0) +#if !MIN_VERSION_ghc(8,10,0) noExtField :: NoExt noExtField = noExt #endif @@ -137,7 +136,7 @@ supportsHieFiles = True hieExportNames :: HieFile -> [(SrcSpan, Name)] hieExportNames = nameListFromAvails . hie_exports -#if !MIN_GHC_API_VERSION(8,8,0) +#if !MIN_VERSION_ghc(8,8,0) ml_hie_file :: GHC.ModLocation -> FilePath ml_hie_file ml | "boot" `isSuffixOf ` ml_hi_file ml = ml_hi_file ml -<.> ".hie-boot" @@ -145,7 +144,7 @@ ml_hie_file ml #endif upNameCache :: IORef NameCache -> (NameCache -> (NameCache, c)) -> IO c -#if !MIN_GHC_API_VERSION(8,8,0) +#if !MIN_VERSION_ghc(8,8,0) upNameCache ref upd_fn = atomicModifyIORef' ref upd_fn #else @@ -179,7 +178,7 @@ addIncludePathsQuote path x = x{includePaths = f $ includePaths x} pattern ModLocation :: Maybe FilePath -> FilePath -> FilePath -> GHC.ModLocation pattern ModLocation a b c <- -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) GHC.ModLocation a b c _ where ModLocation a b c = GHC.ModLocation a b c "" #else GHC.ModLocation a b c where ModLocation a b c = GHC.ModLocation a b c @@ -187,7 +186,7 @@ pattern ModLocation a b c <- setHieDir :: FilePath -> DynFlags -> DynFlags setHieDir _f d = -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) d { hieDir = Just _f} #else d @@ -195,7 +194,7 @@ setHieDir _f d = dontWriteHieFiles :: DynFlags -> DynFlags dontWriteHieFiles d = -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) gopt_unset d Opt_WriteHie #else d @@ -204,7 +203,7 @@ dontWriteHieFiles d = setUpTypedHoles ::DynFlags -> DynFlags setUpTypedHoles df = flip gopt_unset Opt_AbstractRefHoleFits -- too spammy -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) $ flip gopt_unset Opt_ShowDocsOfHoleFits -- not used #endif $ flip gopt_unset Opt_ShowMatchesOfHoleFits -- nice but broken (forgets module qualifiers) @@ -226,7 +225,7 @@ nameListFromAvails :: [AvailInfo] -> [(SrcSpan, Name)] nameListFromAvails as = map (\n -> (nameSrcSpan n, n)) (concatMap availNames as) -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) type HasSrcSpan = GHC.HasSrcSpan getLoc :: HasSrcSpan a => a -> SrcSpan @@ -251,7 +250,7 @@ addBootSuffixLocnOut locn #endif getModuleHash :: ModIface -> Fingerprint -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) getModuleHash = mi_mod_hash . mi_final_exts #else getModuleHash = mi_mod_hash @@ -264,7 +263,7 @@ disableWarningsAsErrors :: DynFlags -> DynFlags disableWarningsAsErrors df = flip gopt_unset Opt_WarnIsError $ foldl' wopt_unset_fatal df [toEnum 0 ..] -#if !MIN_GHC_API_VERSION(8,8,0) +#if !MIN_VERSION_ghc(8,8,0) wopt_unset_fatal :: DynFlags -> WarningFlag -> DynFlags wopt_unset_fatal dfs f = dfs { fatalWarningFlags = EnumSet.delete f (fatalWarningFlags dfs) } @@ -288,21 +287,21 @@ pattern ExposePackage s a mr = DynFlags.ExposePackage s a mr -- | Take AST representation of type signature and drop `forall` part from it (if any), returning just type's body dropForAll :: LHsType pass -> LHsType pass -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) dropForAll = snd . GHC.splitLHsForAllTyInvis #else dropForAll = snd . GHC.splitLHsForAllTy #endif pattern FunTy :: Type -> Type -> Type -#if MIN_GHC_API_VERSION(8, 10, 0) +#if MIN_VERSION_ghc(8, 10, 0) pattern FunTy arg res <- TyCoRep.FunTy {ft_arg = arg, ft_res = res} #else pattern FunTy arg res <- TyCoRep.FunTy arg res #endif isQualifiedImport :: ImportDecl a -> Bool -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) isQualifiedImport ImportDecl{ideclQualified = NotQualified} = False isQualifiedImport ImportDecl{} = True #else diff --git a/ghcide/src/Development/IDE/GHC/Orphans.hs b/ghcide/src/Development/IDE/GHC/Orphans.hs index 089ba17af4..493a391d19 100644 --- a/ghcide/src/Development/IDE/GHC/Orphans.hs +++ b/ghcide/src/Development/IDE/GHC/Orphans.hs @@ -4,7 +4,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} -#include "ghc-api-version.h" -- | Orphan instances for GHC. -- Note that the 'NFData' instances may not be law abiding. @@ -64,7 +63,7 @@ instance Show ParsedModule where instance NFData ModSummary where rnf = rwhnf -#if !MIN_GHC_API_VERSION(8,10,0) +#if !MIN_VERSION_ghc(8,10,0) instance NFData FastString where rnf = rwhnf #endif diff --git a/ghcide/src/Development/IDE/Import/FindImports.hs b/ghcide/src/Development/IDE/Import/FindImports.hs index 1f6e8ec0fc..bfcdf3f510 100644 --- a/ghcide/src/Development/IDE/Import/FindImports.hs +++ b/ghcide/src/Development/IDE/Import/FindImports.hs @@ -2,7 +2,6 @@ -- SPDX-License-Identifier: Apache-2.0 {-# LANGUAGE CPP #-} -#include "ghc-api-version.h" module Development.IDE.Import.FindImports ( locateModule diff --git a/ghcide/src/Development/IDE/LSP/Outline.hs b/ghcide/src/Development/IDE/LSP/Outline.hs index 046c0c9339..606f1b50b7 100644 --- a/ghcide/src/Development/IDE/LSP/Outline.hs +++ b/ghcide/src/Development/IDE/LSP/Outline.hs @@ -3,7 +3,6 @@ {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} -#include "ghc-api-version.h" module Development.IDE.LSP.Outline ( moduleOutline @@ -194,7 +193,7 @@ documentSymbolForImport (L (RealSrcSpan l) ImportDecl { ideclName, ideclQualifie (defDocumentSymbol l :: DocumentSymbol) { _name = "import " <> pprText ideclName , _kind = SkModule -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) , _detail = case ideclQualified of { NotQualified -> Nothing; _ -> Just "qualified" } #else , _detail = if ideclQualified then Just "qualified" else Nothing diff --git a/ghcide/src/Development/IDE/Plugin/CodeAction.hs b/ghcide/src/Development/IDE/Plugin/CodeAction.hs index 7059dbb7b6..d762accc37 100644 --- a/ghcide/src/Development/IDE/Plugin/CodeAction.hs +++ b/ghcide/src/Development/IDE/Plugin/CodeAction.hs @@ -3,7 +3,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DuplicateRecordFields #-} -#include "ghc-api-version.h" -- | Go to the definition of a variable. diff --git a/ghcide/src/Development/IDE/Plugin/Completions.hs b/ghcide/src/Development/IDE/Plugin/Completions.hs index ad67a5f2f4..80f3f04ceb 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions.hs @@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} -#include "ghc-api-version.h" module Development.IDE.Plugin.Completions ( descriptor diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs index e7e02a48de..4526dbb999 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs @@ -2,7 +2,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiWayIf #-} -#include "ghc-api-version.h" -- Mostly taken from "haskell-ide-engine" module Development.IDE.Plugin.Completions.Logic ( @@ -29,7 +28,7 @@ import HscTypes import Name import RdrName import Type -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) import Coercion import Pair import Predicate (isDictTy) @@ -269,7 +268,7 @@ mkNameCompItem doc thingParent origName origMod thingType isInfix docs !imp = CI then getArgs ret else Prelude.filter (not . isDictTy) args | isPiTy t = getArgs $ snd (splitPiTys t) -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) | Just (Pair _ t) <- coercionKind <$> isCoercionTy_maybe t = getArgs t #else diff --git a/ghcide/src/Development/IDE/Spans/AtPoint.hs b/ghcide/src/Development/IDE/Spans/AtPoint.hs index 0d33e88dff..4f000e1df6 100644 --- a/ghcide/src/Development/IDE/Spans/AtPoint.hs +++ b/ghcide/src/Development/IDE/Spans/AtPoint.hs @@ -3,7 +3,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} -#include "ghc-api-version.h" -- | Gives information about symbols at a given point in DAML files. -- These are all pure functions that should execute quickly. @@ -255,7 +254,7 @@ typeLocationsAtPoint hiedb lookupModule _ideOptions pos (HAR _ ast _ _ hieKind) where ni = nodeInfo x getTypes ts = flip concatMap (unfold ts) $ \case HTyVarTy n -> [n] -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) HAppTy a (HieArgs xs) -> getTypes (a : map snd xs) #else HAppTy a b -> getTypes [a,b] diff --git a/ghcide/src/Development/IDE/Spans/Common.hs b/ghcide/src/Development/IDE/Spans/Common.hs index a23d616c5a..1436c3cd2a 100644 --- a/ghcide/src/Development/IDE/Spans/Common.hs +++ b/ghcide/src/Development/IDE/Spans/Common.hs @@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DerivingStrategies #-} -#include "ghc-api-version.h" module Development.IDE.Spans.Common ( showGhc diff --git a/ghcide/src/Development/IDE/Spans/Documentation.hs b/ghcide/src/Development/IDE/Spans/Documentation.hs index bf7acd6116..6681379410 100644 --- a/ghcide/src/Development/IDE/Spans/Documentation.hs +++ b/ghcide/src/Development/IDE/Spans/Documentation.hs @@ -3,7 +3,6 @@ -- SPDX-License-Identifier: Apache-2.0 {-# LANGUAGE CPP #-} -#include "ghc-api-version.h" module Development.IDE.Spans.Documentation ( getDocumentation diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index e1640ae740..c61a93de62 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -11,7 +11,6 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-deprecations -Wno-unticked-promoted-constructors #-} -#include "ghc-api-version.h" module Main (main) where @@ -3569,7 +3568,7 @@ findDefinitionAndHoverTests = let , test yes yes lclL33 lcb "listcomp lookup" , test yes yes mclL36 mcl "top-level fn 1st clause" , test yes yes mclL37 mcl "top-level fn 2nd clause #1030" -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) , test yes yes spaceL37 space "top-level fn on space #1002" #else , test yes broken spaceL37 space "top-level fn on space #1002" @@ -4313,7 +4312,7 @@ highlightTests = testGroup "highlight" highlights <- getHighlights doc (Position 4 15) liftIO $ highlights @?= List -- Span is just the .. on 8.10, but Rec{..} before -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) [ DocumentHighlight (R 4 8 4 10) (Just HkWrite) #else [ DocumentHighlight (R 4 4 4 11) (Just HkWrite) @@ -4324,7 +4323,7 @@ highlightTests = testGroup "highlight" liftIO $ highlights @?= List [ DocumentHighlight (R 3 17 3 23) (Just HkWrite) -- Span is just the .. on 8.10, but Rec{..} before -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) , DocumentHighlight (R 4 8 4 10) (Just HkRead) #else , DocumentHighlight (R 4 4 4 11) (Just HkRead) @@ -4537,7 +4536,7 @@ ignoreInWindowsBecause :: String -> TestTree -> TestTree ignoreInWindowsBecause = if isWindows then ignoreTestBecause else (\_ x -> x) ignoreInWindowsForGHC88And810 :: TestTree -> TestTree -#if MIN_GHC_API_VERSION(8,8,1) && !MIN_GHC_API_VERSION(9,0,0) +#if MIN_VERSION_ghc(8,8,1) && !MIN_VERSION_ghc(9,0,0) ignoreInWindowsForGHC88And810 = ignoreInWindowsBecause "tests are unreliable in windows for ghc 8.8 and 8.10" #else @@ -4545,7 +4544,7 @@ ignoreInWindowsForGHC88And810 = id #endif ignoreInWindowsForGHC88 :: TestTree -> TestTree -#if MIN_GHC_API_VERSION(8,8,1) && !MIN_GHC_API_VERSION(8,10,1) +#if MIN_VERSION_ghc(8,8,1) && !MIN_VERSION_ghc(8,10,1) ignoreInWindowsForGHC88 = ignoreInWindowsBecause "tests are unreliable in windows for ghc 8.8" #else diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index bbe15bd12a..c920fe1f47 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -18,7 +18,6 @@ tested-with: GHC == 8.6.4 || == 8.6.5 || == 8.8.2 || == 8.8.3 || == 8.8.4 extra-source-files: README.md ChangeLog.md - include/ghc-api-version.h test/testdata/**/*.project test/testdata/**/*.cabal test/testdata/**/*.yaml diff --git a/include/ghc-api-version.h b/include/ghc-api-version.h deleted file mode 100644 index 11cabb3dc9..0000000000 --- a/include/ghc-api-version.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef GHC_API_VERSION_H -#define GHC_API_VERSION_H - -#ifdef GHC_LIB -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib(x,y,z) -#else -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc(x,y,z) -#endif - -#endif diff --git a/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal b/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal index 0d12befcbd..1982308368 100644 --- a/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal +++ b/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal @@ -9,7 +9,6 @@ maintainer: pepeiborra@gmail.com category: Development build-type: Simple extra-source-files: - include/ghc-api-version.h LICENSE library diff --git a/plugins/hls-explicit-imports-plugin/include/ghc-api-version.h b/plugins/hls-explicit-imports-plugin/include/ghc-api-version.h index 11cabb3dc9..ffe3029190 100644 --- a/plugins/hls-explicit-imports-plugin/include/ghc-api-version.h +++ b/plugins/hls-explicit-imports-plugin/include/ghc-api-version.h @@ -2,9 +2,9 @@ #define GHC_API_VERSION_H #ifdef GHC_LIB -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib(x,y,z) +#define MIN_VERSION_ghc(x,y,z) MIN_VERSION_ghc_lib(x,y,z) #else -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc(x,y,z) +#define MIN_VERSION_ghc(x,y,z) MIN_VERSION_ghc(x,y,z) #endif #endif diff --git a/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs b/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs index c9d067eb3f..4714fe49ee 100644 --- a/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs +++ b/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs @@ -9,7 +9,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -#include "ghc-api-version.h" module Ide.Plugin.ExplicitImports ( descriptor diff --git a/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal b/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal index f52a1731a3..ef5305f2c2 100644 --- a/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal +++ b/plugins/hls-retrie-plugin/hls-retrie-plugin.cabal @@ -9,7 +9,6 @@ maintainer: pepeiborra@gmail.com category: Development build-type: Simple extra-source-files: - include/ghc-api-version.h LICENSE library diff --git a/plugins/hls-retrie-plugin/include/ghc-api-version.h b/plugins/hls-retrie-plugin/include/ghc-api-version.h index 11cabb3dc9..ffe3029190 100644 --- a/plugins/hls-retrie-plugin/include/ghc-api-version.h +++ b/plugins/hls-retrie-plugin/include/ghc-api-version.h @@ -2,9 +2,9 @@ #define GHC_API_VERSION_H #ifdef GHC_LIB -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib(x,y,z) +#define MIN_VERSION_ghc(x,y,z) MIN_VERSION_ghc_lib(x,y,z) #else -#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc(x,y,z) +#define MIN_VERSION_ghc(x,y,z) MIN_VERSION_ghc(x,y,z) #endif #endif diff --git a/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs b/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs index a39fd7ca54..0414c7deb8 100644 --- a/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs +++ b/plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs @@ -12,7 +12,6 @@ {-# LANGUAGE TypeFamilies #-} {-# OPTIONS -Wno-orphans #-} -#include "ghc-api-version.h" module Ide.Plugin.Retrie (descriptor) where @@ -293,7 +292,7 @@ suggestRuleRewrites originatingFile pos ms_mod (L _ HsRules {rds_rules}) = ] | L l r <- rds_rules, pos `isInsideSrcSpan` l, -#if MIN_GHC_API_VERSION(8,8,0) +#if MIN_VERSION_ghc(8,8,0) let HsRule {rd_name = L _ (_, rn)} = r, #else let HsRule _ (L _ (_,rn)) _ _ _ _ = r, @@ -547,7 +546,7 @@ toImportDecl AddImport {..} = GHC.ImportDecl {..} ideclSourceSrc = NoSourceText ideclExt = GHC.noExtField ideclAs = toMod <$> ideclAsString -#if MIN_GHC_API_VERSION(8,10,0) +#if MIN_VERSION_ghc(8,10,0) ideclQualified = if ideclQualifiedBool then GHC.QualifiedPre else GHC.NotQualified #else ideclQualified = ideclQualifiedBool