diff options
author | Christian Kamm <mail@ckamm.de> | 2020-05-10 15:57:22 +0200 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2020-05-21 07:53:44 +0000 |
commit | f64146741df05d7da7429f66af079b24c11cc3ca (patch) | |
tree | d83e5f5bfbf482029afd52a56e3da47bdec04b6f /tests/auto | |
parent | 338fa26bc37ab1180090c3d7b58c5097cb10e70e (diff) |
QmlJS: Use "import" commands from qmldir files
qmldir files can have lines like "import QtQml". These were already
parsed, but not stored in LibraryInfo. Store them.
When imports are resolved in Link and a library has such an import, also
load the module it refers to, with the same version and "as" scope.
Add a test to verify the behavior works.
Change-Id: I80b260bfaa36a9e5de0849fa5632b3361077ef01
Task-number: QTCREATORBUG-23986
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto')
12 files changed, 693 insertions, 3 deletions
diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/importQtQuick.qml b/tests/auto/qml/codemodel/importscheck/importTypes/importQtQuick.qml new file mode 100644 index 0000000000..68c21087cb --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/importQtQuick.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/plugins.qmltypes new file mode 100644 index 0000000000..39cb4f3ccc --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/plugins.qmltypes @@ -0,0 +1,26 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "QObject" + exports: ["QtQml/QtObject 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/qmldir new file mode 100644 index 0000000000..8175ebb1a1 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/qmldir @@ -0,0 +1,2 @@ +module QtQml +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/plugins.qmltypes new file mode 100644 index 0000000000..b6a7fc5697 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/plugins.qmltypes @@ -0,0 +1,175 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "IsQtQuickQmldirImport" + exports: ["QtQuick/IsQtQuickQmldirImport 2.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QQuickBehavior" + defaultProperty: "animation" + prototype: "QObject" + exports: [ + "QtQuick/Behavior 2.0", + "QtQuick/Behavior 2.13", + "QtQuick/Behavior 2.15", + "QtQuick/Behavior 2.16" + ] + exportMetaObjectRevisions: [0, 13, 15, 16] + Property { name: "animation"; type: "QQuickAbstractAnimation"; isPointer: true } + Property { name: "enabled"; type: "bool" } + Property { name: "targetValue"; revision: 13; type: "QVariant"; isReadonly: true } + Property { name: "targetProperty"; revision: 15; type: "QQmlProperty"; isReadonly: true } + Method { name: "componentFinalized" } + } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + exports: ["QtQuick/Item 2.0", "QtQuick/Item 2.1"] + exportMetaObjectRevisions: [0, 1] + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/qmldir new file mode 100644 index 0000000000..4bdfa4feb3 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/qmldir @@ -0,0 +1,5 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes +import QtQml diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/plugins.qmltypes new file mode 100644 index 0000000000..8771dbec91 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/plugins.qmltypes @@ -0,0 +1,174 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "IsQtQuickSimple" + exports: ["QtQuick/IsQtQuickSimple 2.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QObject" + exports: ["QtQml/QtObject 2.0", "QtQuick/QtObject 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + exports: ["QtQuick/Item 2.0", "QtQuick/Item 2.1"] + exportMetaObjectRevisions: [0, 1] + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/qmldir new file mode 100644 index 0000000000..4a79c82e76 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/qmldir @@ -0,0 +1,4 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/plugins.qmltypes new file mode 100644 index 0000000000..39cb4f3ccc --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/plugins.qmltypes @@ -0,0 +1,26 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "QObject" + exports: ["QtQml/QtObject 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/qmldir new file mode 100644 index 0000000000..8175ebb1a1 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/qmldir @@ -0,0 +1,2 @@ +module QtQml +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/plugins.qmltypes new file mode 100644 index 0000000000..25d6c402a6 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/plugins.qmltypes @@ -0,0 +1,174 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "IsQtQuickWorkaround" + exports: ["QtQuick/IsQtQuickWorkaround 2.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QQuickBehavior" + defaultProperty: "animation" + prototype: "QObject" + exports: [ + "QtQuick/Behavior 2.0", + "QtQuick/Behavior 2.13", + "QtQuick/Behavior 2.15" + ] + exportMetaObjectRevisions: [0, 13, 15] + Property { name: "animation"; type: "QQuickAbstractAnimation"; isPointer: true } + Property { name: "enabled"; type: "bool" } + Property { name: "targetValue"; revision: 13; type: "QVariant"; isReadonly: true } + Property { name: "targetProperty"; revision: 15; type: "QQmlProperty"; isReadonly: true } + Method { name: "componentFinalized" } + } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + exports: ["QtQuick/Item 2.0", "QtQuick/Item 2.1"] + exportMetaObjectRevisions: [0, 1] + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/qmldir new file mode 100644 index 0000000000..4a79c82e76 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/qmldir @@ -0,0 +1,4 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp b/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp index f6126b73af..582fbd49fb 100644 --- a/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp +++ b/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp @@ -58,6 +58,9 @@ private slots: void test(); void test_data(); + void importTypes_data(); + void importTypes(); + void initTestCase(); private: QStringList m_basePaths; @@ -191,10 +194,12 @@ void tst_ImportCheck::test() QStringList detectedFiles; foreach (const ImportKey &importK, iDeps->libraryImports(vCtx)) detectedLibraries << importK.toString(); - foreach (const QString &path, paths) + foreach (const QString &path, paths) { foreach (const ImportKey &importK, iDeps->subdirImports(ImportKey(ImportType::Directory, - path), vCtx)) - detectedFiles << QFileInfo(importK.toString()).canonicalFilePath(); + path), vCtx)) { + detectedFiles << QFileInfo(importK.toString()).canonicalFilePath(); + } + } expectedLibraries.sort(); expectedFiles.sort(); @@ -204,6 +209,94 @@ void tst_ImportCheck::test() QCOMPARE(expectedFiles, detectedFiles); } +class MyModelManager : public ModelManagerInterface +{ +public: + using ModelManagerInterface::setDefaultProject; + using ModelManagerInterface::updateImportPaths; +}; + +void tst_ImportCheck::importTypes_data() +{ + QTest::addColumn<QString>("qmlFile"); + QTest::addColumn<QString>("importPath"); + QTest::addColumn<QStringList>("expectedTypes"); + + QTest::newRow("base") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/base") + << QStringList({ "Item", "Rectangle", "QtObject" }); + + // simple case, with everything in QtQuick/plugins.qmltypes + QTest::newRow("QtQuick-simple") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/importTypes/imports-QtQuick-simple") + << QStringList({ "Item", "QtObject", "IsQtQuickSimple" }); + + // QtQuick/ and QtQml/ with an implicit dependency + // This is the situation in Qt 5.15.0 and will be made to work in a + // follow-up commit. + /* + QTest::newRow("QtQuick-workaround-QtQml") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/importTypes/imports-QtQuick-workaround-QtQml") + << QStringList({ "Item", "QtObject", "IsQtQuickWorkaround" });*/ + + // QtQuick/ and QtQml/ with an "import" in the qmldir file + // Seen in Qt 6. + QTest::newRow("QtQuick-qmldir-import") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/importTypes/imports-QtQuick-qmldir-import") + << QStringList({ "Item", "QtObject", "IsQtQuickQmldirImport" }); +} + +void tst_ImportCheck::importTypes() +{ + QFETCH(QString, qmlFile); + QFETCH(QString, importPath); + QFETCH(QStringList, expectedTypes); + + // full reset + delete ModelManagerInterface::instance(); + MyModelManager *modelManager = new MyModelManager; + + // the default qtQmlPath is based on the Qt version in use otherwise + ModelManagerInterface::ProjectInfo defaultProject; + defaultProject.qtQmlPath = importPath; + modelManager->setDefaultProject(defaultProject, nullptr); + modelManager->activateScan(); + + modelManager->updateSourceFiles(QStringList(qmlFile), false); + modelManager->test_joinAllThreads(); + + Snapshot snapshot = modelManager->newestSnapshot(); + Document::Ptr doc = snapshot.document(qmlFile); + + // It's unfortunate, but nowadays linking can trigger async module loads, + // so do it once to start the process, then do it again for real once the + // dependencies are available. + const auto getContext = [&]() { + Link link(snapshot, modelManager->defaultVContext(doc->language(), doc), + modelManager->builtins(doc)); + return link(); + }; + getContext(); + modelManager->test_joinAllThreads(); + snapshot = modelManager->newestSnapshot(); + doc = snapshot.document(qmlFile); + + ContextPtr context = getContext(); + + bool allFound = true; + for (const auto &expected : expectedTypes) { + if (!context->lookupType(doc.data(), QStringList(expected))) { + allFound = false; + qWarning() << "Type '" << expected << "' not found"; + } + } + QVERIFY(allFound); +} + #ifdef MANUAL_IMPORT_SCANNER int main(int argc, char *argv[]) |