Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ae3a5f1
Fix broken pip during test
soulomoon Aug 21, 2025
cd83664
Consolidate source-repository-package entries in cabal.project
soulomoon Aug 21, 2025
c7ad3a2
Add flakiness testing workflow
soulomoon Aug 21, 2025
4d56b39
Update flakiness workflow and fix exit codes in open-close loop script
soulomoon Aug 21, 2025
9272de3
Update lsp repository tag in cabal.project
soulomoon Aug 22, 2025
e1a7947
Update flakiness.yml
soulomoon Aug 22, 2025
ed85d9b
Add InitParameters data type and enhance shutdown handling in Languag…
soulomoon Aug 22, 2025
100b39e
Rename InitParameters to InitializationContext and update related fie…
soulomoon Aug 22, 2025
5835ad7
Increase default maximum iterations to 1000 in flakiness workflow
soulomoon Aug 22, 2025
d26ed7f
Update cabal.project and LanguageServer for improved logging and upda…
soulomoon Aug 22, 2025
c0f6a9b
Merge branch 'master' into 1875-tests-randomly-fail-with-exception-fd…
soulomoon Aug 22, 2025
1f9cb02
Update lsp repository tag to latest commit
soulomoon Aug 22, 2025
c72d2e7
Improve log message for server exit and simplify test failure detecti…
soulomoon Aug 22, 2025
569d766
Fix flakiness test
soulomoon Aug 22, 2025
cb67ec5
Set default max_iter value to 1000 in flakiness test workflow
soulomoon Aug 22, 2025
56bc03b
Refactor logging in open-close loop script to improve iteration outpu…
soulomoon Aug 22, 2025
9f24f2e
Fix exit codes for broken pipe and test failure detection in open-clo…
soulomoon Aug 22, 2025
8eb7bb5
Refactor flakiness testing workflow: replace open-close loop script w…
soulomoon Aug 23, 2025
d233023
Update lsp repository tag to a447a4f
soulomoon Aug 24, 2025
fe7421e
Update cabal.project
soulomoon Aug 24, 2025
7bf694a
update CI
soulomoon Aug 24, 2025
8c17daa
Update reactor shutdown logging, and improve shutdown handling
soulomoon Aug 24, 2025
6907be0
update flaky-test-loop script
soulomoon Aug 26, 2025
0851914
update lsp rev
soulomoon Aug 26, 2025
7900d71
Use a TMVar as a stop flag to coordinate graceful shutdown.
soulomoon Aug 26, 2025
8c50e74
restore
soulomoon Aug 26, 2025
54e334b
restore
soulomoon Aug 26, 2025
d1b6d55
update CI
soulomoon Aug 26, 2025
53a6162
update test
soulomoon Aug 26, 2025
a26922c
Remove comment markers from flaky test patterns for clarity
soulomoon Aug 26, 2025
d10cf47
Remove pattern_file input and use default pattern file for flakiness …
soulomoon Aug 26, 2025
b36f8a6
Replace writeFile and writeFileUTF8 with atomicFileWriteString and at…
soulomoon Aug 26, 2025
15cd44a
Refactor flaky test loop script for improved build handling and error…
soulomoon Aug 28, 2025
ed1c20c
Update lsp
soulomoon Aug 28, 2025
53c4536
format
soulomoon Aug 28, 2025
a9fa00d
Enhance testing workflow and progress reporting
soulomoon Aug 28, 2025
6e50414
Simplify build step in flakiness workflow to compile all tests
soulomoon Aug 28, 2025
1097ce6
Add HLS test executables to flakiness workflow environment
soulomoon Aug 28, 2025
afb4328
Update flakiness workflow to dynamically locate HLS executable
soulomoon Aug 28, 2025
5384ea7
Refactor flakiness workflow to streamline HLS test execution command
soulomoon Aug 28, 2025
bffdb6a
Replace waitForAllProgressDone with waitForKickDone in resolveRequest…
soulomoon Aug 28, 2025
d07c06f
always send progress
soulomoon Aug 29, 2025
7ad628e
update lsp
soulomoon Aug 29, 2025
b962e1f
increase timeout for flakiness
soulomoon Aug 29, 2025
c3758fa
update number of runs to 500 for flakiness
soulomoon Aug 29, 2025
b313fd0
update CI
soulomoon Aug 30, 2025
84f7d35
Add AsyncParentKill exception handling and improve database step retr…
soulomoon Aug 30, 2025
9788101
fix bench
soulomoon Aug 30, 2025
a87d1c2
fix import
soulomoon Aug 30, 2025
66dc235
fix compilation
soulomoon Aug 30, 2025
8483c7b
add event log
soulomoon Aug 31, 2025
969bce9
workaround hlint bug
soulomoon Sep 5, 2025
8f37e25
enforce build state changes
soulomoon Sep 5, 2025
08350aa
Merge remote-tracking branch 'upstream/master' into 1875-tests-random…
soulomoon Sep 5, 2025
773bfee
new hls-graph runtime
soulomoon Sep 5, 2025
b771ed2
update script
soulomoon Sep 6, 2025
f0ae0ee
Merge remote-tracking branch 'upstream/master' into 1875-tests-random…
soulomoon Sep 6, 2025
08e7a8a
Revert "new hls-graph runtime"
soulomoon Sep 6, 2025
075b742
revert hls-graph changes
soulomoon Sep 6, 2025
767ca29
fix build
soulomoon Sep 6, 2025
73ce412
revert test CI changes
soulomoon Sep 6, 2025
42bbfbe
Refactor flakiness workflow and CI
soulomoon Sep 7, 2025
7319397
improve hls graph
soulomoon Sep 10, 2025
0f20eb4
fix build
soulomoon Sep 10, 2025
b11b939
Refactor AIO to use IORef instead of TVar for async management
soulomoon Sep 11, 2025
01a03ff
Refactor builder functions to support BuildArity for unary and n-ary …
soulomoon Sep 11, 2025
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
109 changes: 109 additions & 0 deletions .github/workflows/flakiness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: flakiness

defaults:
run:
shell: bash

concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

on:
# Run on PRs that touch relevant areas and on manual dispatch
pull_request:
branches:
- '**'
paths:
- 'scripts/flaky-test-loop.sh'
- 'scripts/flaky-test-patterns.txt'
- 'ghcide/**'
- 'ghcide-test/**'
- 'hls-test-utils/**'
- 'src/**'
- 'exe/**'
- 'plugins/**'
- 'cabal.project'
- 'stack.yaml'
- 'haskell-language-server.cabal'
- '.github/workflows/flakiness.yml'
workflow_dispatch:
inputs:
max_iter:
description: 'Maximum iterations to attempt'
required: false
default: '1000'
sleep_secs:
description: 'Seconds to sleep between iterations'
required: false
default: '0'
test_patterns:
description: 'Comma-separated Tasty patterns to run each iteration (overrides default)'
required: false
default: ''

jobs:
loop:
name: Flakiness Test (broken pipe and test failures)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest

steps:
- uses: actions/checkout@v4

- name: Setup GHC and caching
uses: ./.github/actions/setup-build
with:
ghc: '9.12'
os: ${{ runner.os }}

- name: Show cabal and GHC versions
run: |
cabal --version
ghc --version
- name: Build
env:
PATTERN_FILE: 'scripts/flaky-test-patterns.txt'
RUN_MODE: 'build'
run: HLS_TEST_EXE="$(cabal exec which hls)" bash scripts/flaky-test-loop.sh

- name: Run flakiness loop
id: run-loop
# Let this run for a while; build is done once inside the script
timeout-minutes: 60
env:
# Use workflow_dispatch inputs when present, else defaults
SLEEP_SECS: ${{ github.event.inputs.sleep_secs || '0' }}
LOG_STDERR: '1'
TEST_PATTERNS: ${{ github.event.inputs.test_patterns }}
PATTERN_FILE: 'scripts/flaky-test-patterns.txt'
NO_BUILD_ONCE: '1'
RUN_MODE: 'run'
# HLS_TEST_EXE: 'hls' # HLS_WRAPPER_TEST_EXE: 'hls-wrapper'
run: |
# Run with a sensible default of 500 iterations on PRs;
max_iter="${{ github.event.inputs.max_iter }}"
max_iter="${max_iter:-500}"
# copy hls to current dir so the script can find it
HLS_TEST_EXE="$(cabal exec which hls)" bash scripts/flaky-test-loop.sh "${max_iter}"
ec=$?
# Interpret exit codes from flaky-test-loop.sh
# 0 => no issues reproduced within MAX_ITER -> pass job
# 1 => issue reproduced (broken pipe or test failure) -> fail job
# 2+ => setup/infra error -> fail job
if [[ $ec -eq 1 ]]; then
echo "Issue reproduced (broken pipe or test failure): failing job"
exit 1
elif [[ $ec -eq 0 ]]; then
echo "No issues reproduced within MAX_ITER=${max_iter}: passing"
exit 0
else
echo "Loop script error (exit $ec): failing"
exit $ec
fi

6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ if impl(ghc >= 9.11)
allow-newer:
cabal-install-parsers:base,
cabal-install-parsers:time,

source-repository-package
type: git
location: https://github.com/soulomoon/lsp.git
tag: 640c7c755bf16128e3cb19c257688aa3305ff9f5
subdir: lsp lsp-types lsp-test
8 changes: 4 additions & 4 deletions ghcide-test/exe/ResolveTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Language.LSP.Test hiding (resolveCompletion)
import Test.Hls (IdeState, SMethod (..), liftIO,
mkPluginTestDescriptor,
someMethodToMethodString,
waitForAllProgressDone)
waitForKickDone)
import qualified Test.Hls.FileSystem as FS
import Test.Tasty
import Test.Tasty.HUnit
Expand Down Expand Up @@ -100,7 +100,7 @@ resolveRequests =
, "data Foo = Foo { foo :: Int }"
, "bar = Foo 4"
]
waitForAllProgressDone
waitForKickDone
items <- getCompletions doc (Position 2 7)
let resolveCompItems = filter (\i -> "test item" `T.isPrefixOf` (i ^. J.label)) items
liftIO $ assertEqual "There must be exactly two results" 2 (length resolveCompItems)
Expand All @@ -113,7 +113,7 @@ resolveRequests =
, "data Foo = Foo { foo :: Int }"
, "bar = Foo 4"
]
waitForAllProgressDone
waitForKickDone
-- Cant use 'getAllCodeActions', as this lsp-test function queries the diagnostic
-- locations and we don't have diagnostics in these tests.
cas <- Maybe.mapMaybe (preview _R) <$> getCodeActions doc (Range (Position 0 0) (Position 1 0))
Expand All @@ -128,7 +128,7 @@ resolveRequests =
, "data Foo = Foo { foo :: Int }"
, "bar = Foo 4"
]
waitForAllProgressDone
waitForKickDone
cd <- getCodeLenses doc
let resolveCodeLenses = filter (\i -> case i ^. J.command of
Just cmd -> "test item" `T.isPrefixOf` (cmd ^. J.title)
Expand Down
18 changes: 11 additions & 7 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE TypeFamilies #-}

{-|
The logic for setting up a ghcide session by tapping into hie-bios.
Expand Down Expand Up @@ -104,8 +105,7 @@
import qualified Data.Set as OS
import Database.SQLite.Simple
import Development.IDE.Core.Tracing (withTrace)
import Development.IDE.Core.WorkerThread (awaitRunInThread,
withWorkerQueue)
import Development.IDE.Core.WorkerThread
import qualified Development.IDE.GHC.Compat.Util as Compat
import Development.IDE.Session.Diagnostics (renderCradleError)
import Development.IDE.Types.Shake (WithHieDb,
Expand All @@ -119,6 +119,7 @@
import System.Random (RandomGen)
import Text.ParserCombinators.ReadP (readP_to_S)

import qualified Control.Monad.Catch as MC
import GHC.Driver.Env (hsc_all_home_unit_ids)
import GHC.Driver.Errors.Types
import GHC.Types.Error (errMsgDiagnostic,
Expand Down Expand Up @@ -149,10 +150,12 @@
| LogNewComponentCache !(([FileDiagnostic], Maybe HscEnvEq), DependencyInfo)
| LogHieBios HieBios.Log
| LogSessionLoadingChanged
| LogSessionWorkerThread LogWorkerThread
deriving instance Show Log

instance Pretty Log where
pretty = \case
LogSessionWorkerThread msg -> pretty msg
LogNoneCradleFound path ->
"None cradle found for" <+> pretty path <+> ", ignoring the file"
LogSettingInitialDynFlags ->
Expand Down Expand Up @@ -381,8 +384,8 @@
_ <- withWriteDbRetryable deleteMissingRealFiles
_ <- withWriteDbRetryable garbageCollectTypeNames

runContT (withWorkerQueue (writer withWriteDbRetryable)) $ \chan ->
withHieDb fp (\readDb -> k (WithHieDbShield $ makeWithHieDbRetryable recorder rng readDb, chan))
runContT (withWorkerQueue (cmapWithPrio LogSessionWorkerThread recorder) "hiedb thread" (writer withWriteDbRetryable))
$ \chan -> withHieDb fp (\readDb -> k (WithHieDbShield $ makeWithHieDbRetryable recorder rng readDb, chan))
where
writer withHieDbRetryable l = do
-- TODO: probably should let exceptions be caught/logged/handled by top level handler
Expand Down Expand Up @@ -415,7 +418,7 @@
-- components mapping to the same hie.yaml file are mapped to the same
-- HscEnv which is updated as new components are discovered.

loadSessionWithOptions :: Recorder (WithPriority Log) -> SessionLoadingOptions -> FilePath -> TQueue (IO ()) -> IO (Action IdeGhcSession)
loadSessionWithOptions :: Recorder (WithPriority Log) -> SessionLoadingOptions -> FilePath -> TaskQueue (IO ()) -> IO (Action IdeGhcSession)
loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
let toAbsolutePath = toAbsolute rootDir -- see Note [Root Directory]
cradle_files <- newIORef []
Expand Down Expand Up @@ -629,7 +632,7 @@
[] -> error $ "GHC version could not be parsed: " <> version
((runTime, _):_)
| compileTime == runTime -> do
atomicModifyIORef' cradle_files (\xs -> (cfp:xs,()))

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

View workflow job for this annotation

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
Expand Down Expand Up @@ -753,6 +756,7 @@
emptyHscEnv nc libDir = do
-- We call setSessionDynFlags so that the loader is initialised
-- We need to do this before we call initUnits.
-- we mask_ here because asynchronous exceptions might be swallowed
env <- runGhc (Just libDir) $
getSessionDynFlags >>= setSessionDynFlags >> getSession
pure $ setNameCache nc (hscSetFlags ((hsc_dflags env){useUnicode = True }) env)
Expand Down Expand Up @@ -896,7 +900,7 @@
x <- map errMsgDiagnostic closure_errs
DriverHomePackagesNotClosed us <- pure x
pure us
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units

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

View workflow job for this annotation

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
Expand Down
3 changes: 2 additions & 1 deletion ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@
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

View workflow job for this annotation

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
import Development.IDE.Core.Shake
import Development.IDE.Core.WorkerThread (writeTaskQueue)
import Development.IDE.Core.Tracing (withTrace)
import qualified Development.IDE.GHC.Compat as Compat
import qualified Development.IDE.GHC.Compat as GHC
Expand Down Expand Up @@ -825,7 +826,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 829 in ghcide/src/Development/IDE/Core/Compile.hs

View workflow job for this annotation

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
Expand Down Expand Up @@ -882,7 +883,7 @@
-- hiedb doesn't use the Haskell src, so we clear it to avoid unnecessarily keeping it around
let !hf' = hf{hie_hs_src = mempty}
modifyTVar' indexPending $ HashMap.insert srcPath hash
writeTQueue indexQueue $ \withHieDb -> do
writeTaskQueue indexQueue $ \withHieDb -> do
-- We are now in the worker thread
-- Check if a newer index of this file has been scheduled, and if so skip this one
newerScheduled <- atomically $ do
Expand Down Expand Up @@ -1105,7 +1106,7 @@


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

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

View workflow job for this annotation

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
Expand Down
7 changes: 4 additions & 3 deletions ghcide/src/Development/IDE/Core/FileStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Development.IDE.Core.IdeConfiguration (isWorkspaceFile)
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Shake hiding (Log)
import qualified Development.IDE.Core.Shake as Shake
import Development.IDE.Core.WorkerThread
import Development.IDE.GHC.Orphans ()
import Development.IDE.Graph
import Development.IDE.Import.DependencyInformation
Expand Down Expand Up @@ -252,8 +253,8 @@ getVersionedTextDoc doc = do
maybe (pure Nothing) getVirtualFile $
uriToNormalizedFilePath $ toNormalizedUri uri
let ver = case mvf of
Just (VirtualFile lspver _ _) -> lspver
Nothing -> 0
Just (VirtualFile lspver _ _ _) -> lspver
Nothing -> 0
return (VersionedTextDocumentIdentifier uri ver)

fileStoreRules :: Recorder (WithPriority Log) -> (NormalizedFilePath -> Action Bool) -> Rules ()
Expand Down Expand Up @@ -304,7 +305,7 @@ typecheckParentsAction recorder nfp = do
setSomethingModified :: VFSModified -> IdeState -> String -> IO [Key] -> IO ()
setSomethingModified vfs state reason actionBetweenSession = do
-- Update database to remove any files that might have been renamed/deleted
atomically $ writeTQueue (indexQueue $ hiedbWriter $ shakeExtras state) (\withHieDb -> withHieDb deleteMissingRealFiles)
atomically $ writeTaskQueue (indexQueue $ hiedbWriter $ shakeExtras state) (\withHieDb -> withHieDb deleteMissingRealFiles)
void $ restartShakeSession (shakeExtras state) vfs reason [] actionBetweenSession

registerFileWatches :: [String] -> LSP.LspT Config IO Bool
Expand Down
42 changes: 37 additions & 5 deletions ghcide/src/Development/IDE/Core/ProgressReporting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,30 @@ import Control.Concurrent.STM (STM)
import Control.Concurrent.STM.Stats (TVar, atomically,
atomicallyNamed, modifyTVar',
newTVarIO, readTVar, retry)
import Control.Concurrent.Strict (modifyVar_, newVar,
threadDelay)
import Control.Concurrent.Strict (modifyVar_, newBarrier, newVar,
signalBarrier, threadDelay)
import Control.Monad.Extra hiding (loop)
import Control.Monad.IO.Class
import Control.Monad.Trans.Class (lift)
import qualified Data.Aeson as J
import Data.Functor (($>))
import qualified Data.Text as T
import Data.Unique (hashUnique, newUnique)
import Development.IDE.GHC.Orphans ()
import Development.IDE.Types.Location
import Development.IDE.Types.Options
import qualified Focus
import Language.LSP.Protocol.Message
import Language.LSP.Protocol.Types
import Language.LSP.Server (ProgressAmount (..),
import qualified Language.LSP.Protocol.Types as L
import Language.LSP.Server (MonadLsp, ProgressAmount (..),
ProgressCancellable (..),
sendNotification, sendRequest,
withProgress)
import qualified Language.LSP.Server as LSP
import qualified StmContainers.Map as STM
import UnliftIO (Async, async, bracket, cancel)
import qualified UnliftIO.Exception as UE

data ProgressEvent
= ProgressNewStarted
Expand Down Expand Up @@ -168,7 +174,7 @@ progressReportingNoTrace todo done (Just lspEnv) title optProgressStyle = do
let _progressUpdate event = liftIO $ updateStateVar $ Event event
_progressStop = updateStateVar StopProgress
updateStateVar = modifyVar_ progressState . updateState (progressCounter lspEnv title optProgressStyle todo done)
return ProgressReporting {..}
return ProgressReporting {_progressUpdate, _progressStop}

-- | `progressReporting` initiates a new progress reporting session.
-- It necessitates the active tracking of progress using the `inProgress` function.
Expand Down Expand Up @@ -196,6 +202,28 @@ progressReporting (Just lspEnv) title optProgressStyle = do

f = recordProgress inProgress file

withProgressDummy ::
forall c m a.
MonadLsp c m =>
T.Text ->
Maybe ProgressToken ->
ProgressCancellable ->
((ProgressAmount -> m ()) -> m a) ->
m a
withProgressDummy title _ _ f = do
UE.bracket start end $ \_ ->
f (const $ return ())
where
sendProgressReport token report = sendNotification SMethod_Progress $ ProgressParams token $ J.toJSON report
start = UE.uninterruptibleMask_ $ do
t <- L.ProgressToken . L.InR . T.pack . show . hashUnique <$> liftIO newUnique
r <- liftIO newBarrier
_ <- sendRequest SMethod_WindowWorkDoneProgressCreate (WorkDoneProgressCreateParams t) $ \_ -> liftIO $ signalBarrier r ()
sendProgressReport t $ WorkDoneProgressBegin L.AString title Nothing Nothing Nothing
return t
end t = do
sendProgressReport t (WorkDoneProgressEnd L.AString Nothing)

-- Kill this to complete the progress session
progressCounter ::
LSP.LanguageContextEnv c ->
Expand All @@ -205,8 +233,12 @@ progressCounter ::
STM Int ->
IO ()
progressCounter lspEnv title optProgressStyle getTodo getDone =
LSP.runLspT lspEnv $ withProgress title Nothing NotCancellable $ \update -> loop update 0
LSP.runLspT lspEnv $ withProgressChoice title Nothing NotCancellable $ \update -> loop update 0
where
withProgressChoice = case optProgressStyle of
TestReporting -> withProgressDummy
_ -> withProgress

loop _ _ | optProgressStyle == NoProgress = forever $ liftIO $ threadDelay maxBound
loop update prevPct = do
(todo, done, nextPct) <- liftIO $ atomically $ do
Expand Down
4 changes: 2 additions & 2 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@
vfsRef <- asks vfsVar
vfsData <- liftIO $ _vfsMap <$> readTVarIO vfsRef
(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)
Just (Open vf) -> pure (virtualFileText vf, Just $ virtualFileVersion vf)
_ -> (,Nothing) . T.decodeUtf8 <$> BS.readFile (fromNormalizedFilePath file)
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)
Expand Down Expand Up @@ -809,7 +809,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 812 in ghcide/src/Development/IDE/Core/Rules.hs

View workflow job for this annotation

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
}
Expand Down
Loading
Loading