diff --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto --- a/clang-tools-extra/clangd/index/remote/Index.proto +++ b/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 diff --git a/clang-tools-extra/clangd/index/remote/ProtocolVersion.h b/clang-tools-extra/clangd/index/remote/ProtocolVersion.h new file mode 100644 --- /dev/null +++ b/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 diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp --- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ b/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(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(From.Predicate));