ClangCodeModel: Fix mis-detection of class members as operators

The name check was not tight enough.

Change-Id: I5d813a29525bd5b5c23ce04f0bd9e5982a36536e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-04-20 17:27:51 +02:00
parent 2529b62315
commit cf96a91b69
3 changed files with 28 additions and 3 deletions

View File

@@ -3839,10 +3839,18 @@ void ExtraHighlightingResultsCollector::collectFromNode(const AstNode &node)
QString detail = node.detail().value_or(QString());
const bool isCallToNew = node.kind() == "CXXNew";
const bool isCallToDelete = node.kind() == "CXXDelete";
if (!isCallToNew && !isCallToDelete
&& (!detail.startsWith(operatorPrefix) || detail == operatorPrefix)) {
const auto isProperOperator = [&] {
if (isCallToNew || isCallToDelete)
return true;
if (!detail.startsWith(operatorPrefix))
return false;
if (detail == operatorPrefix)
return false;
const QChar nextChar = detail.at(operatorPrefix.length());
return !nextChar.isLetterOrNumber() && nextChar != '_';
};
if (!isProperOperator())
return;
}
if (!isCallToNew && !isCallToDelete)
detail.remove(0, operatorPrefix.length());