[PATCH] D89862: [clangd] Give the server information about client's remote index protocol version

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 02:55:35 PDT 2020


kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89862

Files:
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/ProtocolVersion.h
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp


Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -16,6 +16,7 @@
 #include "index/SymbolID.h"
 #include "index/SymbolLocation.h"
 #include "index/SymbolOrigin.h"
+#include "index/remote/ProtocolVersion.h"
 #include "support/Logger.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/DenseSet.h"
@@ -196,6 +197,7 @@
 
 LookupRequest Marshaller::toProtobuf(const clangd::LookupRequest &From) {
   LookupRequest RPCRequest;
+  RPCRequest.set_client_version(RemoteIndexProtocolVersion);
   for (const auto &SymbolID : From.IDs)
     RPCRequest.add_ids(SymbolID.str());
   return RPCRequest;
@@ -204,6 +206,7 @@
 FuzzyFindRequest Marshaller::toProtobuf(const clangd::FuzzyFindRequest &From) {
   assert(LocalIndexRoot);
   FuzzyFindRequest RPCRequest;
+  RPCRequest.set_client_version(RemoteIndexProtocolVersion);
   RPCRequest.set_query(From.Query);
   for (const auto &Scope : From.Scopes)
     RPCRequest.add_scopes(Scope);
@@ -224,6 +227,7 @@
 
 RefsRequest Marshaller::toProtobuf(const clangd::RefsRequest &From) {
   RefsRequest RPCRequest;
+  RPCRequest.set_client_version(RemoteIndexProtocolVersion);
   for (const auto &ID : From.IDs)
     RPCRequest.add_ids(ID.str());
   RPCRequest.set_filter(static_cast<uint32_t>(From.Filter));
@@ -234,6 +238,7 @@
 
 RelationsRequest Marshaller::toProtobuf(const clangd::RelationsRequest &From) {
   RelationsRequest RPCRequest;
+  RPCRequest.set_client_version(RemoteIndexProtocolVersion);
   for (const auto &ID : From.Subjects)
     RPCRequest.add_subjects(ID.str());
   RPCRequest.set_predicate(static_cast<uint32_t>(From.Predicate));
Index: clang-tools-extra/clangd/index/remote/ProtocolVersion.h
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/ProtocolVersion.h
@@ -0,0 +1,7 @@
+namespace clang {
+namespace clangd {
+namespace remote {
+static const char *RemoteIndexProtocolVersion = "0.1.0";
+}
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/index/remote/Index.proto
===================================================================
--- clang-tools-extra/clangd/index/remote/Index.proto
+++ clang-tools-extra/clangd/index/remote/Index.proto
@@ -22,7 +22,10 @@
   rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
 }
 
-message LookupRequest { repeated string ids = 1; }
+message LookupRequest {
+  repeated string ids = 1;
+  string client_version = 2;
+}
 
 // The response is a stream of symbol messages and the terminating message
 // indicating the end of stream.
@@ -41,6 +44,7 @@
   bool restricted_for_code_completion = 5;
   repeated string proximity_paths = 6;
   repeated string preferred_types = 7;
+  string client_version = 8;
 }
 
 // The response is a stream of symbol messages, and one terminating has_more
@@ -56,6 +60,7 @@
   repeated string ids = 1;
   uint32 filter = 2;
   uint32 limit = 3;
+  string client_version = 4;
 }
 
 // The response is a stream of reference messages, and one terminating has_more
@@ -121,6 +126,7 @@
   repeated string subjects = 1;
   uint32 predicate = 2;
   uint32 limit = 3;
+  string client_version = 4;
 }
 
 // The response is a stream of reference messages, and one terminating has_more


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89862.299617.patch
Type: text/x-patch
Size: 3462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201021/7a1808bb/attachment.bin>


More information about the cfe-commits mailing list