[clang-tools-extra] r352624 - [clangd] Drop fixes if replying with tweaks resulted in an error
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 30 06:24:17 PST 2019
Author: ibiryukov
Date: Wed Jan 30 06:24:17 2019
New Revision: 352624
URL: http://llvm.org/viewvc/llvm-project?rev=352624&view=rev
Log:
[clangd] Drop fixes if replying with tweaks resulted in an error
This should not happen in normal operation, as it implies that the diagnostics
with some available fixes were produced but the AST is invalid.
Moreover, the code had an error: always returned code actions ignoring the
SupportsCodeAction capability and writing a test for this is impossible,
since this can only happen due to programmer's error rather than invalid inputs.
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/test/clangd/fixits-codeaction.test
Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=352624&r1=352623&r2=352624&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Jan 30 06:24:17 2019
@@ -672,14 +672,8 @@ void ClangdLSPServer::onCodeAction(const
[this](decltype(Reply) Reply, URIForFile File, std::string Code,
Range Selection, std::vector<CodeAction> FixIts,
llvm::Expected<std::vector<ClangdServer::TweakRef>> Tweaks) {
- if (!Tweaks) {
- auto Err = Tweaks.takeError();
- if (Err.isA<CancelledError>())
- return Reply(std::move(Err)); // do no logging, this is expected.
- elog("error while getting semantic code actions: {0}",
- std::move(Err));
- return Reply(llvm::json::Array(FixIts));
- }
+ if (!Tweaks)
+ return Reply(Tweaks.takeError());
std::vector<CodeAction> Actions = std::move(FixIts);
Actions.reserve(Actions.size() + Tweaks->size());
Modified: clang-tools-extra/trunk/test/clangd/fixits-codeaction.test
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/fixits-codeaction.test?rev=352624&r1=352623&r2=352624&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clangd/fixits-codeaction.test (original)
+++ clang-tools-extra/trunk/test/clangd/fixits-codeaction.test Wed Jan 30 06:24:17 2019
@@ -23,7 +23,7 @@
# CHECK-NEXT: "uri": "file://{{.*}}/foo.c"
# CHECK-NEXT: }
---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}}
# CHECK: "id": 2,
# CHECK-NEXT: "jsonrpc": "2.0",
# CHECK-NEXT: "result": [
More information about the cfe-commits
mailing list