[clang-tools-extra] 678303c - [clangd] Fix code action kind for readability-identifier-naming fixes (#162808)

via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 12 23:04:56 PDT 2025


Author: Ruoyu Zhong
Date: 2025-10-13T02:04:51-04:00
New Revision: 678303cd92983b75e35df298a9ee5a6d26ca4a26

URL: https://github.com/llvm/llvm-project/commit/678303cd92983b75e35df298a9ee5a6d26ca4a26
DIFF: https://github.com/llvm/llvm-project/commit/678303cd92983b75e35df298a9ee5a6d26ca4a26.diff

LOG: [clangd] Fix code action kind for readability-identifier-naming fixes (#162808)

https://github.com/llvm/llvm-project/pull/78454 converted
readability-identifier-naming fixes to use rename mechanism to rename
the symbol project-wide. 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)".

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

Signed-off-by: Ruoyu Zhong <zhongruoyu at outlook.com>

Added: 
    

Modified: 
    clang-tools-extra/clangd/ClangdLSPServer.cpp
    clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 
    


################################################################################
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);


        


More information about the cfe-commits mailing list