Skip to content

Commit 4282c39

Browse files
committed
Add container field to remote index Refs grpc method
1 parent f6ca0ed commit 4282c39

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

clang-tools-extra/clangd/index/YAMLSerialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ template <> struct MappingTraits<Ref> {
319319
MappingNormalization<NormalizedRefKind, RefKind> NKind(IO, R.Kind);
320320
IO.mapRequired("Kind", NKind->Kind);
321321
IO.mapRequired("Location", R.Location);
322+
IO.mapOptional("Container", R.Container);
322323
}
323324
};
324325

clang-tools-extra/clangd/index/remote/Index.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ message Symbol {
8181
message Ref {
8282
optional SymbolLocation location = 1;
8383
optional uint32 kind = 2;
84+
optional string container = 3;
8485
}
8586

8687
message SymbolInfo {

clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ llvm::Expected<clangd::Ref> Marshaller::fromProtobuf(const Ref &Message) {
189189
return Location.takeError();
190190
Result.Location = *Location;
191191
Result.Kind = static_cast<RefKind>(Message.kind());
192+
auto ContainerID = SymbolID::fromStr(Message.container());
193+
if (ContainerID)
194+
Result.Container = *ContainerID;
192195
return Result;
193196
}
194197

@@ -296,6 +299,7 @@ llvm::Expected<Ref> Marshaller::toProtobuf(const clangd::Ref &From) {
296299
if (!Location)
297300
return Location.takeError();
298301
*Result.mutable_location() = *Location;
302+
Result.set_container(From.Container.str());
299303
return Result;
300304
}
301305

clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ TEST(RemoteMarshallingTest, RefSerialization) {
223223
Location.FileURI = testPathURI(
224224
"llvm-project/llvm/clang-tools-extra/clangd/Protocol.h", Strings);
225225
Ref.Location = Location;
226+
Ref.Container = llvm::cantFail(SymbolID::fromStr("0000000000000001"));
226227

227228
Marshaller ProtobufMarshaller(testPath("llvm-project/"),
228229
testPath("llvm-project/"));

0 commit comments

Comments
 (0)