OSDN Git Service

[clangd] Show background index status using LSP 3.15 work-done progress notifications
authorSam McCall <sam.mccall@gmail.com>
Wed, 22 Jan 2020 18:41:45 +0000 (19:41 +0100)
committerSam McCall <sam.mccall@gmail.com>
Fri, 24 Jan 2020 11:21:08 +0000 (12:21 +0100)
commit7d20e80225b3e4f3f5a8c57929061bef55f3d855
tree16abb30e8b8e2f4109383fdb687270a6ffdda90e
parente37cdbeeabfb17821b9ff5d2f42e9f440882dab8
[clangd] Show background index status using LSP 3.15 work-done progress notifications

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.

Reviewers: kadircet, usaxena95

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D73218
13 files changed:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/BackgroundQueue.cpp
clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
clang-tools-extra/clangd/test/background-index.test
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
llvm/include/llvm/Support/JSON.h