[clang-tools-extra] r314119 - [clangd] Fix missing "message" key when responding with unsupported method
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 25 10:16:47 PDT 2017
Author: d0k
Date: Mon Sep 25 10:16:47 2017
New Revision: 314119
URL: http://llvm.org/viewvc/llvm-project?rev=314119&view=rev
Log:
[clangd] Fix missing "message" key when responding with unsupported method
The language server protocol dictates that a ResponseError should have a
[message string][1] describing the error. This adds a simple message to the
error and a simple test.
[1]: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#response-message
Patch by Raoul Wols!
Differential Revision: https://reviews.llvm.org/D38225
Added:
clang-tools-extra/trunk/test/clangd/unsupported-method.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=314119&r1=314118&r2=314119&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Sep 25 10:16:47 2017
@@ -42,7 +42,7 @@ void Handler::handleMethod(llvm::yaml::M
// Return that this method is unsupported.
writeMessage(
R"({"jsonrpc":"2.0","id":)" + ID +
- R"(,"error":{"code":-32601}})");
+ R"(,"error":{"code":-32601,"message":"method not found"}})");
}
void Handler::handleNotification(llvm::yaml::MappingNode *Params) {
Added: clang-tools-extra/trunk/test/clangd/unsupported-method.test
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/unsupported-method.test?rev=314119&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test (added)
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test Mon Sep 25 10:16:47 2017
@@ -0,0 +1,19 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":""}}}
+
+Content-Length: 92
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/jumpInTheAirLikeYouJustDontCare","params":{}}
+# CHECK: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"method not found"}}
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}
More information about the cfe-commits
mailing list