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: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ shake.yaml.lock
.vscode
/test-logs/*.log

# stack 2.1 stack.yaml lock files
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just deleting duplicated entries (they already exist few lines above this)

stack*.yaml.lock
shake.yaml.lock

# ignore hie.yaml's for testdata
test/testdata/**/hie.yaml

Expand Down
43 changes: 19 additions & 24 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,31 @@ if impl(ghc >= 9.11)

if impl(ghc >= 9.14)
allow-newer:
aeson:containers,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted alphabetically, removed some no-longer needed entries.

aeson:template-haskell,
aeson:time,
binary-instances:base,
binary-instances:tagged,
binary-orphans:base,
boring:base,
cabal-install-parsers:containers,
constraints-extras:template-haskell,
dependent-map:containers,
ghc-trace-events:base,
hie-compat:base,
indexed-traversable:base,
indexed-traversable:containers,
indexed-traversable-instances:base,
lukko:base,
quickcheck-instances:base,
quickcheck-instances:containers,
dependent-map:containers,
aeson:containers,
semialign:base,
semialign:containers,
string-interpolate:template-haskell,
tasty-hspec:base,
tagged:template-haskell,
indexed-traversable:base,
quickcheck-instances:base,
text-iso8601:time,
these:base,
time-compat:base,
time-compat:time,
these:base,
some:base,
boring:base,
indexed-traversable-instances:base,
uuid-types:template-haskell,
hie-compat:base,
ghc-trace-events:base,
constraints-extras:template-haskell,
aeson:time,
text-iso8601:time,
semialign:base,
aeson:template-haskell,
lukko:base,
binary-instances:base,
binary-orphans:base,
cabal-install-parsers:containers,
haddock-library:base,
websockets:containers,
monad-control:transformers,
mmorph:transformers-compat,
binary-instances:tagged,
2 changes: 1 addition & 1 deletion ghcide-test/exe/BootTests.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module BootTests (tests) where

import Config (checkDefs, mkR, runInDir,
import Config (checkDefs, mkR,
runWithExtraFiles)
import Control.Applicative.Combinators
import Control.Monad
Expand Down
2 changes: 0 additions & 2 deletions ghcide-test/exe/DiagnosticTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Control.Monad
import Control.Monad.IO.Class (liftIO)
import Data.List.Extra
import qualified Data.Text as T
import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion)
import Development.IDE.GHC.Util
import Development.IDE.Test (diagnostic,
expectCurrentDiagnostics,
Expand All @@ -28,7 +27,6 @@ import Language.LSP.Protocol.Types hiding
import Language.LSP.Test
import System.Directory
import System.FilePath
import System.IO.Extra hiding (withTempDir)

import Config
import Control.Lens ((^.))
Expand Down
2 changes: 1 addition & 1 deletion ghcide-test/exe/FindImplementationAndHoverTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ tests = let
]
where yes :: (TestTree -> Maybe TestTree)
yes = Just -- test should run and pass
no = const Nothing -- don't run this test at all
_no = const Nothing -- don't run this test at all

-- ----------------------------------------------------------------------------
-- Helper functions for creating hover message verification
Expand Down
1 change: 0 additions & 1 deletion ghcide-test/exe/IfaceTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import Language.LSP.Protocol.Types hiding
import Language.LSP.Test
import System.Directory
import System.FilePath
import System.IO.Extra hiding (withTempDir)
import Test.Hls.FileSystem
import Test.Tasty
import Test.Tasty.HUnit
Expand Down
1 change: 0 additions & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ library
, mtl
, opentelemetry >=0.6.1
, optparse-applicative
, os-string
, parallel
, process
, prettyprinter >=1.7
Expand Down
43 changes: 12 additions & 31 deletions ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,10 @@ withBootSuffix _ = id
getModSummaryFromImports
:: HscEnv
-> FilePath
-> UTCTime
-> Maybe Util.StringBuffer
-> ExceptT [FileDiagnostic] IO ModSummaryResult
-- modTime is only used in GHC < 9.4
getModSummaryFromImports env fp _modTime mContents = do
-- src_hash is only used in GHC >= 9.4
(contents, opts, ppEnv, _src_hash) <- preprocessor env fp mContents
getModSummaryFromImports env fp mContents = do
(contents, opts, ppEnv, src_hash) <- preprocessor env fp mContents

let dflags = hsc_dflags ppEnv

Expand All @@ -1194,8 +1191,7 @@ getModSummaryFromImports env fp _modTime mContents = do
(src_idecls, ord_idecls) = partition ((== IsBoot) . ideclSource.unLoc) imps

-- GHC.Prim doesn't exist physically, so don't go looking for it.
-- ghc_prim_imports is only used in GHC >= 9.4
(ordinary_imps, _ghc_prim_imports)
(ordinary_imps, ghc_prim_imports)
= partition ((/= moduleName gHC_PRIM) . unLoc
. ideclName . unLoc)
ord_idecls
Expand Down Expand Up @@ -1233,7 +1229,7 @@ getModSummaryFromImports env fp _modTime mContents = do
srcImports = rn_imps $ map convImport src_idecls
textualImports = rn_imps $ map convImport (implicit_imports ++ ordinary_imps)
#endif
ghc_prim_import = not (null _ghc_prim_imports)
ghc_prim_import = not (null ghc_prim_imports)


-- Force bits that might keep the string buffer and DynFlags alive unnecessarily
Expand All @@ -1253,11 +1249,11 @@ getModSummaryFromImports env fp _modTime mContents = do
ModSummary
{ ms_mod = modl
, ms_hie_date = Nothing
, ms_dyn_obj_date = Nothing
, ms_dyn_obj_date = Nothing
#if !MIN_VERSION_ghc(9,13,0)
, ms_ghc_prim_import = ghc_prim_import
#endif
, ms_hs_hash = _src_hash
, ms_hs_hash = src_hash

, ms_hsc_src = sourceType
-- The contents are used by the GetModSummary rule
Expand Down Expand Up @@ -1528,36 +1524,21 @@ loadInterface
loadInterface session ms linkableNeeded RecompilationInfo{..} = do
let sessionWithMsDynFlags = hscSetFlags (ms_hspp_opts ms) session
mb_old_iface = hirModIface . fst <$> old_value
mb_old_version = snd <$> old_value

core_file = ml_core_file (ms_location ms)
iface_file = ml_hi_file (ms_location ms)

!mod = ms_mod ms

mb_dest_version <- case mb_old_version of
Just ver -> pure $ Just ver
Nothing -> get_file_version (toNormalizedFilePath' iface_file)

-- The source is modified if it is newer than the destination (iface file)
-- A more precise check for the core file is performed later
let _sourceMod = case mb_dest_version of -- sourceMod is only used in GHC < 9.4
Nothing -> SourceModified -- destination file doesn't exist, assume modified source
Just dest_version
| source_version <= dest_version -> SourceUnmodified
| otherwise -> SourceModified

-- old_iface is only used in GHC >= 9.4
_old_iface <- case mb_old_iface of
old_iface <- case mb_old_iface of
Just iface -> pure (Just iface)
Nothing -> do
-- ncu and read_dflags are only used in GHC >= 9.4
let _ncu = hsc_NC sessionWithMsDynFlags
_read_dflags = hsc_dflags sessionWithMsDynFlags
let ncu = hsc_NC sessionWithMsDynFlags
read_dflags = hsc_dflags sessionWithMsDynFlags
#if MIN_VERSION_ghc(9,13,0)
read_result <- liftIO $ readIface (hsc_hooks sessionWithMsDynFlags) (hsc_logger sessionWithMsDynFlags) _read_dflags _ncu mod iface_file
read_result <- liftIO $ readIface (hsc_hooks sessionWithMsDynFlags) (hsc_logger sessionWithMsDynFlags) read_dflags ncu mod iface_file
#else
read_result <- liftIO $ readIface _read_dflags _ncu mod iface_file
read_result <- liftIO $ readIface read_dflags ncu mod iface_file
#endif
case read_result of
Util.Failed{} -> return Nothing
Expand All @@ -1568,7 +1549,7 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
-- If mb_old_iface is nothing then checkOldIface will load it for us
-- given that the source is unmodified
(recomp_iface_reqd, mb_checked_iface)
<- liftIO $ checkOldIface sessionWithMsDynFlags ms _old_iface >>= \case
<- liftIO $ checkOldIface sessionWithMsDynFlags ms old_iface >>= \case
UpToDateItem x -> pure (UpToDate, Just x)
OutOfDateItem reason x -> pure (NeedsRecompile reason, x)

Expand Down
1 change: 0 additions & 1 deletion ghcide/src/Development/IDE/Core/FileStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Development.IDE.Core.FileStore(
) where

import Control.Concurrent.STM.Stats (STM, atomically)
import Control.Concurrent.STM.TQueue (writeTQueue)
import Control.Exception
import Control.Lens ((^.))
import Control.Monad.Extra
Expand Down
3 changes: 1 addition & 2 deletions ghcide/src/Development/IDE/Core/RuleTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import qualified Data.Map as M
import Data.Time.Clock.POSIX
import Data.Typeable
import Development.IDE.GHC.Compat hiding
(HieFileResult,
assert)
(HieFileResult)
import Development.IDE.GHC.Compat.Util
import Development.IDE.GHC.CoreFile
import Development.IDE.GHC.Util
Expand Down
5 changes: 2 additions & 3 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import Development.IDE.Core.Compile
import Development.IDE.Core.FileExists hiding (Log,
LogShake)
import Development.IDE.Core.FileStore (getFileContents,
getFileModTimeContents,
getModTime)
import Development.IDE.Core.IdeConfiguration
import Development.IDE.Core.OfInterest hiding (Log,
Expand Down Expand Up @@ -924,10 +923,10 @@ getModSummaryRule displayTHWarning recorder = do
session' <- hscEnv <$> use_ GhcSession f
modify_dflags <- getModifyDynFlags dynFlagsModifyGlobal
let session = setNonHomeFCHook $ hscSetFlags (modify_dflags $ hsc_dflags session') session' -- TODO wz1000
(modTime, mFileContent) <- getFileModTimeContents f
mFileContent <- getFileContents f
let fp = fromNormalizedFilePath f
modS <- liftIO $ runExceptT $
getModSummaryFromImports session fp modTime (textToStringBuffer . Rope.toText <$> mFileContent)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modTime argument was used for ghc < 9.4, removing it allows for this simplification.

getModSummaryFromImports session fp (textToStringBuffer . Rope.toText <$> mFileContent)
case modS of
Right res -> do
-- Check for Template Haskell
Expand Down
1 change: 0 additions & 1 deletion ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ import Development.IDE.Core.RuleTypes
import Development.IDE.Types.Options as Options
import qualified Language.LSP.Protocol.Message as LSP
import qualified Language.LSP.Server as LSP
import qualified Language.LSP.VFS as VFS

import Development.IDE.Core.Tracing
import Development.IDE.Core.WorkerThread
Expand Down
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -506,5 +506,6 @@ recDotDot x =
unRecFieldsDotDot <$>
unLoc <$> rec_dotdot x

extract_cons :: DataDefnCons a -> [a]
extract_cons (NewTypeCon x) = [x]
extract_cons (DataTypeCons _ xs) = xs
4 changes: 0 additions & 4 deletions ghcide/src/Development/IDE/GHC/Compat/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ import qualified GHC.Utils.Panic.Plain as Plain

import Data.Foldable (toList)
import GHC.Core.Multiplicity (scaledThing)
import GHC.Data.Bag
import qualified GHC.Data.Strict as Strict
import qualified GHC.Driver.Config.Finder as GHC
import qualified GHC.Driver.Config.Tidy as GHC
Expand Down Expand Up @@ -531,9 +530,6 @@ import GHC.Unit.Module.Graph
import GHC.Unit.Module.Imported
import GHC.Unit.Module.ModDetails
import GHC.Unit.Module.ModGuts
#if !MIN_VERSION_ghc(9,9,0)
import GHC.Hs (SrcSpanAnn')
#endif
import GHC.Unit.Module.ModIface (IfaceExport, ModIface,
ModIface_ (..), mi_fix
#if MIN_VERSION_ghc(9,11,0)
Expand Down
6 changes: 2 additions & 4 deletions ghcide/src/Development/IDE/Plugin/TypeLenses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Development.IDE.Plugin.TypeLenses (

import Control.Concurrent.STM.Stats (atomically)
import Control.DeepSeq (rwhnf)
import Control.Lens (to, (?~), (^?))
import Control.Lens ((?~), (^?))
import Control.Monad (mzero)
import Control.Monad.Extra (whenMaybe)
import Control.Monad.IO.Class (MonadIO (liftIO))
Expand Down Expand Up @@ -51,8 +51,7 @@ import qualified Development.IDE.Core.Shake as Shake
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Compat.Error (_TcRnMessage,
_TcRnMissingSignature,
msgEnvelopeErrorL,
stripTcRnMessageContext)
msgEnvelopeErrorL)
import Development.IDE.GHC.Util (printName)
import Development.IDE.Graph.Classes
import Development.IDE.Types.Location (Position (Position, _line),
Expand Down Expand Up @@ -91,7 +90,6 @@ import Language.LSP.Protocol.Types (ApplyWorkspaceEditParams
TextEdit (TextEdit),
WorkspaceEdit (WorkspaceEdit),
type (|?) (..))
import Text.Regex.TDFA ((=~))

data Log = LogShake Shake.Log deriving Show

Expand Down
5 changes: 0 additions & 5 deletions ghcide/src/Development/IDE/Spans/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ getNextPragmaInfo dynFlags mbSource =
| otherwise
-> NextPragmaInfo 0 Nothing

-- NOTE(ozkutuk): `RecordPuns` extension is renamed to `NamedFieldPuns`
-- in GHC 9.4, but we still want to insert `NamedFieldPuns` in pre-9.4
-- GHC as well, hence the replacement.
-- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6156
showExtension :: Extension -> Text
showExtension NamedFieldPuns = "NamedFieldPuns"
showExtension ext = pack (show ext)

insertNewPragma :: NextPragmaInfo -> Extension -> LSP.TextEdit
Expand Down
1 change: 0 additions & 1 deletion ghcide/src/Development/IDE/Types/Diagnostics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module Development.IDE.Types.Diagnostics (
attachReason,
attachedReason) where

import Control.Applicative ((<|>))
import Control.DeepSeq
import Control.Lens
import qualified Data.Aeson as JSON
Expand Down
4 changes: 0 additions & 4 deletions ghcide/src/Development/IDE/Types/HscEnvEq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Control.Exception (evaluate, mask, throwIO)
import Control.Monad.Extra (eitherM, join, mapMaybeM)
import Data.Either (fromRight)
import Data.IORef
import qualified Data.Map as M
import Data.Unique (Unique)
import qualified Data.Unique as Unique
import Development.IDE.GHC.Compat hiding (newUnique)
Expand All @@ -25,9 +24,7 @@ import Development.IDE.GHC.Util (lookupPackageConfig)
import Development.IDE.Graph.Classes
import Development.IDE.Types.Exports (ExportsMap, createExportsMap)
import GHC.Driver.Env (hsc_all_home_unit_ids)
import Ide.PluginUtils (toAbsolute)
import OpenTelemetry.Eventlog (withSpan)
import System.Directory (makeAbsolute)


-- | An 'HscEnv' with equality. Two values are considered equal
Expand All @@ -54,7 +51,6 @@ newHscEnvEq :: HscEnv -> IO HscEnvEq
newHscEnvEq hscEnv' = do

mod_cache <- newIORef emptyInstalledModuleEnv
file_cache <- newIORef M.empty
-- This finder cache is for things which are outside of things which are tracked
-- by HLS. For example, non-home modules, dependent object files etc
#if MIN_VERSION_ghc(9,11,0)
Expand Down
Loading
Loading