[PATCH] D81845: [clangd] Support typeHierarchy/resolve for children of parents as well

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 15 08:41:02 PDT 2020


nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/XRefs.cpp:1233
+  llvm::SmallString<32> USR;
+  if (!index::generateUSRForDecl(&ND, USR)) {
+    THI.data = SymbolID(USR).str();
----------------
nit: use getSymbolID from AST.h instead


The initial implementation of typeHierarchy/resolve only supported
cases where an initial request was made for children, and then
typeHierarchy/resolve was used to get additional levels of children.

However, a client may also want to make an initial request for
parents, and then show other children of those parents, so support
typeHierarchy/resolve for items returned in response to a request
for parents as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81845

Files:
  clang-tools-extra/clangd/XRefs.cpp


Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1225,6 +1225,15 @@
 
   THI.uri = URIForFile::canonicalize(*FilePath, *TUPath);
 
+  // Compute the SymbolID and store it in the 'data' field.
+  // This allows typeHierarchy/resolve to be used to
+  // resolve children of items returned in a previous request
+  // for parents.
+  llvm::SmallString<32> USR;
+  if (!index::generateUSRForDecl(&ND, USR)) {
+    THI.data = SymbolID(USR).str();
+  }
+
   return THI;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81845.270755.patch
Type: text/x-patch
Size: 612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200615/84516957/attachment.bin>


More information about the cfe-commits mailing list