[PATCH] D124344: [clangd] Output inlay hints with `clangd --check`

Tobias Ribizel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 24 22:53:49 PDT 2022


upsj updated this revision to Diff 424816.
upsj added a comment.

Output InlayHintKind and improve comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124344/new/

https://reviews.llvm.org/D124344

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===================================================================
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -192,7 +192,7 @@
     return true;
   }
 
-  // Build Inlay Hints for the entire AST
+  // Build Inlay Hints for the entire AST or the specified range
   bool buildInlayHints(llvm::Optional<Range> LineRange) {
     log("Building inlay hints");
     auto Hints = inlayHints(*AST, LineRange);
Index: clang-tools-extra/clangd/Protocol.h
===================================================================
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1576,6 +1576,7 @@
   /// naturally when placed inline with the code.
   std::string label;
 };
+const char* toString(InlayHintKind);
 llvm::json::Value toJSON(const InlayHint &);
 bool operator==(const InlayHint &, const InlayHint &);
 bool operator<(const InlayHint &, const InlayHint &);
Index: clang-tools-extra/clangd/Protocol.cpp
===================================================================
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1316,7 +1316,7 @@
   return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
 }
 
-llvm::json::Value toJSON(InlayHintKind K) {
+const char* toString(InlayHintKind K){
   switch (K) {
   case InlayHintKind::ParameterHint:
     return "parameter";
@@ -1328,6 +1328,10 @@
   llvm_unreachable("Unknown clang.clangd.InlayHintKind");
 }
 
+llvm::json::Value toJSON(InlayHintKind K) {
+  return toString(K);
+}
+
 llvm::json::Value toJSON(const InlayHint &H) {
   return llvm::json::Object{{"position", H.position},
                             {"range", H.range},


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124344.424816.patch
Type: text/x-patch
Size: 1763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220425/b09b5255/attachment-0001.bin>


More information about the cfe-commits mailing list