[clang-tools-extra] 7de1eff - [clangd] Check for editsNearCursor client capability under experimental capabilities (#114699)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 23:13:24 PST 2024


Author: Nathan Ridge
Date: 2024-11-05T02:13:21-05:00
New Revision: 7de1eff7cff35481e4a502858c5e3ff21502b186

URL: https://github.com/llvm/llvm-project/commit/7de1eff7cff35481e4a502858c5e3ff21502b186
DIFF: https://github.com/llvm/llvm-project/commit/7de1eff7cff35481e4a502858c5e3ff21502b186.diff

LOG: [clangd] Check for editsNearCursor client capability under experimental capabilities (#114699)

This is done to support clients which only support adding custom
(language-specific or server-specific) capabilities under
'experimental'.

Fixes https://github.com/clangd/clangd/issues/2201

Added: 
    

Modified: 
    clang-tools-extra/clangd/Protocol.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 295ccd26a40454..761f96846d4538 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -504,6 +504,16 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
                   P.field("offsetEncoding")))
       return false;
   }
+
+  if (auto *Experimental = O->getObject("experimental")) {
+    if (auto *TextDocument = Experimental->getObject("textDocument")) {
+      if (auto *Completion = TextDocument->getObject("completion")) {
+        if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
+          R.CompletionFixes |= *EditsNearCursor;
+      }
+    }
+  }
+
   return true;
 }
 


        


More information about the cfe-commits mailing list