Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.6", "9.8", "9.10", "9.12"]
# GHC-9.6.7 fails in the linker phase on Linux.
# GHC-9.6.6 fails to compile ghc-lib-parser on Windows.
ghc: ["9.6.6", "9.8", "9.10", "9.12"]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ endif
# THIS FILE WILL BE REMOVED!
ENV=.ghc-tags-plugin.env

uninstall:
${GHC_PKG} unregister \
--package-db=${PACKAGE_DB} \
--force \
ghc-tags-plugin

uninstall-core:
${GHC_PKG} unregister \
--package-db=${PACKAGE_DB} \
--force \
ghc-tags-core

install:
# avoid changing the default environment
cabal install --package-db=${PACKAGE_DB} \
Expand All @@ -62,6 +50,18 @@ prof-install:
rm ${ENV}
${GHC_PKG} describe --package-db=${PACKAGE_DB} ghc-tags-plugin | grep -A1 ^id

uninstall:
${GHC_PKG} unregister \
--package-db=${PACKAGE_DB} \
--force \
ghc-tags-plugin

uninstall-core:
${GHC_PKG} unregister \
--package-db=${PACKAGE_DB} \
--force \
ghc-tags-core

# reinstall ghc-tags-core and ghc-tags-plugin
reinstall-core: uninstall uninstall-core install

Expand Down
9 changes: 5 additions & 4 deletions cabal.project.ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ documentation: True
tests: True
benchmarks: True
flags: +gtp-check
jobs: 2

package ghc-tags-core
ghc-options: -j2 -Werror
ghc-options: -Werror

package ghc-tags-plugin
ghc-options: -j2 -Werror
ghc-options: -Werror

package ghc-tags-pipes
ghc-options: -j2 -Werror
ghc-options: -Werror

package ghc-tags-test
ghc-options: -j2 -Werror
ghc-options: -Werror
4 changes: 0 additions & 4 deletions ghc-tags-core/ghc-tags-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ common warnings
ghc-options: -Wall
-Wno-unticked-promoted-constructors
-Wcompat
-- the following three warnings are enabled by -Wall in
-- ghc-9.2
-Wno-incomplete-uni-patterns
-Wno-incomplete-record-updates
-Wpartial-fields
-Widentities
-Wredundant-constraints
Expand Down
1 change: 0 additions & 1 deletion ghc-tags-core/lib/GhcTags/ETag/Parser.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
Expand Down
35 changes: 12 additions & 23 deletions ghc-tags-core/lib/GhcTags/Ghc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ module GhcTags.Ghc

import Data.Maybe (mapMaybe)
import Data.Maybe (maybeToList)
#if MIN_VERSION_base(4,18,0)
import qualified Data.List.NonEmpty as NonEmpty
#endif
#if MIN_VERSION_base(4,20,0)
import Data.Foldable (toList)
#else
import Data.Foldable (foldl', toList)
#endif
import qualified Data.Foldable as Foldable
import Data.ByteString (ByteString)

-- Ghc imports
Expand Down Expand Up @@ -351,7 +344,7 @@ hsDeclsToGhcTags :: Maybe [IE GhcPs]
-> [LHsDecl GhcPs]
-> GhcTags
hsDeclsToGhcTags mies =
reverse . foldl' go []
reverse . Foldable.foldl' go []
where
fixLoc :: SrcSpan -> GhcTag -> GhcTag
fixLoc loc gt@GhcTag { gtSrcSpan = UnhelpfulSpan {} } = gt { gtSrcSpan = loc }
Expand Down Expand Up @@ -424,14 +417,14 @@ hsDeclsToGhcTags mies =
-- class methods
: (mkClsMemberTags decLoc (unSpanAnn tcdLName) . unLoc) `concatMap` tcdSigs
-- default methods
++ foldl' (\tags' hsBind -> mkHsBindLRTags decLoc (unLoc hsBind) ++ tags')
[]
tcdMeths
++ Foldable.foldl' (\tags' hsBind -> mkHsBindLRTags decLoc (unLoc hsBind) ++ tags')
[]
tcdMeths
-- associated types
++ ((\a -> mkFamilyDeclTags decLoc a (Just $ unSpanAnn tcdLName)) . unLoc) `mapMaybe` tcdATs
-- associated type defaults (data type families, type families
-- (open or closed)
++ foldl'
++ Foldable.foldl'
(\tags' (L _ decl'@(TyFamInstDecl { tfid_eqn = tyFamDeflEqn })) ->
let decl = Just decl' in
case tyFamDeflEqn of
Expand Down Expand Up @@ -552,11 +545,7 @@ hsDeclsToGhcTags mies =
`map` con_names'
++ mkHsConDeclGADTDetails decLoc tyName con_args
where
#if MIN_VERSION_GHC(9,6)
con_names' = NonEmpty.toList con_names
#else
con_names' = con_names
#endif
con_names' = Foldable.toList con_names

mkConsTags decLoc tyName con@ConDeclH98 { con_name, con_args } =
mkGhcTagForMember decLoc (unSpanAnn con_name) tyName
Expand All @@ -566,7 +555,7 @@ hsDeclsToGhcTags mies =
mkHsLocalBindsTags :: SrcSpan -> HsLocalBinds GhcPs -> [GhcTag]
mkHsLocalBindsTags decLoc (HsValBinds _ (ValBinds _ hsBindsLR sigs)) =
-- where clause bindings
concatMap (mkHsBindLRTags decLoc . unLoc) (toList hsBindsLR)
concatMap (mkHsBindLRTags decLoc . unLoc) (Foldable.toList hsBindsLR)
++ concatMap (mkSigTags decLoc . unLoc) sigs

mkHsLocalBindsTags _ _ = []
Expand All @@ -576,10 +565,10 @@ hsDeclsToGhcTags mies =
-> HsConDeclH98Details GhcPs
-> GhcTags
mkHsConDeclH98Details decLoc tyName (RecCon (L _ fields)) =
foldl' f [] fields
Foldable.foldl' f [] fields
where
f :: GhcTags -> LConDeclField GhcPs -> GhcTags
f ts (L _ ConDeclField { cd_fld_names }) = foldl' g ts cd_fld_names
f ts (L _ ConDeclField { cd_fld_names }) = Foldable.foldl' g ts cd_fld_names

g :: GhcTags -> LFieldOcc GhcPs -> GhcTags
g ts (L _ fo@FieldOcc {}) =
Expand All @@ -597,10 +586,10 @@ hsDeclsToGhcTags mies =
#else
mkHsConDeclGADTDetails decLoc tyName (RecConGADT (L _ fields) _) =
#endif
foldl' f [] fields
Foldable.foldl' f [] fields
where
f :: GhcTags -> LConDeclField GhcPs -> GhcTags
f ts (L _ ConDeclField { cd_fld_names }) = foldl' g ts cd_fld_names
f ts (L _ ConDeclField { cd_fld_names }) = Foldable.foldl' g ts cd_fld_names

g :: GhcTags -> LFieldOcc GhcPs -> GhcTags
g ts (L _ fo) =
Expand Down
28 changes: 6 additions & 22 deletions ghc-tags-core/lib/GhcTags/Tag.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,40 +110,40 @@ import qualified Outputable as Out
#endif


#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GHC(9,6)
type RawFilePath = OsPath
#endif

rawFilePathToBS :: RawFilePath -> BS.ByteString
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GHC(9,6)
rawFilePathToBS = \a -> unsafePerformIO $ BS.Char8.pack <$> OsPath.decodeFS a
#else
rawFilePathToBS = id
#endif

rawFilePathFromBS :: BS.ByteString -> RawFilePath
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GHC(9,6)
rawFilePathFromBS = unsafePerformIO . OsPath.encodeFS . BS.Char8.unpack
#else
rawFilePathFromBS = id
#endif

normaliseRawFilePath :: RawFilePath -> RawFilePath
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GHC(9,6)
normaliseRawFilePath = OsPath.normalise
#else
normaliseRawFilePath = FilePath.BS.normalise
#endif

makeRelativeRawFilePath :: RawFilePath -> RawFilePath -> RawFilePath
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GHC(9,6)
makeRelativeRawFilePath = OsPath.makeRelative
#else
makeRelativeRawFilePath = FilePath.BS.makeRelative
#endif

(</>) :: RawFilePath -> RawFilePath -> RawFilePath
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GHC(9,6)
(</>) = (OsPath.</>)
#else
(</>) = (FilePath.BS.</>)
Expand Down Expand Up @@ -655,23 +655,7 @@ ghcTagToTag sing dynFlags GhcTag { gtSrcSpan, gtTag, gtKind, gtIsExported, gtFF
Text.intercalate " " -- remove all line breaks, tabs and multiple spaces
. Text.words
. Text.pack
#if MIN_VERSION_GHC(9,2)
. Out.renderWithContext
Out.defaultSDocContext { Out.sdocStyle = Out.mkErrStyle Out.neverQualify }
. Out.ppr
$ hsType
#elif MIN_VERSION_GHC(9,0)
$ Out.renderWithStyle
(Out.initSDocContext
dynFlags
(Out.setStyleColoured False
$ Out.mkErrStyle Out.neverQualify))
(Out.ppr hsType)

#else
$ Out.renderWithStyle
(dynFlags { pprUserLength = 1 })
(Out.ppr hsType)
(Out.setStyleColoured False
$ Out.mkErrStyle dynFlags Out.neverQualify)
#endif
7 changes: 2 additions & 5 deletions ghc-tags-core/lib/GhcTags/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ module GhcTags.Utils

-- | Platform dependent eol:
--
-- * Windows "CRNL"
-- * MacOS "CR"
-- * Linux (unit) "NL"
-- * Windows "CRNL"
-- * Linux & Darwin "NL"
--
endOfLine :: String
#if defined(mingw32_HOST_OS)
endOfLine = "\r\n"
#elif defined(darwin_HIST_OS)
endOfLine = "\r"
#else
endOfLine = "\n"
#endif
Expand Down
7 changes: 1 addition & 6 deletions ghc-tags-pipes/ghc-tags-pipes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ common warnings
ghc-options: -Wall
-Wno-unticked-promoted-constructors
-Wcompat
-- the following three warnings are enabled by -Wall in
-- ghc-9.2
-Wno-incomplete-uni-patterns
-Wno-incomplete-record-updates
-Wpartial-fields
-Widentities
-Wredundant-constraints
if impl(ghc >= 9)
ghc-options: -Wunused-packages
-Wunused-packages

library
import: warnings
Expand Down
2 changes: 1 addition & 1 deletion ghc-tags-pipes/lib/GhcTags/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module GhcTags.Stream
, runCombineTagsPipe
) where

#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
import Control.Monad.State.Strict
#else
import Control.Monad.State.Strict hiding (void)
Expand Down
4 changes: 0 additions & 4 deletions ghc-tags-plugin/ghc-tags-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ common warnings
ghc-options: -Wall
-Wno-unticked-promoted-constructors
-Wcompat
-- the following three warnings are enabled by -Wall in
-- ghc-9.2
-Wno-incomplete-uni-patterns
-Wno-incomplete-record-updates
-Wpartial-fields
-Widentities
-Wredundant-constraints
Expand Down
4 changes: 2 additions & 2 deletions ghc-tags-plugin/lib/Plugin/GhcTags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Plugin.GhcTags ( plugin, Options (..) ) where

import Control.Exception
import Control.Monad (when)
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
import Control.Monad.State.Strict
#else
import Control.Monad.State.Strict hiding (when, void)
Expand Down Expand Up @@ -92,7 +92,7 @@ import Plugin.GhcTags.FileLock
import qualified Plugin.GhcTags.CTag as CTag


#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
type GhcPsModule = HsModule GhcPs
#else
type GhcPsModule = HsModule
Expand Down
8 changes: 1 addition & 7 deletions ghc-tags-plugin/lib/Plugin/GhcTags/FileLock.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}

module Plugin.GhcTags.FileLock
( withFileLock
, LockMode (..)
Expand All @@ -8,11 +6,7 @@ module Plugin.GhcTags.FileLock
import Control.Exception
import Control.Monad (when)

#if !defined(mingw32_HOST_OS)
import Lukko.FLock
#else
import Lukko.Windows
#endif
import Lukko

-- | 'flock' base lock (on posix) or `LockFileEx` on Windows.
--
Expand Down
4 changes: 2 additions & 2 deletions ghc-tags-test/bench/Main.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS -Wno-orphans #-}
#if __GLASGOW_HASKELL__ >= 908
#if MIN_VERSION_GLASGOW_HASKELL(9,8,0,0)
{-# OPTIONS -Wno-x-partial #-}
#endif

module Main (main) where

import Control.Exception
import Control.DeepSeq
#if __GLASGOW_HASKELL__ >= 906
#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
import Control.Monad.State.Strict
#else
import Control.Monad.State.Strict hiding (void)
Expand Down
Loading