Skip to content

Conversation

@ZhongRuoyu
Copy link
Member

Backport of #162808.

#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".

…llvm#162808)

llvm#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 <[email protected]>
@llvmbot
Copy link
Member

llvmbot commented Oct 13, 2025

@llvm/pr-subscribers-clangd

Author: Ruoyu Zhong (ZhongRuoyu)

Changes

Backport of #162808.

#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".


Full diff: https://github.com/llvm/llvm-project/pull/163130.diff

2 Files Affected:

  • (modified) clang-tools-extra/clangd/ClangdLSPServer.cpp (+1-1)
  • (modified) clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp (+2-1)
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index a703009e2b467..e83af299bbd18 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);

@llvmbot
Copy link
Member

llvmbot commented Oct 13, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: Ruoyu Zhong (ZhongRuoyu)

Changes

Backport of #162808.

#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".


Full diff: https://github.com/llvm/llvm-project/pull/163130.diff

2 Files Affected:

  • (modified) clang-tools-extra/clangd/ClangdLSPServer.cpp (+1-1)
  • (modified) clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp (+2-1)
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index a703009e2b467..e83af299bbd18 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);

Copy link
Collaborator

@HighCommander4 HighCommander4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for backporting this to 21.x:

  • It fixes a regression (users of some popular LSP clients like VSCode are unable to accept the fixit for the readability-identifier-naming clang-tidy check)
  • It's a low risk, one-liner fix

@HighCommander4 HighCommander4 added this to the LLVM 21.x Release milestone Oct 13, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Oct 13, 2025
@c-rhodes c-rhodes moved this from Needs Triage to Needs Merge in LLVM Release Status Oct 13, 2025
@c-rhodes
Copy link
Collaborator

merged - c03b58b

@c-rhodes c-rhodes closed this Oct 14, 2025
@c-rhodes c-rhodes moved this from Needs Merge to Done in LLVM Release Status Oct 14, 2025
@ZhongRuoyu ZhongRuoyu deleted the clangd-readability-identifier-renaming-quickfix-backport branch October 14, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants