[clang-tools-extra] [clangd] Support go-to-definition on type hints. The protocol part (PR #85497)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 25 00:33:12 PDT 2024


================
@@ -1483,9 +1483,18 @@ llvm::json::Value toJSON(const InlayHintKind &Kind) {
   llvm_unreachable("Unknown clang.clangd.InlayHintKind");
 }
 
+namespace {
+
+llvm::json::Array toJSON(const std::vector<InlayHintLabelPart> &Labels) {
+  return llvm::json::Array{
+      llvm::map_range(Labels, [](auto &Label) { return toJSON(Label); })};
+}
+
+} // namespace
+
 llvm::json::Value toJSON(const InlayHint &H) {
   llvm::json::Object Result{{"position", H.position},
-                            {"label", H.label},
+                            {"label", toJSON(H.label)},
----------------
HighCommander4 wrote:

Is this needed? Looking at the code for serializing other vectors in this file, the conversion to `llvm::json::Array` Just Works.

https://github.com/llvm/llvm-project/pull/85497


More information about the cfe-commits mailing list