https://github.com/ZhongRuoyu created 
https://github.com/llvm/llvm-project/pull/162808

Commit a45df47375e50914900dcc07abd2fa67bfa0dd3b 
(https://github.com/llvm/llvm-project/pull/78454) converted 
readability-identifier-naming fixes to use rename mechanism to leverage the 
index for better results. However, it set the code action kind to "refactor" 
instead of "quickfix", which caused the fixes to be filtered out when editors 
(like VS Code) request quick fixes for diagnostics. On VS Code, for example, 
users would see "No quick fixes available" despite the diagnostic indicating 
"(fix available)", and the following warning would appear in the output console:

    [warning] llvm-vs-code-extensions.vscode-clangd - Code actions of kind 
'quickfix' requested but returned code action is of kind 'refactor'. Code 
action will be dropped. Please check 'CodeActionContext.only' to only return 
requested code actions.

Fix that by changing the code action kind back to "quickfix".

Addresses 
https://github.com/llvm/llvm-project/pull/78454#issuecomment-1937918144.

CC @tom-anders @HighCommander4.


>From 604c0a003c436833299b0d80217d246e963b7a50 Mon Sep 17 00:00:00 2001
From: Ruoyu Zhong <[email protected]>
Date: Fri, 10 Oct 2025 16:55:45 +0800
Subject: [PATCH] [clangd] Fix code action kind for
 readability-identifier-naming fixes

Commit a45df47375e50914900dcc07abd2fa67bfa0dd3b
(https://github.com/llvm/llvm-project/pull/78454) converted
readability-identifier-naming fixes to use rename mechanism to leverage
the index for better results. However, it set the code action kind to
"refactor" instead of "quickfix", which caused the fixes to be filtered
out when editors (like VS Code) request quick fixes for diagnostics. On
VS Code, for example, users would see "No quick fixes available" despite
the diagnostic indicating "(fix available)", and the following warning
would appear in the output console:

    [warning] llvm-vs-code-extensions.vscode-clangd - Code actions of kind 
'quickfix' requested but returned code action is of kind 'refactor'. Code 
action will be dropped. Please check 'CodeActionContext.only' to only return 
requested code actions.

Fix that by changing the code action kind back to "quickfix".

Addresses 
https://github.com/llvm/llvm-project/pull/78454#issuecomment-1937918144.

Signed-off-by: Ruoyu Zhong <[email protected]>
---
 clang-tools-extra/clangd/ClangdLSPServer.cpp                | 2 +-
 clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index b445dcf2bbd2e..0f765e96fb152 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -81,7 +81,7 @@ CodeAction toCodeAction(const 
ClangdServer::CodeActionResult::Rename &R,
                         const URIForFile &File) {
   CodeAction CA;
   CA.title = R.FixMessage;
-  CA.kind = std::string(CodeAction::REFACTOR_KIND);
+  CA.kind = std::string(CodeAction::QUICKFIX_KIND);
   CA.command.emplace();
   CA.command->title = R.FixMessage;
   CA.command->command = std::string(ApplyRenameCommand);
diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index 2c7f50d8c9e4c..95bf5e54fc792 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -235,7 +235,8 @@ TEST_F(LSPTest, ClangTidyRename) {
             .takeValue()
             .getAsArray())[0];
 
-  ASSERT_EQ((*RenameCommand.getAsObject())["title"], "change 'foo' to 'Foo'");
+  ASSERT_EQ((*RenameCommand.getAsObject())["title"],
+            "Apply fix: change 'foo' to 'Foo'");
 
   Client.expectServerCall("workspace/applyEdit");
   Client.call("workspace/executeCommand", RenameCommand);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to