Page MenuHomePhabricator

[clangd] Show background index status using LSP 3.15 work-done progress notifications

Authored by sammccall on Wed, Jan 22, 10:42 AM.



It simply shows the completed/total items on the background queue, e.g.
indexing: 233/1000
The denominator is reset to zero every time the queue goes idle.

The protocol is fairly complicated here (requires creating a remote "progress"
resource before sending updates). We implement the full protocol, but I've added
an extension allowing it to be skipped to reduce the burden on clients - in
particular the lit test takes this shortcut.

The addition of background index progress to DiagnosticConsumer seems ridiculous
at first glance, but I believe that interface is trending in the direction of
"ClangdServer callbacks" anyway. It's due for a rename, but otherwise actually

Diff Detail

Event Timeline

sammccall created this revision.Wed, Jan 22, 10:42 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptWed, Jan 22, 10:42 AM

Revert changes to VSCode client. This experimental version of the VSCode libs
is fairly new and some corp mirrors we care about are behind ;-)

also clang-format

revert accidental change

Unit tests: unknown.

clang-tidy: fail. clang-tidy found 1 errors and 11 warnings.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt

nridge added a subscriber: nridge.Wed, Jan 22, 6:04 PM
kadircet added inline comments.Thu, Jan 23, 1:26 AM



initialize to false


why not have a single struct with that has a required kind field and a bunch of optional fields.
Later on we can assert on the existence of fields depending on the kind, I think it would simplify the implementation.

sammccall updated this revision to Diff 240121.Fri, Jan 24, 1:29 AM
sammccall marked 3 inline comments as done.

address comments


Yeah, this was my first thought/attempt. It's possible but I think not ideal in the end.

The main downsides:

  • this would diverge from LSP and so make it harder to cross-reference things
  • this would diverge from LSP and usually we don't, so it's surprising
  • the semantics of the "same" field across different events are sometimes subtly different. e.g. Begin.cancellable is whether a cancel button is shown (and in VSCode, the overall UI!) whereas End.cancellable controls its enablement.
  • between replicating the LSP docs, documenting divergence, documenting varied optionality, and documenting varying semantics, the merged struct is really hard to document well
  • it's a bit harder to see the structure of the messages clangd sends this way: e.g. we always send message in report, but never in begin/end, how we handle percentage etc

Mostly I think following LSP closely is a good thing, but it sucks when the spec is a mess :-(

Unit tests: unknown.

clang-tidy: fail. clang-tidy found 8 errors and 12 warnings. 12 of them are added as review comments below (why?).

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

kadircet accepted this revision.Fri, Jan 24, 2:09 AM
kadircet added inline comments.

this would diverge from LSP and so make it harder to cross-reference things

ah sorry, I didn't know LSP defined those in 3 different structs, that makes sense.

SG then

This revision is now accepted and ready to land.Fri, Jan 24, 2:09 AM
This revision was automatically updated to reflect the committed changes.