haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Wait for progress token using Barrier when indexHieFile

Open soulomoon opened this issue 1 year ago • 5 comments

soulomoon avatar May 02 '24 23:05 soulomoon

Could we refactor this to actually use the helpers from lsp for running progress sessions? I think that should handle all of this properly, rather than us re-implementing it here?

michaelpj avatar May 03 '24 11:05 michaelpj

This code manages its progress token in a somewhat unique way which is not easy to statically scope with the lsp progress functions.

wz1000 avatar May 03 '24 11:05 wz1000

Instead of a long runner task, it is more like tunes of small tasks dynamically created only finished when the all the pendding tasks are done. Hard to fit this in helpers from lsp. But we still can if we are handling this in a seperate thread, might need serveral pipes though. And hard to say if it would make thing simpler🤔

soulomoon avatar May 03 '24 15:05 soulomoon

I've spawn a new thread to run the indexing progress update, send through TQueue. 🤔 Is it a good idea to do so?

soulomoon avatar May 04 '24 23:05 soulomoon

I think we can probably do something like https://github.com/haskell/haskell-language-server/pull/4218 now

michaelpj avatar May 19 '24 15:05 michaelpj

I think we can probably do something like #4218 now

It seems, here we are using a push update model. And in #4218, it is a pull update model for every interval. Maybe we can unify to use a pull update model?

Also, I am wondering if we can make Development.IDE.Core.ProgressReporting more general, so we can actually reuse it.

soulomoon avatar Jun 12 '24 07:06 soulomoon

Also, I am wondering if we can make Development.IDE.Core.ProgressReporting more general, so we can actually reuse it.

Yes, I think there's almost something there. It's something like a standalone counter that also has some triggers for killing and restarting it?

michaelpj avatar Jun 12 '24 08:06 michaelpj

The scope quite complex and is hard to fit in.

To solve the scope problem, I refactored the Development.IDE.Core.ProgressReporting to add InProgressStateOutSide. We can let the ouside program manage the state, and ProgressReporting just pull in the todo and done count.

soulomoon avatar Jun 13 '24 11:06 soulomoon

But it seems we lose the finish notification. Any idea? @michaelpj I think it should be fine even if we do not show the finish notification? Or maybe we can add it to LSP package?

soulomoon avatar Jun 13 '24 17:06 soulomoon

Now it becomes resumable/restartable/cancellable progress reporting

We might want to renamed that

  • ProgressStarted -> ProgressNewStarted: cancel the old one
  • ProgressTryToStart -> ProgressStarted: won't cancel the old one

soulomoon avatar Jun 17 '24 12:06 soulomoon

After introducing new event capturing more progress reporting logic, we are able to change the indexProgressToken :: Var (Maybe LSP.ProgressToken) to indexProgressReporting :: ProgressReporting IO. Ready to be reviewed again @michaelpj

soulomoon avatar Jun 18 '24 11:06 soulomoon

Needs conflicts fixed then good to go

michaelpj avatar Jun 20 '24 08:06 michaelpj