@@ -23,30 +23,24 @@ import Control.Concurrent.STM (STM)
23
23
import Control.Concurrent.STM.Stats (TVar , atomically ,
24
24
atomicallyNamed , modifyTVar' ,
25
25
newTVarIO , readTVar , retry )
26
- import Control.Concurrent.Strict (modifyVar_ , newBarrier , newVar ,
27
- signalBarrier , threadDelay )
26
+ import Control.Concurrent.Strict (modifyVar_ , newVar ,
27
+ threadDelay )
28
28
import Control.Monad.Extra hiding (loop )
29
29
import Control.Monad.IO.Class
30
30
import Control.Monad.Trans.Class (lift )
31
- import qualified Data.Aeson as J
32
31
import Data.Functor (($>) )
33
32
import qualified Data.Text as T
34
- import Data.Unique (hashUnique , newUnique )
35
33
import Development.IDE.GHC.Orphans ()
36
34
import Development.IDE.Types.Location
37
35
import Development.IDE.Types.Options
38
36
import qualified Focus
39
- import Language.LSP.Protocol.Message
40
37
import 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 (.. ),
43
39
ProgressCancellable (.. ),
44
- sendNotification , sendRequest ,
45
40
withProgress )
46
41
import qualified Language.LSP.Server as LSP
47
42
import qualified StmContainers.Map as STM
48
43
import UnliftIO (Async , async , bracket , cancel )
49
- import qualified UnliftIO.Exception as UE
50
44
51
45
data ProgressEvent
52
46
= ProgressNewStarted
@@ -174,7 +168,7 @@ progressReportingNoTrace todo done (Just lspEnv) title optProgressStyle = do
174
168
let _progressUpdate event = liftIO $ updateStateVar $ Event event
175
169
_progressStop = updateStateVar StopProgress
176
170
updateStateVar = modifyVar_ progressState . updateState (progressCounter lspEnv title optProgressStyle todo done)
177
- return ProgressReporting {_progressUpdate, _progressStop }
171
+ return ProgressReporting {.. }
178
172
179
173
-- | `progressReporting` initiates a new progress reporting session.
180
174
-- It necessitates the active tracking of progress using the `inProgress` function.
@@ -202,28 +196,6 @@ progressReporting (Just lspEnv) title optProgressStyle = do
202
196
203
197
f = recordProgress inProgress file
204
198
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
-
227
199
-- Kill this to complete the progress session
228
200
progressCounter ::
229
201
LSP. LanguageContextEnv c ->
@@ -233,12 +205,8 @@ progressCounter ::
233
205
STM Int ->
234
206
IO ()
235
207
progressCounter 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
237
209
where
238
- withProgressChoice = case optProgressStyle of
239
- TestReporting -> withProgressDummy
240
- _ -> withProgress
241
-
242
210
loop _ _ | optProgressStyle == NoProgress = forever $ liftIO $ threadDelay maxBound
243
211
loop update prevPct = do
244
212
(todo, done, nextPct) <- liftIO $ atomically $ do
0 commit comments