[llvm-branch-commits] [clang-tools-extra] 213329d - [clangd] Add server capability advertising hot-reloading of CDBs.

Sam McCall via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 7 04:44:15 PST 2021


Author: Sam McCall
Date: 2021-01-07T13:39:21+01:00
New Revision: 213329d7c64f9710f23a78596255509b147b37c6

URL: https://github.com/llvm/llvm-project/commit/213329d7c64f9710f23a78596255509b147b37c6
DIFF: https://github.com/llvm/llvm-project/commit/213329d7c64f9710f23a78596255509b147b37c6.diff

LOG: [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

Added: 
    

Modified: 
    clang-tools-extra/clangd/ClangdLSPServer.cpp
    clang-tools-extra/clangd/test/initialize-params.test

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index c606ccae4fdc..4e5d9f8bf0fa 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -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)

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test b/clang-tools-extra/clangd/test/initialize-params.test
index e4f4bf18dee4..907ab0ade420 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -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:          " ",


        


More information about the llvm-branch-commits mailing list