ClangCodeModel: Do not set C_ENUMERATION for enum declarations

... when highlighting with clangd.
This value is only meant for enum values, not types.

Task-number: QTCREATORBUG-27059
Change-Id: I7bb68f5deb6bb215ee3c23d995207019850a7bfc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-02-15 10:18:01 +01:00
parent 6414f22be7
commit dad534005e
2 changed files with 3 additions and 4 deletions

View File

@@ -2784,7 +2784,6 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
styles.mainStyle = C_FIELD; styles.mainStyle = C_FIELD;
} else if (token.type == "enum") { } else if (token.type == "enum") {
styles.mainStyle = C_TYPE; styles.mainStyle = C_TYPE;
styles.mixinStyles.push_back(C_ENUMERATION);
} else if (token.type == "enumMember") { } else if (token.type == "enumMember") {
styles.mainStyle = C_ENUMERATION; styles.mainStyle = C_ENUMERATION;
} else if (token.type == "parameter") { } else if (token.type == "parameter") {

View File

@@ -739,11 +739,11 @@ void ClangdTestHighlighting::test_data()
QTest::newRow("static member function call") << 114 << 15 << 114 << 27 QTest::newRow("static member function call") << 114 << 15 << 114 << 27
<< QList<int>{C_FUNCTION} << 0; << QList<int>{C_FUNCTION} << 0;
QTest::newRow("enum declaration") << 118 << 6 << 118 << 17 QTest::newRow("enum declaration") << 118 << 6 << 118 << 17
<< QList<int>{C_TYPE, C_ENUMERATION, C_DECLARATION} << 0; << QList<int>{C_TYPE, C_DECLARATION} << 0;
QTest::newRow("enumerator declaration") << 120 << 5 << 120 << 15 QTest::newRow("enumerator declaration") << 120 << 5 << 120 << 15
<< QList<int>{C_ENUMERATION, C_DECLARATION} << 0; << QList<int>{C_ENUMERATION, C_DECLARATION} << 0;
QTest::newRow("enum in variable declaration") << 125 << 5 << 125 << 16 QTest::newRow("enum in variable declaration") << 125 << 5 << 125 << 16
<< QList<int>{C_TYPE, C_ENUMERATION} << 0; << QList<int>{C_TYPE} << 0;
QTest::newRow("enum variable declaration") << 125 << 17 << 125 << 28 QTest::newRow("enum variable declaration") << 125 << 17 << 125 << 28
<< QList<int>{C_LOCAL, C_DECLARATION} << 0; << QList<int>{C_LOCAL, C_DECLARATION} << 0;
QTest::newRow("enum variable reference") << 127 << 5 << 127 << 16 << QList<int>{C_LOCAL} << 0; QTest::newRow("enum variable reference") << 127 << 5 << 127 << 16 << QList<int>{C_LOCAL} << 0;
@@ -961,7 +961,7 @@ void ClangdTestHighlighting::test_data()
<< 310 << 29 << 310 << 38 << 310 << 29 << 310 << 38
<< QList<int>{C_FIELD} << 0; << QList<int>{C_FIELD} << 0;
QTest::newRow("enum declaration with underlying type") << 316 << 6 << 316 << 21 QTest::newRow("enum declaration with underlying type") << 316 << 6 << 316 << 21
<< QList<int>{C_TYPE, C_ENUMERATION, C_DECLARATION} << 0; << QList<int>{C_TYPE, C_DECLARATION} << 0;
QTest::newRow("type in static_cast") << 328 << 23 << 328 << 33 QTest::newRow("type in static_cast") << 328 << 23 << 328 << 33
<< QList<int>{C_TYPE} << 0; << QList<int>{C_TYPE} << 0;
QTest::newRow("opening angle bracket in static_cast") << 328 << 16 << 328 << 17 QTest::newRow("opening angle bracket in static_cast") << 328 << 16 << 328 << 17