[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

Eduardo Caldas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 02:57:08 PDT 2020


eduucaldas added inline comments.


================
Comment at: clang/include/clang/Tooling/Syntax/Tree.h:172-174
   /// Find the first node with a corresponding role.
   Node *findChild(NodeRole R);
+  const Node *findChild(NodeRole R) const;
----------------
I think that makes sense, since all the functions used by `findChild` are public anyways.

WDYT Dmitri? Now that the API is being used I realize its surface ^^. Perhaps we should pour some thought into that in the future :) 



================
Comment at: clang/lib/Tooling/Syntax/Tree.cpp:304-308
+  for (const auto *C = FirstChild; C; C = C->getNextSibling()) {
+    if (C->getRole() == R)
+      return C;
+  }
+  return nullptr;
----------------
Similarly to the const version of `findFirstLeaf`. I think this should work :)

Also you could put the definition in `clang/Tooling/Syntax/Tree.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553



More information about the cfe-commits mailing list