ClangCodeModel: Highlight "override" and "final" with clangd

Change-Id: If30de546ce360ab9bc3cfa2780f61d6a78e4191d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-27 12:31:12 +02:00
parent 0aa3cc45b5
commit b35630c03d
2 changed files with 10 additions and 0 deletions

View File

@@ -1968,6 +1968,14 @@ static void collectExtraResults(QFutureInterface<TextEditor::HighlightingResult>
insert(result); insert(result);
continue; continue;
} }
if (node.role() == "attribute" && (node.kind() == "Override" || node.kind() == "Final")) {
TextEditor::HighlightingResult result;
result.useTextSyles = true;
result.textStyles.mainStyle = TextEditor::C_KEYWORD;
setFromRange(result, node.range());
insert(result);
continue;
}
const bool isExpression = node.role() == "expression"; const bool isExpression = node.role() == "expression";
const bool isDeclaration = node.role() == "declaration"; const bool isDeclaration = node.role() == "declaration";

View File

@@ -1236,6 +1236,8 @@ void ClangdTestHighlighting::test_data()
<< QList<int>{C_LOCAL} << 0; << QList<int>{C_LOCAL} << 0;
QTest::newRow("static function call (argument)") << 819 << 18 << 819 << 19 QTest::newRow("static function call (argument)") << 819 << 18 << 819 << 19
<< QList<int>{C_LOCAL, C_OUTPUT_ARGUMENT} << 0; << QList<int>{C_LOCAL, C_OUTPUT_ARGUMENT} << 0;
QTest::newRow("override attribute") << 186 << 28 << 186 << 36 << QList<int>{C_KEYWORD} << 0;
QTest::newRow("final attribute") << 187 << 33 << 187 << 38 << QList<int>{C_KEYWORD} << 0;
} }
void ClangdTestHighlighting::test() void ClangdTestHighlighting::test()