-
Notifications
You must be signed in to change notification settings - Fork 15.1k
release/21.x: [clangd] Fix code action kind for readability-identifier-naming fixes (#162808) #163130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…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]>
|
@llvm/pr-subscribers-clangd Author: Ruoyu Zhong (ZhongRuoyu) ChangesBackport 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:
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);
|
|
@llvm/pr-subscribers-clang-tools-extra Author: Ruoyu Zhong (ZhongRuoyu) ChangesBackport 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:
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);
|
HighCommander4
left a comment
There was a problem hiding this 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-namingclang-tidy check) - It's a low risk, one-liner fix
|
merged - c03b58b |
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".