forked from qt-creator/qt-creator
ClangCodeModel: Classify Q_PROPERTY functions as Qt-invokable
Fixes: QTCREATORBUG-28971 Change-Id: Ia60a82aa83ad89fbf6b5d1332d413de029510b34 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -172,6 +172,20 @@ bool ClangdAstNode::hasChildWithRole(const QString &role) const
|
|||||||
[&role](const ClangdAstNode &c) { return c.role() == role; });
|
[&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
|
QString ClangdAstNode::operatorString() const
|
||||||
{
|
{
|
||||||
if (kind() == "BinaryOperator")
|
if (kind() == "BinaryOperator")
|
||||||
|
@@ -77,6 +77,7 @@ public:
|
|||||||
|
|
||||||
bool childContainsRange(int index, const LanguageServerProtocol::Range &range) const;
|
bool childContainsRange(int index, const LanguageServerProtocol::Range &range) const;
|
||||||
bool hasChildWithRole(const QString &role) const;
|
bool hasChildWithRole(const QString &role) const;
|
||||||
|
bool hasChild(const std::function<bool(const ClangdAstNode &child)> &predicate, bool recursive) const;
|
||||||
QString operatorString() const;
|
QString operatorString() const;
|
||||||
|
|
||||||
enum class FileStatus { Ours, Foreign, Mixed, Unknown };
|
enum class FileStatus { Ours, Foreign, Mixed, Unknown };
|
||||||
|
@@ -595,6 +595,19 @@ static Usage::Tags getUsageType(const ClangdAstPath &path, const QString &search
|
|||||||
tags |= Usage::Tag::Operator;
|
tags |= Usage::Tag::Operator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pathIt->kind() == "CXXMethod") {
|
||||||
|
const ClangdAstNode &classNode = *std::next(pathIt);
|
||||||
|
if (classNode.hasChild([&](const ClangdAstNode &n) {
|
||||||
|
if (n.kind() != "StaticAssert")
|
||||||
|
return false;
|
||||||
|
return n.hasChild([&](const ClangdAstNode &n) {
|
||||||
|
return n.arcanaContains("Q_PROPERTY"); }, true)
|
||||||
|
&& n.hasChild([&](const ClangdAstNode &n) {
|
||||||
|
return n.arcanaContains(" " + searchTerm); }, true);
|
||||||
|
}, false)) {
|
||||||
|
tags |= Usage::Tag::MocInvokable;
|
||||||
|
}
|
||||||
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
if (pathIt->kind() == "MemberInitializer")
|
if (pathIt->kind() == "MemberInitializer")
|
||||||
|
Reference in New Issue
Block a user