forked from qt-creator/qt-creator
ClangCodeModel: Don't highlight streaming operator args as outputs
... with clangd. As with operator++ etc, it's immediately obvious to a developer which arguments are modified. Change-Id: Ia2b15d5eef7848b7ed284f8d544f039fe2927292 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -2706,8 +2706,9 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
||||
const AstNode n = firstChildTree.takeFirst();
|
||||
const QString detail = n.detail().value_or(QString());
|
||||
if (detail.startsWith("operator")) {
|
||||
return !detail.contains('=') && !detail.contains("++")
|
||||
&& !detail.contains("--");
|
||||
return !detail.contains('=')
|
||||
&& !detail.contains("++") && !detail.contains("--")
|
||||
&& !detail.contains("<<") && !detail.contains(">>");
|
||||
}
|
||||
firstChildTree << n.children().value_or(QList<AstNode>());
|
||||
}
|
||||
|
||||
@@ -1295,6 +1295,9 @@ void ClangdTestHighlighting::test_data()
|
||||
QTest::newRow("keywords: true") << 920 << 15 << 920 << 19 << QList<int>{C_KEYWORD} << 0;
|
||||
QTest::newRow("keywords: false") << 921 << 15 << 921 << 20 << QList<int>{C_KEYWORD} << 0;
|
||||
QTest::newRow("keywords: nullptr") << 922 << 15 << 922 << 22 << QList<int>{C_KEYWORD} << 0;
|
||||
QTest::newRow("operator<<") << 934 << 10 << 934 << 14 << QList<int>{C_GLOBAL} << 0;
|
||||
QTest::newRow("operator>>") << 936 << 10 << 936 << 13 << QList<int>{C_GLOBAL} << 0;
|
||||
QTest::newRow("operator>>") << 936 << 17 << 936 << 18 << QList<int>{C_LOCAL} << 0;
|
||||
}
|
||||
|
||||
void ClangdTestHighlighting::test()
|
||||
|
||||
@@ -921,3 +921,17 @@ void keywords()
|
||||
bool b2 = false;
|
||||
void *p = nullptr;
|
||||
}
|
||||
|
||||
namespace std {
|
||||
struct Debug {};
|
||||
Debug& operator<<(Debug &dbg, int) { return dbg; }
|
||||
Debug& operator>>(Debug &dbg, int&) { return dbg; }
|
||||
static Debug cout;
|
||||
static Debug cin;
|
||||
}
|
||||
void outputOperator()
|
||||
{
|
||||
std::cout << 0;
|
||||
int i;
|
||||
std::cin >> i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user