[clangd] Add server capability advertising hot-reloading of CDBs.

Currently some clients watch for CDB changes and restart clangd, now that we
can reload compile_commands.json ourselves this is counterproductive.
The capability allows this behavior to be phased out.

This is going to be a mild regression, as we do not actually watch for files on
disk and so new diagnostics need to wait until a rebuild is requested e.g. due
to file change (and the internal caches have expired).
However this is still a better tradeoff (and if it's important, we can request
the client to watch files for us in the future).

Differential Revision: https://reviews.llvm.org/D94222
This commit is contained in:
Sam McCall 2021-01-07 11:40:33 +01:00
parent 10164a2e50
commit 213329d7c6
2 changed files with 7 additions and 2 deletions

View File

@ -620,7 +620,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"documentSymbolProvider", true},
{"workspaceSymbolProvider", true},
{"referencesProvider", true},
{"astProvider", true},
{"astProvider", true}, // clangd extension
{"executeCommandProvider",
llvm::json::Object{
{"commands",
@ -628,7 +628,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
}},
{"typeHierarchyProvider", true},
{"memoryUsageProvider", true}, // clangd extension.
{"memoryUsageProvider", true}, // clangd extension
{"compilationDatabase", // clangd extension
llvm::json::Object{{"automaticReload", true}}},
{"callHierarchyProvider", true},
}}}};
if (Opts.Encoding)

View File

@ -8,6 +8,9 @@
# CHECK-NEXT: "astProvider": true,
# CHECK-NEXT: "callHierarchyProvider": true,
# CHECK-NEXT: "codeActionProvider": true,
# CHECK-NEXT: "compilationDatabase": {
# CHECK-NEXT: "automaticReload": true
# CHECK-NEXT: },
# CHECK-NEXT: "completionProvider": {
# CHECK-NEXT: "allCommitCharacters": [
# CHECK-NEXT: " ",