diff options
Diffstat (limited to 'src/plugins/clangcodemodel/clangdast.cpp')
-rw-r--r-- | src/plugins/clangcodemodel/clangdast.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/clangcodemodel/clangdast.cpp b/src/plugins/clangcodemodel/clangdast.cpp index 6b97146dd5..01f12d1177 100644 --- a/src/plugins/clangcodemodel/clangdast.cpp +++ b/src/plugins/clangcodemodel/clangdast.cpp @@ -172,6 +172,20 @@ bool ClangdAstNode::hasChildWithRole(const QString &role) const [&role](const ClangdAstNode &c) { return c.role() == role; }); } +bool ClangdAstNode::hasChild(const std::function<bool(const ClangdAstNode &)> &predicate, + bool recursive) const +{ + std::function<bool(const ClangdAstNode &)> fullPredicate = predicate; + if (recursive) { + fullPredicate = [&predicate](const ClangdAstNode &n) { + if (predicate(n)) + return true; + return n.hasChild(predicate, true); + }; + } + return Utils::contains(children().value_or(QList<ClangdAstNode>()), fullPredicate); +} + QString ClangdAstNode::operatorString() const { if (kind() == "BinaryOperator") |