diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2022-02-22 14:17:31 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2022-02-23 10:53:52 +0000 |
commit | 7b82b55b73f7c788bf8cb48a30b032a42cf93bcb (patch) | |
tree | e48a9a97481d3e8e949d4bf5a1e10b109363c780 | |
parent | 08d1f30d4a9d6fd42c18bef95c6990a749604d2f (diff) |
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>
-rw-r--r-- | src/plugins/clangcodemodel/clangdclient.cpp | 5 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/test/clangdtests.cpp | 3 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp | 14 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index effe6a1f76..d0a54042df 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -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>()); } diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp index d03fcc2c89..6efddf7c20 100644 --- a/src/plugins/clangcodemodel/test/clangdtests.cpp +++ b/src/plugins/clangcodemodel/test/clangdtests.cpp @@ -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() diff --git a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp index c54dfe1371..40a4ef23b4 100644 --- a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp +++ b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp @@ -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; +} |