@@ -23,30 +23,24 @@ import Control.Concurrent.STM (STM)
2323import Control.Concurrent.STM.Stats (TVar , atomically ,
2424 atomicallyNamed , modifyTVar' ,
2525 newTVarIO , readTVar , retry )
26- import Control.Concurrent.Strict (modifyVar_ , newBarrier , newVar ,
27- signalBarrier , threadDelay )
26+ import Control.Concurrent.Strict (modifyVar_ , newVar ,
27+ threadDelay )
2828import Control.Monad.Extra hiding (loop )
2929import Control.Monad.IO.Class
3030import Control.Monad.Trans.Class (lift )
31- import qualified Data.Aeson as J
3231import Data.Functor (($>) )
3332import qualified Data.Text as T
34- import Data.Unique (hashUnique , newUnique )
3533import Development.IDE.GHC.Orphans ()
3634import Development.IDE.Types.Location
3735import Development.IDE.Types.Options
3836import qualified Focus
39- import Language.LSP.Protocol.Message
4037import Language.LSP.Protocol.Types
41- import qualified Language.LSP.Protocol.Types as L
42- import Language.LSP.Server (MonadLsp , ProgressAmount (.. ),
38+ import Language.LSP.Server (ProgressAmount (.. ),
4339 ProgressCancellable (.. ),
44- sendNotification , sendRequest ,
4540 withProgress )
4641import qualified Language.LSP.Server as LSP
4742import qualified StmContainers.Map as STM
4843import UnliftIO (Async , async , bracket , cancel )
49- import qualified UnliftIO.Exception as UE
5044
5145data ProgressEvent
5246 = ProgressNewStarted
@@ -174,7 +168,7 @@ progressReportingNoTrace todo done (Just lspEnv) title optProgressStyle = do
174168 let _progressUpdate event = liftIO $ updateStateVar $ Event event
175169 _progressStop = updateStateVar StopProgress
176170 updateStateVar = modifyVar_ progressState . updateState (progressCounter lspEnv title optProgressStyle todo done)
177- return ProgressReporting {_progressUpdate, _progressStop }
171+ return ProgressReporting {.. }
178172
179173-- | `progressReporting` initiates a new progress reporting session.
180174-- It necessitates the active tracking of progress using the `inProgress` function.
@@ -202,28 +196,6 @@ progressReporting (Just lspEnv) title optProgressStyle = do
202196
203197 f = recordProgress inProgress file
204198
205- withProgressDummy ::
206- forall c m a .
207- MonadLsp c m =>
208- T. Text ->
209- Maybe ProgressToken ->
210- ProgressCancellable ->
211- ((ProgressAmount -> m () ) -> m a ) ->
212- m a
213- withProgressDummy title _ _ f = do
214- UE. bracket start end $ \ _ ->
215- f (const $ return () )
216- where
217- sendProgressReport token report = sendNotification SMethod_Progress $ ProgressParams token $ J. toJSON report
218- start = UE. uninterruptibleMask_ $ do
219- t <- L. ProgressToken . L. InR . T. pack . show . hashUnique <$> liftIO newUnique
220- r <- liftIO newBarrier
221- _ <- sendRequest SMethod_WindowWorkDoneProgressCreate (WorkDoneProgressCreateParams t) $ \ _ -> liftIO $ signalBarrier r ()
222- sendProgressReport t $ WorkDoneProgressBegin L. AString title Nothing Nothing Nothing
223- return t
224- end t = do
225- sendProgressReport t (WorkDoneProgressEnd L. AString Nothing )
226-
227199-- Kill this to complete the progress session
228200progressCounter ::
229201 LSP. LanguageContextEnv c ->
@@ -233,12 +205,8 @@ progressCounter ::
233205 STM Int ->
234206 IO ()
235207progressCounter lspEnv title optProgressStyle getTodo getDone =
236- LSP. runLspT lspEnv $ withProgressChoice title Nothing NotCancellable $ \ update -> loop update 0
208+ LSP. runLspT lspEnv $ withProgress title Nothing NotCancellable $ \ update -> loop update 0
237209 where
238- withProgressChoice = case optProgressStyle of
239- TestReporting -> withProgressDummy
240- _ -> withProgress
241-
242210 loop _ _ | optProgressStyle == NoProgress = forever $ liftIO $ threadDelay maxBound
243211 loop update prevPct = do
244212 (todo, done, nextPct) <- liftIO $ atomically $ do
0 commit comments