summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clangd/JSONRPCDispatcher.cpp2
-rw-r--r--clang-tools-extra/test/clangd/unsupported-method.test19
2 files changed, 20 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/JSONRPCDispatcher.cpp b/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
index 2f38e9c1bb8..6641aae6a2f 100644
--- a/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
+++ b/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
@@ -42,7 +42,7 @@ void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
// 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) {
diff --git a/clang-tools-extra/test/clangd/unsupported-method.test b/clang-tools-extra/test/clangd/unsupported-method.test
new file mode 100644
index 00000000000..200bae08ba2
--- /dev/null
+++ b/clang-tools-extra/test/clangd/unsupported-method.test
@@ -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"}
OpenPOWER on IntegriCloud