aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmlls/utils/data/JSDefinitions.qml
blob: f9ed272d434a1069fdf9feb652edc43b818ca648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

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)
    }

    function ffff() {
        let scoped = 42;
        {
            let scoped = 666;
            f(scoped, i);
            {
                let a = 12345, i = 32;
                f(scoped, i);
            }
        }
        f(scoped, i);
    }

    Rectangle {
        id: nested

        property int i

        function f(n: int): int {
            let x = i, y = nested.i, z = rootId.i;
            if (x > 3)
                return 1 + f(f(x-1) + f(x-2) - f(x-3));
            else
                return f(0);
        }
        function fff(n: int, m: int): int {
            return f(n + m) / 42 + ffff()
        }
    }
    function abc() {
        return nested.f(42);
    }

    component MyIC: Rectangle {
        id: helloIC

        property int data: 42
        Item {
            property int data: helloIC.data
        }
    }

    property MyIC ic: MyIC {}
    function icProperty() {
        return ic.data
    }
    property int propertyInBinding: i
    property int propertyInBinding2: i * 42
    property int propertyInBinding3: abc()[rootId.i ** 42 - 7]

    property BaseType bt: BaseType {}
    property int helloProperty: 1234567890 // BaseType also has a property helloProperty
    function helloFunction() {} // BaseType also has a method helloFunction
    function fromDifferentFiles() {
        let x = bt.helloProperty + bt.helloFunction()
    }
}