Skip to content

Conversation

@ZhongRuoyu
Copy link
Member

Commit a45df47 (#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 #78454 (comment).

CC @tom-anders @HighCommander4.

Commit a45df47
(llvm#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 llvm#78454 (comment).

Signed-off-by: Ruoyu Zhong <[email protected]>
@llvmbot
Copy link
Member

llvmbot commented Oct 10, 2025

@llvm/pr-subscribers-clangd

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

Author: Ruoyu Zhong (ZhongRuoyu)

Changes

Commit a45df47 (#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 #78454 (comment).

CC @tom-anders @HighCommander4.


Full diff: https://github.com/llvm/llvm-project/pull/162808.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 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);

@HighCommander4
Copy link
Collaborator

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)"

Ouch! Thanks very much for catching and fixing that.

@HighCommander4 HighCommander4 merged commit 678303c into llvm:main Oct 13, 2025
13 checks passed
@ZhongRuoyu ZhongRuoyu deleted the clangd-readability-identifier-renaming-quickfix branch October 13, 2025 06:08
@ZhongRuoyu
Copy link
Member Author

ZhongRuoyu commented Oct 13, 2025

Thanks for merging, @HighCommander4! What do you think about backporting this to the 21.x branch so that existing users can get this without having to wait for a 22.x release?

If you think it's OK: #163130

ZhongRuoyu added a commit to ZhongRuoyu/llvm-project that referenced this pull request Oct 13, 2025
…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]>
DharuniRAcharya pushed a commit to DharuniRAcharya/llvm-project that referenced this pull request Oct 13, 2025
…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]>
c-rhodes pushed a commit that referenced this pull request Oct 14, 2025
…#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".

Signed-off-by: Ruoyu Zhong <[email protected]>
akadutta pushed a commit to akadutta/llvm-project that referenced this pull request Oct 14, 2025
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants