[clang-tools-extra] [clangd][RFC] Add container field to remote index Refs grpc method (PR #71605)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 7 07:55:36 PST 2023
https://github.com/tdupes updated https://github.com/llvm/llvm-project/pull/71605
>From 2384f359e8ccb2dfe3fca61cc2703c3548c510f7 Mon Sep 17 00:00:00 2001
From: dup <dup at fb.com>
Date: Fri, 3 Nov 2023 09:03:24 -0700
Subject: [PATCH] Add container field to remote index Refs grpc method
---
clang-tools-extra/clangd/index/YAMLSerialization.cpp | 1 +
clang-tools-extra/clangd/index/remote/Index.proto | 1 +
.../clangd/index/remote/marshalling/Marshalling.cpp | 4 ++++
clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp | 2 +-
.../clangd/unittests/remote/MarshallingTests.cpp | 1 +
5 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang-tools-extra/clangd/index/YAMLSerialization.cpp b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
index 214a847b5eddb..495d8a2ff487a 100644
--- a/clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -319,6 +319,7 @@ template <> struct MappingTraits<Ref> {
MappingNormalization<NormalizedRefKind, RefKind> NKind(IO, R.Kind);
IO.mapRequired("Kind", NKind->Kind);
IO.mapRequired("Location", R.Location);
+ IO.mapOptional("Container", R.Container);
}
};
diff --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto
index 3072299d8f345..33bf095d88598 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -81,6 +81,7 @@ message Symbol {
message Ref {
optional SymbolLocation location = 1;
optional uint32 kind = 2;
+ optional string container = 3;
}
message SymbolInfo {
diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 7e31ada18a657..e9f0972ba91c3 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -189,6 +189,9 @@ llvm::Expected<clangd::Ref> Marshaller::fromProtobuf(const Ref &Message) {
return Location.takeError();
Result.Location = *Location;
Result.Kind = static_cast<RefKind>(Message.kind());
+ auto ContainerID = SymbolID::fromStr(Message.container());
+ if (ContainerID)
+ Result.Container = *ContainerID;
return Result;
}
@@ -296,6 +299,7 @@ llvm::Expected<Ref> Marshaller::toProtobuf(const clangd::Ref &From) {
if (!Location)
return Location.takeError();
*Result.mutable_location() = *Location;
+ Result.set_container(From.Container.str());
return Result;
}
diff --git a/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp b/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
index 9a58b5871bfce..956a7c231182f 100644
--- a/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
+++ b/clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
clang::clangd::elog("Can not convert response ({0}) to JSON ({1}): {2}\n",
Response.DebugString(),
static_cast<int>(JsonStatus.code()),
- JsonStatus.message().as_string());
+ JsonStatus.message());
return -1;
}
llvm::outs() << Output;
diff --git a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
index a2b31698a059a..85e79eae331bc 100644
--- a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -223,6 +223,7 @@ TEST(RemoteMarshallingTest, RefSerialization) {
Location.FileURI = testPathURI(
"llvm-project/llvm/clang-tools-extra/clangd/Protocol.h", Strings);
Ref.Location = Location;
+ Ref.Container = llvm::cantFail(SymbolID::fromStr("0000000000000001"));
Marshaller ProtobufMarshaller(testPath("llvm-project/"),
testPath("llvm-project/"));
More information about the cfe-commits
mailing list