This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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
fits.

Diff Detail

Event Timeline

sammccall created this revision.Jan 22 2020, 10:42 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 22 2020, 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.Jan 22 2020, 6:04 PM
kadircet added inline comments.Jan 23 2020, 1:26 AM
clang-tools-extra/clangd/ClangdLSPServer.h
223

s/PendingBackgraundIndexProgress/PendingBackgroundIndexProgress/

232

initialize to false

clang-tools-extra/clangd/Protocol.cpp
383

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.Jan 24 2020, 1:29 AM
sammccall marked 3 inline comments as done.

address comments

clang-tools-extra/clangd/Protocol.cpp
383

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.Jan 24 2020, 2:09 AM
kadircet added inline comments.
clang-tools-extra/clangd/Protocol.cpp
383

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.Jan 24 2020, 2:09 AM
This revision was automatically updated to reflect the committed changes.