Author: sammccall Date: Tue Jun 18 04:57:26 2019 New Revision: 363664 URL: http://llvm.org/viewvc/llvm-project?rev=363664&view=rev Log: [clangd] Add a capability to enable completions with fixes.
Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63091 Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=363664&r1=363663&r2=363664&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jun 18 04:57:26 2019 @@ -337,6 +337,7 @@ void ClangdLSPServer::onInitialize(const applyConfiguration(Params.initializationOptions.ConfigSettings); CCOpts.EnableSnippets = Params.capabilities.CompletionSnippets; + CCOpts.IncludeFixIts = Params.capabilities.CompletionFixes; DiagOpts.EmbedFixesInDiagnostics = Params.capabilities.DiagnosticFixes; DiagOpts.SendDiagnosticCategory = Params.capabilities.DiagnosticCategory; DiagOpts.EmitRelatedLocations = Modified: clang-tools-extra/trunk/clangd/Protocol.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=363664&r1=363663&r2=363664&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Protocol.cpp (original) +++ clang-tools-extra/trunk/clangd/Protocol.cpp Tue Jun 18 04:57:26 2019 @@ -293,6 +293,8 @@ bool fromJSON(const llvm::json::Value &P return false; } } + if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor")) + R.CompletionFixes = *EditsNearCursor; } if (auto *CodeAction = TextDocument->getObject("codeAction")) { if (CodeAction->getObject("codeActionLiteralSupport")) Modified: clang-tools-extra/trunk/clangd/Protocol.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=363664&r1=363663&r2=363664&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Protocol.h (original) +++ clang-tools-extra/trunk/clangd/Protocol.h Tue Jun 18 04:57:26 2019 @@ -387,6 +387,11 @@ struct ClientCapabilities { /// textDocument.completion.completionItem.snippetSupport bool CompletionSnippets = false; + /// Client supports completions with additionalTextEdit near the cursor. + /// This is a clangd extension. (LSP says this is for unrelated text only). + /// textDocument.completion.editsNearCursor + bool CompletionFixes = false; + /// Client supports hierarchical document symbols. bool HierarchicalDocumentSymbol = false; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits