diff options
Diffstat (limited to 'tests/auto/qmlls/utils/data/highlights')
11 files changed, 263 insertions, 0 deletions
diff --git a/tests/auto/qmlls/utils/data/highlights/Identifiers.qml b/tests/auto/qmlls/utils/data/highlights/Identifiers.qml new file mode 100644 index 0000000000..7725b6d5e4 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/Identifiers.qml @@ -0,0 +1,37 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + readonly property int test: 34 + signal pressed() + function f() { + let sum = 0, sum2 = 0 + for(let i = 1; i < 42; i = i + 2) { + sum = test + i + { + let sum = 42; // another unrelated sum + } + } + // signal and property changed + testChanged(); + pressed(); + } + + // attached + Keys.onPressed: { + } + + // propertychanged handler + onTestChanged: { + f(); // method identifier + } + + // signal handler + onPressed: {} + + enum K { Plus} + property int tt: Identifiers.Plus // component and enum value + +} 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/data/highlights/comments.qml b/tests/auto/qmlls/utils/data/highlights/comments.qml new file mode 100644 index 0000000000..351aaee36c --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/comments.qml @@ -0,0 +1,19 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +import QtQuick +Item { +/* + multiline comment +*/ + +/* single line comment */ +// another + + function inc() { + // in + + /* + inside js + */ + } +} diff --git a/tests/auto/qmlls/utils/data/highlights/enums.qml b/tests/auto/qmlls/utils/data/highlights/enums.qml new file mode 100644 index 0000000000..22183bf37f --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/enums.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + enum Osc { + Sin, + Saw = 1 + } +} diff --git a/tests/auto/qmlls/utils/data/highlights/imports.qml b/tests/auto/qmlls/utils/data/highlights/imports.qml new file mode 100644 index 0000000000..1e69077070 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/imports.qml @@ -0,0 +1,9 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQml 2.15 +import "X" as Patron + +Item { +} diff --git a/tests/auto/qmlls/utils/data/highlights/literals.qml b/tests/auto/qmlls/utils/data/highlights/literals.qml new file mode 100644 index 0000000000..520ed5d2ef --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/literals.qml @@ -0,0 +1,14 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + property int a: 123 + property string b: "single" + property string c: "multi + line string"; + property bool d: true + property var e: null + +} diff --git a/tests/auto/qmlls/utils/data/highlights/methodAndSignal.qml b/tests/auto/qmlls/utils/data/highlights/methodAndSignal.qml new file mode 100644 index 0000000000..4e8319f049 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/methodAndSignal.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + signal p() + signal q(int a) + signal r(a: int) + function a(b: int) : int {} +} diff --git a/tests/auto/qmlls/utils/data/highlights/objectAndComponent.qml b/tests/auto/qmlls/utils/data/highlights/objectAndComponent.qml new file mode 100644 index 0000000000..9165e4b1b5 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/objectAndComponent.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + component Patron: Item {} + Item { + id: inner + } +} diff --git a/tests/auto/qmlls/utils/data/highlights/pragmas.qml b/tests/auto/qmlls/utils/data/highlights/pragmas.qml new file mode 100644 index 0000000000..cf99c93584 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/pragmas.qml @@ -0,0 +1,10 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +pragma Singleton +pragma FunctionSignatureBehavior: Enforced +pragma ValueTypeBehavior: Copy,Addressable + +import QtQml + +QtObject {} diff --git a/tests/auto/qmlls/utils/data/highlights/properties.qml b/tests/auto/qmlls/utils/data/highlights/properties.qml new file mode 100644 index 0000000000..bde60915ca --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/properties.qml @@ -0,0 +1,13 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + Item { + property int k + readonly property int kk + required property int kkk + default property int kkkk + } +} diff --git a/tests/auto/qmlls/utils/data/highlights/scriptExpressions.qml b/tests/auto/qmlls/utils/data/highlights/scriptExpressions.qml new file mode 100644 index 0000000000..ee0b4ff5f8 --- /dev/null +++ b/tests/auto/qmlls/utils/data/highlights/scriptExpressions.qml @@ -0,0 +1,116 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function k() { + } + + function mafik() { + var patron = 34; + const upperLimit = 42; + do { + ++patron; + if (patron < 2) + continue; + else + ++patron; + } while (patron < upperLimit) + switch (patron) { + case 1: + return 23; + default: + break; + } + try { + {} + } catch (error) { + {} + } finally {} + for (const a in [1, 2, 3]) { + throw 2; + } + } + + enum Test { + LOG + } + + readonly property int t: 34 + signal tt + required property int k + + signal kkk(string a) + signal yyy(a: string) + + function ttt() { + + } + +function createComplexExpression(...objects) { + // Create an object that holds some data + let data = { + a: 5, + b: 10, + c: 3 + }; + + // Create a complex expression using the data object + let expression = ((data.a + data.b * data.c) / (data.a - data.b)) ** data.c; + + return expression; +} + + function set1() { + const array = [1,2,3,4]; + const [a, b] = [1,2]; + const [aa, , bb] = array; + const [aaa = 23, bbb] = array; + const [a1, b1, ...rest1] = array; + const [a2, , b2, ...rest2] = array; + const [a3, b3, ...{ pop, push }] = array; + const [a4, b4, ...[c, d]] = array; + + const obj = {_a:1,_b:2}; + const { a5, b5 } = obj; + const { a6: a_, b6: b1_ } = obj; + const { a7: a11 = 4, b11 = 34, c1: b111, d1 } = obj; + let key = a; + const { [key]: a___ } = obj; + } + + function set2(s : int) : int { + // declare first + let a, b, a1, b1, c, d, rest, pop, push; + const array = [1,2,3,4]; + [a, b] = array; + [a, , b] = array; + [a = aDefault, b] = array; + [a, b, ...rest] = array; + [a, , b, ...rest] = array; + [a, b, ...{ pop, push }] = array; + [a, b, ...[c, d]] = array; + + const obj = {_a:1,_b:2}; + ({ a, b } = obj); // brackets are required + ({ a: a1, b: b1 } = obj); + + const complicatedObject = { + a: 1, + b: { + c: 2, + d: { + e: 3, + f: [4, 5, 6] + } + }, + g: [7, 8, 9] + }; + + const { patron, b: { mafik, d: { e, f: [ , secondF, ...restF ] } }, g: [ firstG, ...restG ] } = complicatedObject; + } + + +} + |