diff options
author | Semih Yavuz <semih.yavuz@qt.io> | 2024-04-23 19:10:59 +0200 |
---|---|---|
committer | Semih Yavuz <semih.yavuz@qt.io> | 2024-05-07 13:35:09 +0200 |
commit | 3cec6634807de644d6760e8bd0f4368e4653f9a3 (patch) | |
tree | 45a8350cda6a6db303cdd2f69ca469ebfa6945d4 /tests | |
parent | 592a830d0cee0a92148ebb4d0a3ae522f1f5b300 (diff) |
semantichighlighting: add highlights for bindings
Bindings can be written either x:y or Behavior on x{} syntax. If binding
identifier contains dot in its name, defer the highlighting operation to
be handled when ScriptExpressionIdentifier is visited.
Task-number: QTBUG-120000
Change-Id: I405ea42efe128817ff56f6d9c17c65a0ec6fe868
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qmlls/utils/data/highlights/bindings.qml | 12 | ||||
-rw-r--r-- | tests/auto/qmlls/utils/tst_qmlls_highlighting.cpp | 16 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qmlls/utils/data/highlights/bindings.qml b/tests/auto/qmlls/utils/data/highlights/bindings.qml new file mode 100644 index 0000000000..ac1592e778 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/bindings.qml @@ -0,0 +1,12 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + property int x: 45 + + Behavior on width {} + + x: width +} diff --git a/tests/auto/qmlls/utils/tst_qmlls_highlighting.cpp b/tests/auto/qmlls/utils/tst_qmlls_highlighting.cpp index 5ee3d1720d..2fda00127d 100644 --- a/tests/auto/qmlls/utils/tst_qmlls_highlighting.cpp +++ b/tests/auto/qmlls/utils/tst_qmlls_highlighting.cpp @@ -217,6 +217,22 @@ void tst_qmlls_highlighting::highlights_data() << Token(QQmlJS::SourceLocation(159, 6, 6, 15), int(SemanticTokenTypes::Namespace), 0); } + { // Bindings + const auto filePath = m_highlightingDataDir + "/bindings.qml"; + const auto fileItem = fileObject(filePath); + + // normal binding + QTest::addRow("normalBinding") << fileItem + << Token(QQmlJS::SourceLocation(189, 1, 11, 5), + int(SemanticTokenTypes::Property), 0); + // on binding + QTest::addRow("on-binding") << fileItem + << Token(QQmlJS::SourceLocation(175, 5, 9, 17), + int(SemanticTokenTypes::Property), 0); + QTest::addRow("on-keyword") << fileItem + << Token(QQmlJS::SourceLocation(172, 2, 9, 14), + int(SemanticTokenTypes::Keyword), 0); + } } void tst_qmlls_highlighting::highlights() |