diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 1ee1fe3d514..f0637feb753 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -2821,8 +2821,11 @@ static void semanticHighlighter(QFutureInterface &future, } if (token.modifiers.contains(QLatin1String("declaration"))) styles.mixinStyles.push_back(C_DECLARATION); - if (token.modifiers.contains(QLatin1String("static"))) - styles.mixinStyles.push_back(C_STATIC_MEMBER); + if (token.modifiers.contains(QLatin1String("static"))) { + if (styles.mainStyle != C_FIELD && styles.mainStyle != C_TEXT) + styles.mixinStyles.push_back(styles.mainStyle); + styles.mainStyle = C_STATIC_MEMBER; + } if (isOutputParameter(token)) styles.mixinStyles.push_back(C_OUTPUT_ARGUMENT); qCDebug(clangdLogHighlight) << "adding highlighting result" diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp index dd5b95a63c7..b672dec291d 100644 --- a/src/plugins/clangcodemodel/test/clangdtests.cpp +++ b/src/plugins/clangcodemodel/test/clangdtests.cpp @@ -998,6 +998,10 @@ void ClangdTestHighlighting::test_data() << QList{C_PUNCTUATION} << int(CppEditor::SemanticHighlighter::AngleBracketOpen); QTest::newRow("class template instantiation (closing angle bracket)") << 384 << 22 << 384 << 23 << QList{C_PUNCTUATION} << int(CppEditor::SemanticHighlighter::AngleBracketClose); + QTest::newRow("static member function decl") << 395 << 17 << 395 << 30 + << QList{C_STATIC_MEMBER, C_DECLARATION, C_FUNCTION} << 0; + QTest::newRow("static member function call") << 400 << 17 << 400 << 30 + << QList{C_STATIC_MEMBER, C_FUNCTION} << 0; QTest::newRow("namespace in declaration") << 413 << 4 << 413 << 26 << QList{C_NAMESPACE} << 0; QTest::newRow("namespaced class in declaration") << 413 << 28 << 413 << 41 @@ -1122,9 +1126,9 @@ void ClangdTestHighlighting::test_data() QTest::newRow("local variable captured by lambda") << 442 << 24 << 442 << 27 << QList{C_LOCAL} << 0; QTest::newRow("static protected member") << 693 << 16 << 693 << 30 - << QList{C_FIELD, C_DECLARATION, C_STATIC_MEMBER} << 0; + << QList{C_STATIC_MEMBER, C_DECLARATION} << 0; QTest::newRow("static private member") << 696 << 16 << 696 << 28 - << QList{C_FIELD, C_DECLARATION, C_STATIC_MEMBER} << 0; + << QList{C_STATIC_MEMBER, C_DECLARATION} << 0; QTest::newRow("alias template declaration (opening angle bracket)") << 700 << 10 << 700 << 11 << QList{C_PUNCTUATION} << int(CppEditor::SemanticHighlighter::AngleBracketOpen); QTest::newRow("alias template declaration (closing angle bracket)") << 700 << 16 << 700 << 17