Skip to content

Remove hie-compat #4613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2025
Merged
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
1 change: 0 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
/hls-graph @wz1000
/hls-plugin-api @michaelpj @fendor
/hls-test-utils @fendor
/hie-compat @wz1000

# HLS main
/src @fendor
1 change: 0 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
- [ ] bump package versions in all `*.cabal` files (same version as hls)
- HLS uses lockstep versioning. The core packages and all plugins use the same version number, and only support exactly this version.
- Exceptions:
- `hie-compat` requires no automatic version bump.
- `shake-bench` is an internal testing tool, not exposed to the outside world. Thus, no version bump required for releases.
- For updating cabal files, the following script can be used:
- ```sh
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
packages:
./
./hie-compat
./shake-bench
./hls-graph
./ghcide
1 change: 0 additions & 1 deletion docs/contributing/contributing.md
Original file line number Diff line number Diff line change
@@ -197,7 +197,6 @@ pre-commit install
#### Why are some components excluded from automatic formatting?

- `test/testdata` and `test/data` are excluded because we want to test formatting plugins.
- `hie-compat` is excluded because we want to keep its code as close to GHC as possible.

## Plugin tutorial

1 change: 0 additions & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
@@ -74,7 +74,6 @@ library
, haddock-library >=1.8 && <1.12
, hashable
, hie-bios ^>=0.16.0
, hie-compat ^>=0.3.0.0
, hiedb ^>= 0.7.0.0
, hls-graph == 2.11.0.0
, hls-plugin-api == 2.11.0.0
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/Core/Actions.hs
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import Development.IDE.Graph
import qualified Development.IDE.Spans.AtPoint as AtPoint
import Development.IDE.Types.HscEnvEq (hscEnv)
import Development.IDE.Types.Location
import GHC.Iface.Ext.Types (Identifier)
import qualified HieDb
import Language.LSP.Protocol.Types (DocumentHighlight (..),
SymbolInformation (..),
2 changes: 2 additions & 0 deletions ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@
import Data.Time (UTCTime (..))
import Data.Tuple.Extra (dupe)
import Debug.Trace
import Development.IDE.Core.FileStore (resetInterfaceStore)

Check warning on line 73 in ghcide/src/Development/IDE/Core/Compile.hs

GitHub Actions / Hlint check run

Warning in module Development.IDE.Core.Compile: Use fewer imports ▫︎ Found: "import Development.IDE.Core.FileStore ( resetInterfaceStore )\nimport Development.IDE.Core.FileStore ( shareFilePath )\n" ▫︎ Perhaps: "import Development.IDE.Core.FileStore\n ( resetInterfaceStore, shareFilePath )\n"
import Development.IDE.Core.Preprocessor
import Development.IDE.Core.ProgressReporting (progressUpdate)
import Development.IDE.Core.RuleTypes
@@ -109,6 +109,7 @@
import qualified GHC as G
import GHC.Core.Lint.Interactive
import GHC.Driver.Config.CoreToStg.Prep
import GHC.Iface.Ext.Types (HieASTs)
import qualified GHC.Runtime.Loader as Loader
import GHC.Tc.Gen.Splice
import GHC.Types.Error
@@ -145,6 +146,7 @@
import qualified Data.List.NonEmpty as NE
import Data.Time (getCurrentTime)
import GHC.Driver.Env (hsc_all_home_unit_ids)
import GHC.Iface.Ext.Types (NameEntityInfo)
#endif

#if MIN_VERSION_ghc(9,12,0)
@@ -823,7 +825,7 @@
tcs = tcg_tcs ts :: [TyCon]
hie_asts = GHC.enrichHie all_binds (tmrRenamed tcm) top_ev_binds insts tcs

pure $ Just $

Check warning on line 828 in ghcide/src/Development/IDE/Core/Compile.hs

GitHub Actions / Hlint check run

Suggestion in generateHieAsts in module Development.IDE.Core.Compile: Redundant $ ▫︎ Found: "Just $ hie_asts" ▫︎ Perhaps: "Just hie_asts"
#if MIN_VERSION_ghc(9,11,0)
hie_asts (tcg_type_env ts)
#else
@@ -1103,7 +1105,7 @@


convImport (L _ i) = (
(ideclPkgQual i)

Check warning on line 1108 in ghcide/src/Development/IDE/Core/Compile.hs

GitHub Actions / Hlint check run

Suggestion in getModSummaryFromImports in module Development.IDE.Core.Compile: Redundant bracket ▫︎ Found: "((ideclPkgQual i), reLoc $ ideclName i)" ▫︎ Perhaps: "(ideclPkgQual i, reLoc $ ideclName i)"
, reLoc $ ideclName i)

msrImports = implicit_imports ++ imps
3 changes: 3 additions & 0 deletions ghcide/src/Development/IDE/Core/RuleTypes.hs
Original file line number Diff line number Diff line change
@@ -34,6 +34,9 @@ import Development.IDE.Import.DependencyInformation
import Development.IDE.Types.HscEnvEq (HscEnvEq)
import Development.IDE.Types.KnownTargets
import GHC.Generics (Generic)
import GHC.Iface.Ext.Types (HieASTs,
TypeIndex)
import GHC.Iface.Ext.Utils (RefMap)

import Data.ByteString (ByteString)
import Data.Text.Utf16.Rope.Mixed (Rope)
8 changes: 5 additions & 3 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
@@ -138,6 +138,8 @@
import Development.IDE.Types.Location
import Development.IDE.Types.Options
import qualified Development.IDE.Types.Shake as Shake
import GHC.Iface.Ext.Types (HieASTs (..))
import GHC.Iface.Ext.Utils (generateReferencesMap)
import qualified GHC.LanguageExtensions as LangExt
import HIE.Bios.Ghc.Gap (hostIsDynamic)
import qualified HieDb
@@ -510,7 +512,7 @@
(currentSource, ver) <- liftIO $ case M.lookup (filePathToUri' file) vfsData of
Nothing -> (,Nothing) . T.decodeUtf8 <$> BS.readFile (fromNormalizedFilePath file)
Just vf -> pure (virtualFileText vf, Just $ virtualFileVersion vf)
let refmap = Compat.generateReferencesMap . Compat.getAsts . Compat.hie_asts $ res
let refmap = generateReferencesMap . getAsts . Compat.hie_asts $ res
del = deltaFromDiff (T.decodeUtf8 $ Compat.hie_hs_src res) currentSource
pure (HAR (Compat.hie_module res) (Compat.hie_asts res) refmap mempty (HieFromDisk res),del,ver)

@@ -538,8 +540,8 @@
liftIO $ writeAndIndexHieFile hsc se modSummary f exports asts source
_ -> pure []

let refmap = Compat.generateReferencesMap . Compat.getAsts <$> masts
typemap = AtPoint.computeTypeReferences . Compat.getAsts <$> masts
let refmap = generateReferencesMap . getAsts <$> masts
typemap = AtPoint.computeTypeReferences . getAsts <$> masts
pure (diags <> diagsWrite, HAR (ms_mod $ tmrModSummary tmr) <$> masts <*> refmap <*> typemap <*> pure HieFresh)

getImportMapRule :: Recorder (WithPriority Log) -> Rules ()
@@ -800,7 +802,7 @@
{ source_version = ver
, old_value = m_old
, get_file_version = use GetModificationTime_{missingFileDiagnostics = False}
, get_linkable_hashes = \fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs

Check warning on line 805 in ghcide/src/Development/IDE/Core/Rules.hs

GitHub Actions / Hlint check run

Suggestion in getModIfaceFromDiskRule in module Development.IDE.Core.Rules: Use fmap ▫︎ Found: "\\ fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs" ▫︎ Perhaps: "fmap (map (snd . fromJust . hirCoreFp)) . uses_ GetModIface"
, get_module_graph = useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph f
, regenerate = regenerateHiFile session f ms
}
16 changes: 7 additions & 9 deletions ghcide/src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
@@ -45,8 +45,6 @@ module Development.IDE.GHC.Compat(
readHieFile,
setHieDir,
dontWriteHieFiles,
module Compat.HieTypes,
module Compat.HieUtils,
-- * Compat modules
module Development.IDE.GHC.Compat.Core,
module Development.IDE.GHC.Compat.Env,
@@ -112,14 +110,8 @@ module Development.IDE.GHC.Compat(
#if MIN_VERSION_ghc(9,7,0)
tcInitTidyEnv,
#endif
) where

import Compat.HieAst (enrichHie)
import Compat.HieBin
import Compat.HieTypes hiding
(nodeAnnotations)
import qualified Compat.HieTypes as GHC (nodeAnnotations)
import Compat.HieUtils
) where
import Control.Applicative ((<|>))
import qualified Data.ByteString as BS
import Data.Coerce (coerce)
@@ -146,12 +138,18 @@ import GHC.Core.Tidy (tidyExpr)
import GHC.CoreToStg.Prep (corePrepPgm)
import qualified GHC.CoreToStg.Prep as GHC
import GHC.Driver.Hooks (hscCompileCoreExprHook)
import GHC.Iface.Ext.Types hiding
(nodeAnnotations)
import qualified GHC.Iface.Ext.Types as GHC (nodeAnnotations)
import GHC.Iface.Ext.Utils

import GHC.ByteCode.Asm (bcoFreeNames)
import GHC.Core
import GHC.Data.FastString
import GHC.Data.StringBuffer
import GHC.Driver.Session hiding (ExposePackage)
import GHC.Iface.Ext.Ast (enrichHie)
import GHC.Iface.Ext.Binary
import GHC.Iface.Make (mkIfaceExports)
import GHC.SysTools.Tasks (runPp, runUnlit)
import GHC.Types.Annotations (AnnTarget (ModuleTarget),
1 change: 0 additions & 1 deletion ghcide/src/Development/IDE/GHC/CoreFile.hs
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import Data.Foldable
import Data.IORef
import Data.List (isPrefixOf)
import Data.Maybe
import qualified Data.Text as T
import Development.IDE.GHC.Compat
import qualified Development.IDE.GHC.Compat.Util as Util
import GHC.Core
7 changes: 2 additions & 5 deletions ghcide/src/Development/IDE/GHC/Orphans.hs
Original file line number Diff line number Diff line change
@@ -7,9 +7,7 @@
-- | Orphan instances for GHC.
-- Note that the 'NFData' instances may not be law abiding.
module Development.IDE.GHC.Orphans() where
import Development.IDE.GHC.Compat hiding
(DuplicateRecordFields,
FieldSelectors)
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Util

import Control.DeepSeq
@@ -24,9 +22,8 @@ import GHC.ByteCode.Types
import GHC.Data.Bag
import GHC.Data.FastString
import qualified GHC.Data.StringBuffer as SB
import GHC.Iface.Ext.Types
import GHC.Parser.Annotation
import GHC.Types.FieldLabel (DuplicateRecordFields (DuplicateRecordFields, NoDuplicateRecordFields),
FieldSelectors (FieldSelectors, NoFieldSelectors))
import GHC.Types.PkgQual
import GHC.Types.SrcLoc

3 changes: 3 additions & 0 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
@@ -49,6 +49,9 @@ import Development.IDE.Plugin.Completions.Types
import Development.IDE.Spans.LocalBindings
import Development.IDE.Types.Exports
import Development.IDE.Types.Options
import GHC.Iface.Ext.Types (HieAST,
NodeInfo (..))
import GHC.Iface.Ext.Utils (nodeInfo)
import Ide.PluginUtils (mkLspCommand)
import Ide.Types (CommandId (..),
IdePlugins (..),
19 changes: 18 additions & 1 deletion ghcide/src/Development/IDE/Spans/AtPoint.hs
Original file line number Diff line number Diff line change
@@ -67,6 +67,23 @@ import Data.Tree
import qualified Data.Tree as T
import Data.Version (showVersion)
import Development.IDE.Types.Shake (WithHieDb)
import GHC.Iface.Ext.Types (EvVarSource (..),
HieAST (..),
HieASTs (..),
HieArgs (..),
HieType (..), Identifier,
IdentifierDetails (..),
NodeInfo (..), Scope,
Span)
import GHC.Iface.Ext.Utils (EvidenceInfo (..),
RefMap, getEvidenceTree,
getScopeFromContext,
hieTypeToIface,
isEvidenceContext,
isEvidenceUse,
isOccurrence, nodeInfo,
recoverFullType,
selectSmallestContaining)
import HieDb hiding (pointCommand,
withHieDb)
import System.Directory (doesFileExist)
@@ -488,7 +505,7 @@ instanceLocationsAtPoint
instanceLocationsAtPoint withHieDb lookupModule _ideOptions pos (HAR _ ast _rm _ _) =
let ns = concat $ pointCommand ast pos (M.keys . getNodeIds)
evTrees = mapMaybe (eitherToMaybe >=> getEvidenceTree _rm) ns
evNs = concatMap (map (evidenceVar) . T.flatten) evTrees
evNs = concatMap (map evidenceVar . T.flatten) evTrees
in fmap (nubOrd . concat) $ mapMaybeM
(nameToLocation withHieDb lookupModule)
evNs
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/Spans/Documentation.hs
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import Development.IDE.GHC.Compat.Util
import Development.IDE.GHC.Error
import Development.IDE.GHC.Util (printOutputable)
import Development.IDE.Spans.Common
import GHC.Iface.Ext.Utils (RefMap)
import Language.LSP.Protocol.Types (filePathToUri, getUri)
import Prelude hiding (mod)
import System.Directory
11 changes: 6 additions & 5 deletions ghcide/src/Development/IDE/Spans/LocalBindings.hs
Original file line number Diff line number Diff line change
@@ -17,15 +17,16 @@ import qualified Data.IntervalMap.FingerTree as IM
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Set as S
import GHC.Iface.Ext.Types (IdentifierDetails (..),
Scope (..))
import GHC.Iface.Ext.Utils (RefMap, getBindSiteFromContext,
getScopeFromContext)

import Development.IDE.GHC.Compat (Name, NameEnv, RealSrcSpan,
RefMap, Scope (..), Type,
getBindSiteFromContext,
getScopeFromContext, identInfo,
identType, isSystemName,
Type, isSystemName,
nonDetNameEnvElts,
realSrcSpanEnd,
realSrcSpanStart, unitNameEnv)

import Development.IDE.GHC.Error
import Development.IDE.Types.Location

8 changes: 6 additions & 2 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
@@ -406,6 +406,7 @@ library hls-call-hierarchy-plugin
, aeson
, containers
, extra
, ghc
, ghcide == 2.11.0.0
, hiedb ^>= 0.7.0.0
, hls-plugin-api == 2.11.0.0
@@ -592,10 +593,10 @@ library hls-rename-plugin
hs-source-dirs: plugins/hls-rename-plugin/src
build-depends:
, containers
, ghc
, ghcide == 2.11.0.0
, hashable
, hiedb ^>= 0.7.0.0
, hie-compat
, hls-plugin-api == 2.11.0.0
, haskell-language-server:hls-refactor-plugin
, lens
@@ -800,7 +801,6 @@ library hls-stan-plugin
build-depends:
, deepseq
, hashable
, hie-compat
, hls-plugin-api
, ghcide
, lsp-types
@@ -1066,6 +1066,7 @@ library hls-qualify-imported-names-plugin
hs-source-dirs: plugins/hls-qualify-imported-names-plugin/src
build-depends:
, containers
, ghc
, ghcide == 2.11.0.0
, hls-plugin-api == 2.11.0.0
, lens
@@ -1119,6 +1120,7 @@ library hls-code-range-plugin
, containers
, deepseq
, extra
, ghc
, ghcide == 2.11.0.0
, hashable
, hls-plugin-api == 2.11.0.0
@@ -1322,6 +1324,7 @@ library hls-explicit-record-fields-plugin
buildable: False
exposed-modules: Ide.Plugin.ExplicitFields
build-depends:
, ghc
, ghcide == 2.11.0.0
, hls-plugin-api == 2.11.0.0
, lsp
@@ -1730,6 +1733,7 @@ library hls-semantic-tokens-plugin
, extra
, text-rope
, mtl >= 2.2
, ghc
, ghcide == 2.11.0.0
, hls-plugin-api == 2.11.0.0
, lens
5 changes: 0 additions & 5 deletions hie-compat/CHANGELOG.md

This file was deleted.

Loading

Unchanged files with check annotations Beta

Just fileDiags -> do
pure $ Just $ filter diagRangeOverlaps fileDiags
where
diagRangeOverlaps = \fileDiag ->

Check warning on line 219 in ghcide/src/Development/IDE/Core/PluginUtils.hs

GitHub Actions / Hlint check run

Warning in activeDiagnosticsInRangeMT in module Development.IDE.Core.PluginUtils: Redundant lambda ▫︎ Found: "diagRangeOverlaps\n = \\ fileDiag\n -> rangesOverlap range (fileDiag ^. fdLspDiagnosticL . LSP.range)" ▫︎ Perhaps: "diagRangeOverlaps fileDiag\n = rangesOverlap range (fileDiag ^. fdLspDiagnosticL . LSP.range)"
rangesOverlap range (fileDiag ^. fdLspDiagnosticL . LSP.range)
-- | Just like 'activeDiagnosticsInRangeMT'. See the docs of 'activeDiagnosticsInRangeMT' for details.
{-# LANGUAGE DeriveAnyClass #-}

Check warning on line 1 in ghcide/session-loader/Development/IDE/Session/Diagnostics.hs

GitHub Actions / Hlint check run

Warning in module Development.IDE.Session.Diagnostics: Use module export list ▫︎ Found: "module Development.IDE.Session.Diagnostics where" ▫︎ Perhaps: "module Development.IDE.Session.Diagnostics (\n module Development.IDE.Session.Diagnostics\n ) where" ▫︎ Note: an explicit list is usually better
module Development.IDE.Session.Diagnostics where
import Control.Applicative
surround start s end = do
guard (listToMaybe s == Just start)
guard (listToMaybe (reverse s) == Just end)
pure $ drop 1 $ take (length s - 1) s

Check warning on line 92 in ghcide/session-loader/Development/IDE/Session/Diagnostics.hs

GitHub Actions / Hlint check run

Warning in parseMultiCradleErr in module Development.IDE.Session.Diagnostics: Use drop1 ▫︎ Found: "drop 1" ▫︎ Perhaps: "drop1"
multiCradleErrMessage :: MultiCradleErr -> [String]
multiCradleErrMessage e =
[] -> error $ "GHC version could not be parsed: " <> version
((runTime, _):_)
| compileTime == runTime -> do
atomicModifyIORef' cradle_files (\xs -> (cfp:xs,()))

Check warning on line 632 in ghcide/session-loader/Development/IDE/Session.hs

GitHub Actions / Hlint check run

Warning in loadSessionWithOptions in module Development.IDE.Session: Use atomicModifyIORef'_ ▫︎ Found: "atomicModifyIORef' cradle_files (\\ xs -> (cfp : xs, ()))" ▫︎ Perhaps: "atomicModifyIORef'_ cradle_files ((:) cfp)"
session (hieYaml, toNormalizedFilePath' cfp, opts, libDir)
| otherwise -> return (([renderPackageSetupException cfp GhcVersionMismatch{..}], Nothing),[])
-- Failure case, either a cradle error or the none cradle
x <- map errMsgDiagnostic closure_errs
DriverHomePackagesNotClosed us <- pure x
pure us
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units

Check warning on line 899 in ghcide/session-loader/Development/IDE/Session.hs

GitHub Actions / Hlint check run

Suggestion in newComponentCache in module Development.IDE.Session: Redundant bracket ▫︎ Found: "(homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units" ▫︎ Perhaps: "homeUnitId_ (componentDynFlags ci) `OS.member` bad_units"
-- Whenever we spin up a session on Linux, dynamically load libm.so.6
-- in. We need this in case the binary is statically linked, in which
-- case the interactive session will fail when trying to load
{-# LANGUAGE CPP #-}

Check warning on line 1 in exe/Wrapper.hs

GitHub Actions / Hlint check run

Warning in module Main: Use module export list ▫︎ Found: "module Main where" ▫︎ Perhaps: "module Main (\n module Main\n ) where" ▫︎ Note: an explicit list is usually better
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}