[clang-tools-extra] r369656 - [clangd] Send suppported codeActionKinds to the client.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 22 07:53:45 PDT 2019
Author: hokein
Date: Thu Aug 22 07:53:45 2019
New Revision: 369656
URL: http://llvm.org/viewvc/llvm-project?rev=369656&view=rev
Log:
[clangd] Send suppported codeActionKinds to the client.
Summary:
This would make client know which codeActionKinds that clangd may
return.
VSCode will add a new entry "Refactor..." (which shows all
refactoring-kind code actions) in the right-click menu.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66592
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=369656&r1=369655&r2=369656&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Aug 22 07:53:45 2019
@@ -464,6 +464,16 @@ void ClangdLSPServer::onInitialize(const
if (!Params.capabilities.RenamePrepareSupport) // Only boolean allowed per LSP
RenameProvider = true;
+ // Per LSP, codeActionProvide can be either boolean or CodeActionOptions.
+ // CodeActionOptions is only valid if the client supports action literal
+ // via textDocument.codeAction.codeActionLiteralSupport.
+ llvm::json::Value CodeActionProvider = true;
+ if (Params.capabilities.CodeActionStructure)
+ CodeActionProvider = llvm::json::Object{
+ {"codeActionKinds",
+ {CodeAction::QUICKFIX_KIND, CodeAction::REFACTOR_KIND,
+ CodeAction::INFO_KIND}}};
+
llvm::json::Object Result{
{{"capabilities",
llvm::json::Object{
@@ -475,7 +485,7 @@ void ClangdLSPServer::onInitialize(const
{"firstTriggerCharacter", "\n"},
{"moreTriggerCharacter", {}},
}},
- {"codeActionProvider", true},
+ {"codeActionProvider", std::move(CodeActionProvider)},
{"completionProvider",
llvm::json::Object{
{"resolveProvider", false},
More information about the cfe-commits
mailing list