diff options
Diffstat (limited to 'tests/auto/qmlls/modules/data')
29 files changed, 698 insertions, 0 deletions
diff --git a/tests/auto/qmlls/modules/data/buildDir/BuildDir/BuildDirType.qml b/tests/auto/qmlls/modules/data/buildDir/BuildDir/BuildDirType.qml new file mode 100644 index 0000000000..416ec33253 --- /dev/null +++ b/tests/auto/qmlls/modules/data/buildDir/BuildDir/BuildDirType.qml @@ -0,0 +1,7 @@ +import QtQuick + +Rectangle { + color: "red" + + function blabla() {} +} diff --git a/tests/auto/qmlls/modules/data/buildDir/BuildDir/qmldir b/tests/auto/qmlls/modules/data/buildDir/BuildDir/qmldir new file mode 100644 index 0000000000..df2320f1f0 --- /dev/null +++ b/tests/auto/qmlls/modules/data/buildDir/BuildDir/qmldir @@ -0,0 +1,3 @@ +module BuildDir +BuildDirType 1.0 BuildDirType.qml +import QtQuick.Controls.Basic diff --git a/tests/auto/qmlls/modules/data/completions/SomeBase.qml b/tests/auto/qmlls/modules/data/completions/SomeBase.qml new file mode 100644 index 0000000000..9c36e13c5b --- /dev/null +++ b/tests/auto/qmlls/modules/data/completions/SomeBase.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/tests/auto/qmlls/modules/data/completions/Yyy.qml b/tests/auto/qmlls/modules/data/completions/Yyy.qml new file mode 100644 index 0000000000..9ac6f9968d --- /dev/null +++ b/tests/auto/qmlls/modules/data/completions/Yyy.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 +import QtQuick as QQ + +Zzz { + id: root + width: height + Rectangle { + color: "green" + anchors.fill: parent + width: root.height + height: root.foo.height + + } + + function lala() {} + property Rectangle foo: Rectangle{ height: 200 } + function longfunction(a, b, c = "c", d = "d"): string { + return "hehe: " + c + d + } + + // documentedFunction: is documented + // returns 'Good' + function documentedFunction(arg1, arg2 = "Qt"): string { + return "Good" + } + QQ.Rectangle { + color:"red" + } + + component IC: Zzz { property SomeBase data } + property SomeBase mySomeBase +} diff --git a/tests/auto/qmlls/modules/data/completions/Zzz.qml b/tests/auto/qmlls/modules/data/completions/Zzz.qml new file mode 100644 index 0000000000..165ea46394 --- /dev/null +++ b/tests/auto/qmlls/modules/data/completions/Zzz.qml @@ -0,0 +1,10 @@ +import QtQuick 2.11 + +Item { + id: zzz + height: 333 + + Rectangle { + width: zzz.height + } +} diff --git a/tests/auto/qmlls/modules/data/completions/bindingAfterDot.qml b/tests/auto/qmlls/modules/data/completions/bindingAfterDot.qml new file mode 100644 index 0000000000..2a8694342b --- /dev/null +++ b/tests/auto/qmlls/modules/data/completions/bindingAfterDot.qml @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +QtObject { + id: root + property int good + property var i: Item { + property int bad + property int myP: root. + Item { } + } +} diff --git a/tests/auto/qmlls/modules/data/completions/defaultBindingAfterDot.qml b/tests/auto/qmlls/modules/data/completions/defaultBindingAfterDot.qml new file mode 100644 index 0000000000..4cf47b6f31 --- /dev/null +++ b/tests/auto/qmlls/modules/data/completions/defaultBindingAfterDot.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 + +QtObject { + id: root + property int good + property var i: Item { + property int bad + property int myP2: root. + bad: 43 + } +} diff --git a/tests/auto/qmlls/modules/data/completions/fromBuildDir.qml b/tests/auto/qmlls/modules/data/completions/fromBuildDir.qml new file mode 100644 index 0000000000..2c35f5b864 --- /dev/null +++ b/tests/auto/qmlls/modules/data/completions/fromBuildDir.qml @@ -0,0 +1,10 @@ +import BuildDir +import QtQuick +BuildDirType { + Rectangle { + color: "green" + width: 250 + height: 10 + } + Button {} +} diff --git a/tests/auto/qmlls/modules/data/findDefinition/jsDefinitions.qml b/tests/auto/qmlls/modules/data/findDefinition/jsDefinitions.qml new file mode 100644 index 0000000000..3243030466 --- /dev/null +++ b/tests/auto/qmlls/modules/data/findDefinition/jsDefinitions.qml @@ -0,0 +1,17 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick 2.15 + +Item { + id: rootId + + property int i // (1) + function f(a /*(2)*/ , b) {return a /* go to definition on a leads to (2) */ > b} // (4) + + Component.onCompleted: { + let x = 42 // (3) + f(x, i) // goto definition on f goes to 4, on x goes to (3) and on i goes to (1) + f(x, rootId.i) // goto definition on f goes to 4, on x goes to (3) and on i goes to (1) + } +} diff --git a/tests/auto/qmlls/modules/data/findUsages/jsIdentifierUsages.qml b/tests/auto/qmlls/modules/data/findUsages/jsIdentifierUsages.qml new file mode 100644 index 0000000000..6c099edc9e --- /dev/null +++ b/tests/auto/qmlls/modules/data/findUsages/jsIdentifierUsages.qml @@ -0,0 +1,13 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function f() { + let sum = 0, sum2 = 0 + for(let i = 1; i < 42; i = i + 2) { + sum = sum + i + } + } +} diff --git a/tests/auto/qmlls/modules/data/formatting/blanklines.formatted.qml b/tests/auto/qmlls/modules/data/formatting/blanklines.formatted.qml new file mode 100644 index 0000000000..19548e9023 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/blanklines.formatted.qml @@ -0,0 +1,4 @@ +// leading and trailing spaces +import QtQuick + +Item {} diff --git a/tests/auto/qmlls/modules/data/formatting/blanklines.qml b/tests/auto/qmlls/modules/data/formatting/blanklines.qml new file mode 100644 index 0000000000..ae1a14daed --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/blanklines.qml @@ -0,0 +1,15 @@ + + + + +// leading and trailing spaces +import QtQuick + + +Item { + + + } + + + diff --git a/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted1.qml b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted1.qml new file mode 100644 index 0000000000..e167f829b2 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted1.qml @@ -0,0 +1,23 @@ +pragma Strict + +import QtQuick + +Item { + property var test: [{ + // Testing + "foo": "bar" + }] + + Item { + + function test() { +var patron = "๐test๐"; + let kivrik = 1; + + + + + const yumyum = 1; + } + } +} diff --git a/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted2.qml b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted2.qml new file mode 100644 index 0000000000..ebd68dbde2 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted2.qml @@ -0,0 +1,20 @@ +pragma Strict + +import QtQuick + +Item { + property var test: [{ +// Testing + "foo": "bar" +}] + + Item { + + function test() { + var patron = "๐test๐"; + let kivrik = 1; + + const yumyum = 1; + } + } +} diff --git a/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted3.qml b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted3.qml new file mode 100644 index 0000000000..83f91c6af5 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted3.qml @@ -0,0 +1,23 @@ +pragma Strict + +import QtQuick + +Item { + property var test: [{ +// Testing + "foo": "bar" +}] + + Item { + + function test() { +var patron = "๐test๐"; + let kivrik = 1; + + + + + const yumyum = 1; + } + } +} diff --git a/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted4.qml b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted4.qml new file mode 100644 index 0000000000..d6d7227588 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted4.qml @@ -0,0 +1,20 @@ +pragma Strict + +import QtQuick + +Item { + property var test: [{ + // Testing + "foo": "bar" + }] + + Item { + + function test() { + var patron = "๐test๐"; + let kivrik = 1; + + const yumyum = 1; + } + } +} diff --git a/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted5.qml b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted5.qml new file mode 100644 index 0000000000..8b3ddf8df1 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.formatted5.qml @@ -0,0 +1,20 @@ +pragma Strict + +import QtQuick + +Item { + property var test: [{ +// Testing + "foo": "bar" +}] + + Item { + + function test() { + var patron = "๐test๐"; + let kivrik = 1; + + const yumyum = 1; + } + } +} diff --git a/tests/auto/qmlls/modules/data/formatting/rangeFormatting.qml b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.qml new file mode 100644 index 0000000000..1431fb10c3 --- /dev/null +++ b/tests/auto/qmlls/modules/data/formatting/rangeFormatting.qml @@ -0,0 +1,23 @@ +pragma Strict + +import QtQuick + +Item { + property var test: [{ +// Testing + "foo": "bar" +}] + + Item { + + function test() { +var patron = "๐test๐"; + let kivrik = 1; + + + + + const yumyum = 1; + } + } +} diff --git a/tests/auto/qmlls/modules/data/highlighting/basic.qml b/tests/auto/qmlls/modules/data/highlighting/basic.qml new file mode 100644 index 0000000000..264f553b22 --- /dev/null +++ b/tests/auto/qmlls/modules/data/highlighting/basic.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 { + id: rootId + function a() { + + } +} diff --git a/tests/auto/qmlls/modules/data/highlighting/bigFile.qml b/tests/auto/qmlls/modules/data/highlighting/bigFile.qml new file mode 100644 index 0000000000..9832e8e98a --- /dev/null +++ b/tests/auto/qmlls/modules/data/highlighting/bigFile.qml @@ -0,0 +1,351 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + id: rootId + function f() { + let sum = 0, sum2 = 0; + for (let i = 1; i < 42; i = i + 2) { + sum = sum + i; + { + let sum = 42; // another unrelated sum + } + } + } + + readonly property int helloProperty: 0 + property int p2: 1 + + function withProperty() { + let sum = 0, sum2 = 0; + for (const i = 1; i < 42; i = i + 2) { + sum = sum + i; + helloProperty = helloProperty + sum - i * p2; + { + let helloProperty = "evil"; + } + } + } + Item { + function f() { + return helloProperty + p2; + } + property string helloProperty + } + component IC: Item { + property var helloProperty + function f() { + return helloProperty + p2; + } + } + component NestedComponent: Item { + property NestedComponent2 inner: NestedComponent2 {} + property int p2 + } + component NestedComponent2: Item { + property NestedComponent3 inner + property int p2 + inner: NestedComponent3 {} + } + component NestedComponent3: Item { + property NestedComponent4 inner + property int p2 + inner: NestedComponent4 {} + } + component NestedComponent4: Item { + property int helloProperty + property int p2 + } + NestedComponent { + id: myNested + } + function nestedUsages() { + let x = myNested.inner.inner.inner.helloProperty + helloProperty; + let a = myNested.p2 + p2; + let b = myNested.inner.p2 + p2; + let c = myNested.inner.inner.p2 + p2; + let d = myNested.inner.inner.inner.p2 + p2; + } + + function recursive(n: int): int { + if (n > 3) + return 1 + recursive(recursive(x - 1) + recursive(x - 2) - recursive(x - 3)); + else + return recursive(0); + } + + property int helloRecursive: recursive(42) + Rectangle { + function f() { + return rootId.recursive(123); + } + } + + signal helloSignal + + function callSignals() { + helloSignal(); + if (false) { + helloSignal(); + } else { + // helloSignal() // not a usage btw + if (true) + helloSignal(); + } + } + function callSignals2() { + helloSignal(); + if (false) { + widthChanged(); + } else { + // helloSignal() // not a usage btw + if (true) + widthChanged(); + rootId.widthChanged(); + } + } + Item { + function callSignalsInChild() { + widthChanged(); + rootId.widthChanged(); + } + } + + function myHelloHandler() { + let x = 32; + } + onHelloSignal: myHelloHandler + + property int helloPropertyBinding + helloPropertyBinding: 123 + + property int checkHandlers + onCheckHandlersChanged: myHelloHandler + onChildrenChanged: myHelloHandler + function callChanged() { + checkHandlersChanged(); + childrenChanged(); + } + property int _: 48 + property int ______42: 48 + property int _123a: 48 + on_Changed: myHelloHandler + on______42Changed: myHelloHandler + on_123AChanged: myHelloHandler + function weirdPropertynames() { + _Changed(); + ______42Changed(); + _123aChanged(); + } + + TapHandler { + onTapped: myHelloHandler + function f() { + tapped(); + } + } + + function anotherF() { + helloPropertyChanged(); + } + onHelloPropertyChanged: myHelloHandler + // Type {} + function foo(mouse) { + } + + MouseArea { + id: area1 + onClicked: foo + property int insideMouseArea1 + } + + MouseArea { + id: area2 + Connections { + function onClicked(mouse) { + area1.clicked(); + area3.clicked(); + } + } + property int insideMouseArea2 + + MouseArea { + id: area3 + } + } + + property Connections c: Connections { + target: area3 + onClicked: function (mouse) {} + } + function useMouseAreas() { + area1.clicked(); + area2.clicked(); + area3.clicked(); + } + + function checkParameters(a: int, b: double, { + x, + y = {}, + z = [x, y] + }) { + return a + b + c + x + y + z; + } + + function deconstructingUsages(xxx) { + let { + a, + b + } = xxx; + let c = a + b; + } + + 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(string a) + + 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; + } +} diff --git a/tests/auto/qmlls/modules/data/hover/test.qml b/tests/auto/qmlls/modules/data/hover/test.qml new file mode 100644 index 0000000000..dd1d5abcb0 --- /dev/null +++ b/tests/auto/qmlls/modules/data/hover/test.qml @@ -0,0 +1,8 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +QtObject { + readonly property int t: "" +} diff --git a/tests/auto/qmlls/modules/data/linting/SimpleItem.qml b/tests/auto/qmlls/modules/data/linting/SimpleItem.qml new file mode 100644 index 0000000000..b7b7fc5021 --- /dev/null +++ b/tests/auto/qmlls/modules/data/linting/SimpleItem.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + id: helloItem + +} diff --git a/tests/auto/qmlls/modules/data/quickfixes/INeedAQuickFix.qml b/tests/auto/qmlls/modules/data/quickfixes/INeedAQuickFix.qml new file mode 100644 index 0000000000..ccd2a55383 --- /dev/null +++ b/tests/auto/qmlls/modules/data/quickfixes/INeedAQuickFix.qml @@ -0,0 +1,19 @@ +import QtQuick + +Item { + id: hello + + signal s(xxx: string) + property int i: 42 + + // fix me! add '(xxx) =>' in front of console.log() + onS: console.log(xxx) + + Item { + // fix me! prepend 'hello.' to 'i'! + function f() { + return i + } + } + +} diff --git a/tests/auto/qmlls/modules/data/renameUsages/RenameMe.qml b/tests/auto/qmlls/modules/data/renameUsages/RenameMe.qml new file mode 100644 index 0000000000..7680c63f95 --- /dev/null +++ b/tests/auto/qmlls/modules/data/renameUsages/RenameMe.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + property int helloProperty +}
\ No newline at end of file diff --git a/tests/auto/qmlls/modules/data/renameUsages/RenameMe2.ui.qml b/tests/auto/qmlls/modules/data/renameUsages/RenameMe2.ui.qml new file mode 100644 index 0000000000..b9197def63 --- /dev/null +++ b/tests/auto/qmlls/modules/data/renameUsages/RenameMe2.ui.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + property int helloProperty +} diff --git a/tests/auto/qmlls/modules/data/renameUsages/main.qml b/tests/auto/qmlls/modules/data/renameUsages/main.qml new file mode 100644 index 0000000000..b59508f92f --- /dev/null +++ b/tests/auto/qmlls/modules/data/renameUsages/main.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + RenameMe {} + RenameMe2 {} +} diff --git a/tests/auto/qmlls/modules/data/sourceDir/A.qml b/tests/auto/qmlls/modules/data/sourceDir/A.qml new file mode 100644 index 0000000000..5560aee727 --- /dev/null +++ b/tests/auto/qmlls/modules/data/sourceDir/A.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + +} diff --git a/tests/auto/qmlls/modules/data/sourceDir/Main.qml b/tests/auto/qmlls/modules/data/sourceDir/Main.qml new file mode 100644 index 0000000000..e9fc9d4298 --- /dev/null +++ b/tests/auto/qmlls/modules/data/sourceDir/Main.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + B {} + Button {} +} diff --git a/tests/auto/qmlls/modules/data/sourceDir/qmldir b/tests/auto/qmlls/modules/data/sourceDir/qmldir new file mode 100644 index 0000000000..2dd55288e3 --- /dev/null +++ b/tests/auto/qmlls/modules/data/sourceDir/qmldir @@ -0,0 +1,3 @@ +module SourceDir +B 1.0 A.qml +import QtQuick.Controls.Basic |