diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/quick.metainfo b/share/qtcreator/qmldesigner/propertyEditorQmlSources/quick.metainfo new file mode 100644 index 00000000000..f1aeaa9ebbd --- /dev/null +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/quick.metainfo @@ -0,0 +1,817 @@ +MetaInfo { + + Type { + name: "QtQuick.Item" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleNonDefaultProperties: "layer.effect" + } + + ItemLibraryEntry { + name: "Item" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 200; } + Property { name: "height"; type: "int"; value: 200; } + toolTip: qsTr("Groups several visual items.") + } + } + + Type { + name: "QtQuick.Rectangle" + icon: ":/qtquickplugin/images/rect-icon16.png" + + ItemLibraryEntry { + name: "Rectangle" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/rect-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 200; } + Property { name: "height"; type: "int"; value: 200; } + Property { name: "color"; type: "QColor"; value: "#ffffff"; } + toolTip: qsTr("A rectangle with an optional border.") + } + } + + Type { + name: "QtQuick.Text" + icon: ":/qtquickplugin/images/text-icon16.png" + + ItemLibraryEntry { + name: "Text" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/text-icon.png" + version: "2.0" + + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text\")"; } + toolTip: qsTr("A read-only text label.") + } + } + + Type { + name: "QtQuick.TextEdit" + icon: ":/qtquickplugin/images/text-edit-icon16.png" + + ItemLibraryEntry { + name: "Text Edit" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/text-edit-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 80; } + Property { name: "height"; type: "int"; value: 20; } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Edit\")"; } + toolTip: qsTr("A multi-line block of editable text.") + } + } + + Type { + name: "QtQuick.TextInput" + icon: ":/qtquickplugin/images/text-input-icon16.png" + + ItemLibraryEntry { + name: "Text Input" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/text-input-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 80; } + Property { name: "height"; type: "int"; value: 20; } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Input\")"; } + toolTip: qsTr("An editable line of text.") + } + } + + Type { + name: "QtQuick.MouseArea" + icon: ":/qtquickplugin/images/mouse-area-icon16.png" + + ItemLibraryEntry { + name: "Mouse Area" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/mouse-area-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + toolTip: qsTr("An area with mouse functionality.") + } + } + + Type { + name: "QtQuick.Image" + icon: ":/qtquickplugin/images/image-icon16.png" + + ItemLibraryEntry { + name: "Image" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/image-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + Property { name: "source"; type: "QUrl"; value:"qrc:/qtquickplugin/images/template_image.png"; } + Property { name: "fillMode"; type: "enum"; value: "Image.PreserveAspectFit"; } + toolTip: qsTr("Displays an image.") + } + } + + Type { + name: "QtQuick.AnimatedImage" + icon: ":/qtquickplugin/images/animated-image-icon16.png" + + ItemLibraryEntry { + name: "Animated Image" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/animated-image-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + Property { name: "source"; type: "QUrl"; value:"qrc:/qtquickplugin/images/template_image.png"; } + toolTip: qsTr("Animates a series of images.") + } + } + + Type { + name: "QtQuick.BorderImage" + icon: ":/qtquickplugin/images/border-image-icon16.png" + + ItemLibraryEntry { + name: "Border Image" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/border-image-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + Property { name: "source"; type: "QUrl"; value:"qrc:/qtquickplugin/images/template_image.png"; } + toolTip: qsTr("A responsive border based on an image.") + } + } + + Type { + name: "QtQuick.Flickable" + icon: ":/qtquickplugin/images/flickable-icon16.png" + + ItemLibraryEntry { + name: "Flickable" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/flickable-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 300; } + Property { name: "height"; type: "int"; value: 300; } + toolTip: qsTr("An area for keeping dragable objects.") + } + } + + Type { + name: "QtQuick.GridView" + icon: ":/qtquickplugin/images/gridview-icon16.png" + + ItemLibraryEntry { + name: "Grid View" + category: "b.Qt Quick - Views" + libraryIcon: ":/qtquickplugin/images/gridview-icon.png" + version: "2.0" + + QmlSource { source: ":/qtquickplugin/source/gridviewv2.qml" } + toolTip: qsTr("Organizes dynamic data sets in a grid.") + } + } + + Type { + name: "QtQuick.ListView" + icon: ":/qtquickplugin/images/listview-icon16.png" + + ItemLibraryEntry { + name: "List View" + category: "b.Qt Quick - Views" + libraryIcon: ":/qtquickplugin/images/listview-icon.png" + version: "2.0" + + QmlSource { source: ":/qtquickplugin/source/listviewv2.qml" } + toolTip: qsTr("Organizes dynamic data sets in a list.") + } + } + + Type { + name: "QtQuick.PathView" + icon: ":/qtquickplugin/images/pathview-icon16.png" + + ItemLibraryEntry { + name: "Path View" + category: "b.Qt Quick - Views" + libraryIcon: ":/qtquickplugin/images/pathview-icon.png" + version: "2.0" + + QmlSource { source: ":/qtquickplugin/source/pathviewv2.qml" } + toolTip: qsTr("Organizes dynamic data sets along a path.") + } + } + + Type { + name: "QtQuick.FocusScope" + icon: ":/qtquickplugin/images/focusscope-icon16.png" + + ItemLibraryEntry { + name: "Focus Scope" + category: "a.Qt Quick - Basic" + libraryIcon: ":/qtquickplugin/images/focusscope-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + toolTip: qsTr("A scope to focus on a specific text element.") + } + } + + Type { + name: "QtQuick.Column" + icon: ":/qtquickplugin/images/column-positioner-icon-16px.png" + + ItemLibraryEntry { + name: "Column" + category: "c.Qt Quick - Positioner" + libraryIcon: ":/qtquickplugin/images/column-positioner-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 200; } + Property { name: "height"; type: "int"; value: 400; } + + toolTip: qsTr("Organizes items in a column.") + } + } + + Type { + name: "QtQuick.Row" + icon: ":/qtquickplugin/images/row-positioner-icon-16px.png" + + ItemLibraryEntry { + name: "Row" + category: "c.Qt Quick - Positioner" + libraryIcon: ":/qtquickplugin/images/row-positioner-icon.png" + version: "2.0" + toolTip: qsTr("Organizes items in a row.") + + Property { name: "width"; type: "int"; value: 200; } + Property { name: "height"; type: "int"; value: 400; } + } + } + + Type { + name: "QtQuick.Grid" + icon: ":/qtquickplugin/images/grid-positioner-icon-16px.png" + + ItemLibraryEntry { + name: "Grid" + category: "c.Qt Quick - Positioner" + libraryIcon: ":/qtquickplugin/images/grid-positioner-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 400; } + Property { name: "height"; type: "int"; value: 400; } + toolTip: qsTr("Organizes items in a fixed grid.") + } + } + + Type { + name: "QtQuick.Flow" + icon: ":/qtquickplugin/images/flow-positioner-icon-16px.png" + + ItemLibraryEntry { + name: "Flow" + category: "c.Qt Quick - Positioner" + libraryIcon: ":/qtquickplugin/images/flow-positioner-icon.png" + version: "2.0" + + Property { name: "width"; type: "int"; value: 400; } + Property { name: "height"; type: "int"; value: 400; } + toolTip: qsTr("Organizes items in free-flowing rows.") + } + } + + Type { + name: "QtQuick.Timeline.Timeline" + icon: ":/qtquickplugin/images/timeline-16px.png" + + Hints { + visibleNonDefaultProperties: "animations" + visibleInLibrary: false + visibleInNavigator: true + } + ItemLibraryEntry { + name: "Timeline" + category: "none" + version: "1.0" + } + } + + Type { + name: "QtQuick.Timeline.TimelineAnimation" + icon: ":/qtquickplugin/images/timeline-animation-16px.png" + + Hints { + visibleInLibrary: false + visibleInNavigator: true + } + ItemLibraryEntry { + name: "Animation" + category: "none" + version: "1.0" + } + } + + Type { + name: "QtQuick.Timeline.Keyframe" + icon: ":/qtquickplugin/images/keyframe-16px.png" + + ItemLibraryEntry { + name: "Keyframe" + category: "none" + version: "1.0" + requiredImport: "none" + } + } + + Type { + name: "QtQuick.Timeline.KeyframeGroup" + icon: ":/qtquickplugin/images/keyframe-16px.png" + + ItemLibraryEntry { + name: "KeyframeGroup" + category: "none" + version: "1.0" + requiredImport: "none" + } + } + + Type { + name: "QtQuick.PropertyAnimation" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Property Animation" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Animates changes in property values.") + } + } + + Type { + name: "QtQuick.PauseAnimation" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Pause Animation" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Provides a pause between animations.") + } + } + + Type { + name: "QtQuick.SequentialAnimation" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + } + + ItemLibraryEntry { + name: "Sequential Animation" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Runs animations one after the other.") + } + } + + Type { + name: "QtQuick.ParallelAnimation" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + } + + ItemLibraryEntry { + name: "Parallel Animation" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Runs animations together at the same time.") + } + } + + Type { + name: "QtQuick.PropertyAction" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Property Action" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Provides an immediate property change during animations.") + } + } + + Type { + name: "QtQuick.ScriptAction" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Script Action" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Runs a script during animation.") + } + } + + Type { + name: "QtQuick.ColorAnimation" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Color Animation" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + toolTip: qsTr("Animates the color of an item.") + } + } + + Type { + name: "QtQuick.NumberAnimation" + icon: ":/qtquickplugin/images/item-icon16.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Number Animation" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "2.0" + Property { name: "to"; type: "int"; value: 0; } + Property { name: "from"; type: "int"; value: 0; } + toolTip: qsTr("Animates a numerical property of an item.") + } + } + + Type { + name: "QtQml.Timer" + icon: ":/qtquickplugin/images/timer-16px.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Timer" + category: "d.Qt Quick - Animation" + libraryIcon: ":/qtquickplugin/images/timer-24px.png" + version: "2.0" + toolTip: qsTr(" Triggers an action at a given time.") + } + } + + Type { + name: "QML.Component" + icon: ":/qtquickplugin/images/component-icon16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + } + + ItemLibraryEntry { + name: "Component" + category: "e.Qt Quick - Instancers" + libraryIcon: ":/qtquickplugin/images/component-icon.png" + version: "1.0" + + QmlSource { source: ":/qtquickplugin/source/component.qml" } + toolTip: qsTr("Allows you to define components inline, within a QML document.") + } + } + + Type { + name: "QML.Component" + icon: ":/qtquickplugin/images/component-icon16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + } + + ItemLibraryEntry { + name: "Component 3D" + category: "Instancers" + libraryIcon: ":/qtquickplugin/images/component-icon.png" + version: "1.0" + requiredImport: "QtQuick3D" + + QmlSource { source: ":/qtquickplugin/source/component3d.qml" } + toolTip: qsTr("Allows you to define 3D components inline, within a QML document.") + } + } + + Type { + name: "QtQuick.Loader" + icon: ":/qtquickplugin/images/loader-icon16.png" + + ItemLibraryEntry { + name: "Loader" + category: "e.Qt Quick - Instancers" + libraryIcon: ":/qtquickplugin/images/loader-icon.png" + version: "2.0" + Property { name: "width"; type: "int"; value: 200; } + Property { name: "height"; type: "int"; value: 200; } + toolTip: qsTr("Allows you to load components dynamically.") + } + } + + Type { + name: "QtQuick.Repeater" + icon: ":/qtquickplugin/images/repeater-icon16.png" + + Hints { + canBeDroppedInFormEditor: false + hasFormEditorItem: false + } + + ItemLibraryEntry { + name: "Repeater" + category: "e.Qt Quick - Instancers" + libraryIcon: ":/qtquickplugin/images/repeater-icon.png" + version: "2.0" + toolTip: qsTr("Creates a number of copies of the same item.") + } + } + + Type { + name: "QtMultimedia.MediaPlayer" + icon: ":/qtquickplugin/images/media-player-16px.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Media Player" + category: "f.Qt Quick - Multimedia" + libraryIcon: ":/qtquickplugin/images/media-player-24px.png" + version: "6.0" + requiredImport: "QtMultimedia" + } + } + + Type { + name: "QtMultimedia.AudioOutput" + icon: ":/qtquickplugin/images/audio-output-16px.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Audio Output" + category: "f.Qt Quick - Multimedia" + libraryIcon: ":/qtquickplugin/images/audio-output-24px.png" + version: "6.0" + requiredImport: "QtMultimedia" + } + } + + Type { + name: "QtMultimedia.VideoOutput" + icon: ":/qtquickplugin/images/video-output-16px.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Video Output" + category: "f.Qt Quick - Multimedia" + libraryIcon: ":/qtquickplugin/images/video-output-24px.png" + version: "6.0" + requiredImport: "QtMultimedia" + } + } + + Type { + name: "QtMultimedia.Video" + icon: ":/qtquickplugin/images/video-16px.png" + + Hints { + visibleInNavigator: true + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: true + canBeContainer: false + } + + ItemLibraryEntry { + name: "Video" + category: "f.Qt Quick - Multimedia" + libraryIcon: ":/qtquickplugin/images/video-24px.png" + version: "6.0" + requiredImport: "QtMultimedia" + + Property { name: "width"; type: "int"; value: 200; } + Property { name: "height"; type: "int"; value: 200; } + } + } + + Type { + name: "QtQuick3D.SpatialAudio.AmbientSound" + icon: ":/qtquickplugin/images/ambient-sound-16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeDroppedInView3D: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Ambient Sound" + category: "Spatial Audio" + libraryIcon: ":/qtquickplugin/images/ambient-sound-24.png" + version: "6.0" + requiredImport: "QtQuick3D.SpatialAudio" + toolTip: qsTr("An ambient background sound.") + } + } + + Type { + name: "QtQuick3D.SpatialAudio.AudioEngine" + icon: ":/qtquickplugin/images/audio-engine-16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeDroppedInView3D: false + canBeContainer: false + } + + ItemLibraryEntry { + name: "Audio Engine" + category: "Spatial Audio" + libraryIcon: ":/qtquickplugin/images/audio-engine-24.png" + version: "6.0" + requiredImport: "QtQuick3D.SpatialAudio" + toolTip: qsTr("Manages sound objects inside a 3D scene.") + } + } + + Type { + name: "QtQuick3D.SpatialAudio.AudioListener" + icon: ":/qtquickplugin/images/audio-listener-16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeDroppedInView3D: true + } + + ItemLibraryEntry { + name: "Audio Listener" + category: "Spatial Audio" + libraryIcon: ":/qtquickplugin/images/audio-listener-24.png" + version: "6.0" + requiredImport: "QtQuick3D.SpatialAudio" + toolTip: qsTr("Sets the position and orientation of listening.") + } + } + + Type { + name: "QtQuick3D.SpatialAudio.AudioRoom" + icon: ":/qtquickplugin/images/audio-room-16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeDroppedInView3D: true + } + + ItemLibraryEntry { + name: "Audio Room" + category: "Spatial Audio" + libraryIcon: ":/qtquickplugin/images/audio-room-24.png" + version: "6.0" + requiredImport: "QtQuick3D.SpatialAudio" + toolTip: qsTr("Sets up a room for the spatial audio engine.") + } + } + + Type { + name: "QtQuick3D.SpatialAudio.SpatialSound" + icon: ":/qtquickplugin/images/spatial-audio-16.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeDroppedInView3D: true + } + + ItemLibraryEntry { + name: "Spatial Sound" + category: "Spatial Audio" + libraryIcon: ":/qtquickplugin/images/spatial-audio-24.png" + version: "6.0" + requiredImport: "QtQuick3D.SpatialAudio" + toolTip: qsTr("A sound object in 3D space.") + } + } + + Type { + name: "QtQuick3D.BakedLightmap" + icon: ":/ItemLibrary/images/item-default-icon.png" + + Hints { + canBeDroppedInNavigator: true + canBeDroppedInFormEditor: false + canBeDroppedInView3D: false + } + + ItemLibraryEntry { + name: "Baked Lightmap" + category: "Components" + libraryIcon: ":/ItemLibrary/images/item-default-icon.png" + version: "6.5" + requiredImport: "QtQuick3D" + toolTip: qsTr("An object to specify details about baked lightmap of a model.") + + Property { name: "loadPrefix"; type: "string"; value: "lightmaps"; } + } + } +} diff --git a/src/libs/sqlite/sqlitedatabase.cpp b/src/libs/sqlite/sqlitedatabase.cpp index bb92943776b..12a122030c4 100644 --- a/src/libs/sqlite/sqlitedatabase.cpp +++ b/src/libs/sqlite/sqlitedatabase.cpp @@ -215,6 +215,29 @@ void Database::sessionRollback() m_statements->rollbackBegin.execute(); } +void Database::resetDatabaseForTestsOnly() +{ + m_databaseBackend.resetDatabaseForTestsOnly(); + setIsInitialized(false); +} + +void Database::clearAllTablesForTestsOnly() +{ + m_databaseBackend.disableForeignKeys(); + { + Sqlite::ImmediateTransaction transaction{*this}; + + ReadStatement<1> tablesStatement{"SELECT name FROM sqlite_schema WHERE type='table'", *this}; + auto tables = tablesStatement.template values(); + for (const auto &table : tables) + execute("DELETE FROM " + table); + + transaction.commit(); + } + + m_databaseBackend.enableForeignKeys(); +} + DatabaseBackend &Database::backend() { return m_databaseBackend; diff --git a/src/libs/sqlite/sqlitedatabase.h b/src/libs/sqlite/sqlitedatabase.h index 70be8f43057..0db256c8162 100644 --- a/src/libs/sqlite/sqlitedatabase.h +++ b/src/libs/sqlite/sqlitedatabase.h @@ -161,6 +161,9 @@ public: void sessionCommit() override; void sessionRollback() override; + void resetDatabaseForTestsOnly(); + void clearAllTablesForTestsOnly(); + private: void initializeTables(); void registerTransactionStatements(); diff --git a/src/libs/sqlite/sqlitedatabasebackend.cpp b/src/libs/sqlite/sqlitedatabasebackend.cpp index 1cca1f61791..2f55853dd03 100644 --- a/src/libs/sqlite/sqlitedatabasebackend.cpp +++ b/src/libs/sqlite/sqlitedatabasebackend.cpp @@ -248,11 +248,30 @@ int busyHandlerCallback(void *userData, int counter) void DatabaseBackend::registerBusyHandler() { - int resultCode = sqlite3_busy_handler(sqliteDatabaseHandle(), &busyHandlerCallback, &m_busyHandler); + int resultCode = sqlite3_busy_handler(sqliteDatabaseHandle(), + &busyHandlerCallback, + &m_busyHandler); checkIfBusyTimeoutWasSet(resultCode); } +void DatabaseBackend::resetDatabaseForTestsOnly() +{ + sqlite3_db_config(sqliteDatabaseHandle(), SQLITE_DBCONFIG_RESET_DATABASE, 1, 0); + sqlite3_exec(sqliteDatabaseHandle(), "VACUUM", nullptr, nullptr, nullptr); + sqlite3_db_config(sqliteDatabaseHandle(), SQLITE_DBCONFIG_RESET_DATABASE, 0, 0); +} + +void DatabaseBackend::enableForeignKeys() +{ + sqlite3_exec(sqliteDatabaseHandle(), "PRAGMA foreign_keys=ON", nullptr, nullptr, nullptr); +} + +void DatabaseBackend::disableForeignKeys() +{ + sqlite3_exec(sqliteDatabaseHandle(), "PRAGMA foreign_keys=OFF", nullptr, nullptr, nullptr); +} + void DatabaseBackend::checkForOpenDatabaseWhichCanBeClosed() { if (m_databaseHandle == nullptr) diff --git a/src/libs/sqlite/sqlitedatabasebackend.h b/src/libs/sqlite/sqlitedatabasebackend.h index 9a1caa92d67..39d690c4f73 100644 --- a/src/libs/sqlite/sqlitedatabasebackend.h +++ b/src/libs/sqlite/sqlitedatabasebackend.h @@ -84,6 +84,10 @@ public: void registerBusyHandler(); + void resetDatabaseForTestsOnly(); + void enableForeignKeys(); + void disableForeignKeys(); + protected: bool databaseIsOpen() const; diff --git a/src/libs/sqlite/sqlitevalue.h b/src/libs/sqlite/sqlitevalue.h index 49ab76d89f0..fe576f3fec9 100644 --- a/src/libs/sqlite/sqlitevalue.h +++ b/src/libs/sqlite/sqlitevalue.h @@ -234,9 +234,9 @@ public: {} template - static ValueView create(Type &&value) + static ValueView create(Type &&value_) { - return ValueView{ValueBase{value}}; + return ValueView{ValueBase{value_}}; } }; @@ -267,6 +267,21 @@ public: : ValueBase(Utils::SmallStringView(value)) {} + explicit Value(long long value) + : ValueBase(value) + {} + explicit Value(int value) + : ValueBase(static_cast(value)) + {} + + explicit Value(uint value) + : ValueBase(static_cast(value)) + {} + + explicit Value(double value) + : ValueBase(value) + {} + explicit Value(const QString &value) : ValueBase(VariantType{Utils::SmallString(value)}) {} diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index d2b091d1e4c..5b620323389 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -192,18 +192,26 @@ extend_qtc_library(QmlDesignerCore bytearraymodifier.h componenttextmodifier.h forwardview.h - itemlibraryinfo.h - metainforeader.h + itemlibraryentry.h model.h nodehints.h plaintexteditmodifier.h nodeinstanceview.h propertyparser.h rewriterview.h - subcomponentmanager.h textmodifier.h ) +extend_qtc_library(QmlDesignerCore + CONDITION NOT USE_PROJECTSTORAGE + SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/include + SOURCES + itemlibraryinfo.h + metainforeader.h + subcomponentmanager.h + metainfo.h +) + extend_qtc_library(QmlDesignerCore SOURCES_PROPERTIES SKIP_AUTOGEN ON SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/include @@ -233,7 +241,6 @@ extend_qtc_library(QmlDesignerCore invalidreparentingexception.h invalidslideindexexception.h mathutils.h - metainfo.h modelfwd.h modelmerger.h modelnode.h @@ -273,15 +280,23 @@ extend_qtc_library(QmlDesignerCore ${CMAKE_CURRENT_LIST_DIR}/designercore/metainfo SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/metainfo DEFINES SHARE_QML_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../../../share/qtcreator/qmldesigner" + SOURCES + itemlibraryentry.cpp + nodehints.cpp + nodemetainfo.cpp +) + +extend_qtc_library(QmlDesignerCore + CONDITION NOT USE_PROJECTSTORAGE + SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/metainfo SOURCES itemlibraryinfo.cpp metainfo.cpp metainforeader.cpp - nodehints.cpp - nodemetainfo.cpp subcomponentmanager.cpp ) + extend_qtc_library(QmlDesignerCore PUBLIC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/designercore/instances SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/designercore/instances @@ -405,6 +420,7 @@ extend_qtc_library(QmlDesignerCore projectstorageinterface.h projectstoragefwd.h projectstorageinfotypes.h + projectstorageobserver.h projectstoragepathwatcher.h projectstoragepathwatcherinterface.h projectstoragepathwatchernotifierinterface.h @@ -422,6 +438,7 @@ extend_qtc_library(QmlDesignerCore storagecache.h storagecacheentry.h storagecachefwd.h + typeannotationreader.cpp typeannotationreader.h qmldocumentparserinterface.h qmltypesparserinterface.h qmltypesparser.cpp qmltypesparser.h diff --git a/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp b/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp index 8480115a3b7..256bfac1e9f 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp b/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp index 76f5cc7e211..b605a77191b 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp b/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp index 82c37aa3c41..fa175123c79 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp @@ -8,8 +8,6 @@ #include #include -#include - #include #include #include diff --git a/src/plugins/qmldesigner/components/componentcore/svgpasteaction.cpp b/src/plugins/qmldesigner/components/componentcore/svgpasteaction.cpp index 738b1affedd..7bcd6050869 100644 --- a/src/plugins/qmldesigner/components/componentcore/svgpasteaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/svgpasteaction.cpp @@ -3,9 +3,9 @@ #include "svgpasteaction.h" -#include -#include +#include #include +#include #include diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp index 9831ee18467..e8ebf740397 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp +++ b/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp @@ -257,9 +257,13 @@ void Edit3DView::modelAttached(Model *model) if (QtSupport::QtVersion *qtVer = QtSupport::QtKitAspect::qtVersion(target->kit())) m_isBakingLightsSupported = qtVer->qtVersion() >= QVersionNumber(6, 5, 0); } - - connect(model->metaInfo().itemLibraryInfo(), &ItemLibraryInfo::entriesChanged, this, - &Edit3DView::onEntriesChanged, Qt::UniqueConnection); +#ifndef QDS_USE_PROJECTSTORAGE + connect(model->metaInfo().itemLibraryInfo(), + &ItemLibraryInfo::entriesChanged, + this, + &Edit3DView::onEntriesChanged, + Qt::UniqueConnection); +#endif } void Edit3DView::onEntriesChanged() @@ -285,24 +289,43 @@ void Edit3DView::handleEntriesChanged() EK_importedModels }; - QMap entriesMap { + QMap entriesMap{ {EK_cameras, {tr("Cameras"), contextIcon(DesignerIcons::CameraIcon)}}, {EK_lights, {tr("Lights"), contextIcon(DesignerIcons::LightIcon)}}, {EK_primitives, {tr("Primitives"), contextIcon(DesignerIcons::PrimitivesIcon)}}, - {EK_importedModels, {tr("Imported Models"), contextIcon(DesignerIcons::ImportedModelsIcon)}} + {EK_importedModels, {tr("Imported Models"), contextIcon(DesignerIcons::ImportedModelsIcon)}}}; + +#ifdef QDS_USE_PROJECTSTORAGE + const auto &projectStorage = *model()->projectStorage(); + auto append = [&](const NodeMetaInfo &metaInfo, ItemLibraryEntryKeys key) { + auto entries = metaInfo.itemLibrariesEntries(); + if (entries.size()) + entriesMap[key].entryList.append(toItemLibraryEntries(entries, projectStorage)); }; + append(model()->qtQuick3DModelMetaInfo(), EK_primitives); + append(model()->qtQuick3DDirectionalLightMetaInfo(), EK_lights); + append(model()->qtQuick3DSpotLightMetaInfo(), EK_lights); + append(model()->qtQuick3DPointLightMetaInfo(), EK_lights); + append(model()->qtQuick3DOrthographicCameraMetaInfo(), EK_cameras); + append(model()->qtQuick3DPerspectiveCameraMetaInfo(), EK_cameras); + + auto assetsModule = model()->module("Quick3DAssets"); + + for (const auto &metaInfo : model()->metaInfosForModule(assetsModule)) + append(metaInfo, EK_importedModels); +#else const QList itemLibEntries = model()->metaInfo().itemLibraryInfo()->entries(); for (const ItemLibraryEntry &entry : itemLibEntries) { ItemLibraryEntryKeys entryKey; if (entry.typeName() == "QtQuick3D.Model" && entry.name() != "Empty") { entryKey = EK_primitives; } else if (entry.typeName() == "QtQuick3D.DirectionalLight" - || entry.typeName() == "QtQuick3D.PointLight" - || entry.typeName() == "QtQuick3D.SpotLight") { + || entry.typeName() == "QtQuick3D.PointLight" + || entry.typeName() == "QtQuick3D.SpotLight") { entryKey = EK_lights; } else if (entry.typeName() == "QtQuick3D.OrthographicCamera" - || entry.typeName() == "QtQuick3D.PerspectiveCamera") { + || entry.typeName() == "QtQuick3D.PerspectiveCamera") { entryKey = EK_cameras; } else if (entry.typeName().startsWith("Quick3DAssets.") && NodeHints::fromItemLibraryEntry(entry).canBeDroppedInView3D()) { @@ -312,6 +335,7 @@ void Edit3DView::handleEntriesChanged() } entriesMap[entryKey].entryList.append(entry); } +#endif m_edit3DWidget->updateCreateSubMenu(entriesMap.values()); } diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dview.h b/src/plugins/qmldesigner/components/edit3d/edit3dview.h index e5d41614958..c9d93381e05 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dview.h +++ b/src/plugins/qmldesigner/components/edit3d/edit3dview.h @@ -3,7 +3,7 @@ #pragma once #include "edit3dactions.h" -#include "itemlibraryinfo.h" +#include #include #include diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp index c054b712ce3..70de2d29367 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp +++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp @@ -618,20 +618,39 @@ void Edit3DWidget::dropEvent(QDropEvent *dropEvent) QHash addedAssets = actionManager.handleExternalAssetsDrop(dropEvent->mimeData()); view()->executeInTransaction("Edit3DWidget::dropEvent", [&] { - // add 3D assets to 3d editor (QtQuick3D import will be added if missing) - ItemLibraryInfo *itemLibInfo = m_view->model()->metaInfo().itemLibraryInfo(); - + // add 3D assets to 3d editor (QtQuick3D import will be added if missing) +#ifdef QDS_USE_PROJECTSTORAGE const QStringList added3DAssets = addedAssets.value(ComponentCoreConstants::add3DAssetsDisplayString); for (const QString &assetPath : added3DAssets) { QString fileName = QFileInfo(assetPath).baseName(); fileName = fileName.at(0).toUpper() + fileName.mid(1); // capitalize first letter - QString type = QString("Quick3DAssets.%1.%1").arg(fileName); - QList entriesForType = itemLibInfo->entriesForType(type.toLatin1()); - if (!entriesForType.isEmpty()) { // should always be true, but just in case - QmlVisualNode::createQml3DNode(view(), entriesForType.at(0), - m_canvas->activeScene(), {}, false).modelNode(); + auto model = m_view->model(); + auto metaInfo = model->metaInfo(model->module("Quick3DAssets"), fileName.toUtf8()); + if (auto entries = metaInfo.itemLibrariesEntries(); entries.size()) { + auto entry = ItemLibraryEntry{entries.front(), *model->projectStorage()}; + QmlVisualNode::createQml3DNode(view(), entry, m_canvas->activeScene(), {}, false); } } +#else + ItemLibraryInfo *itemLibInfo = m_view->model()->metaInfo().itemLibraryInfo(); + + const QStringList added3DAssets = addedAssets.value( + ComponentCoreConstants::add3DAssetsDisplayString); + for (const QString &assetPath : added3DAssets) { + QString fileName = QFileInfo(assetPath).baseName(); + fileName = fileName.at(0).toUpper() + fileName.mid(1); // capitalize first letter + QString type = QString("Quick3DAssets.%1.%1").arg(fileName); + QList entriesForType = itemLibInfo->entriesForType(type.toUtf8()); + if (!entriesForType.isEmpty()) { // should always be true, but just in case + QmlVisualNode::createQml3DNode(view(), + entriesForType.at(0), + m_canvas->activeScene(), + {}, + false) + .modelNode(); + } + } +#endif }); m_view->model()->endDrag(); diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h index b9826ca07b3..7f119c205a5 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h +++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h @@ -9,7 +9,7 @@ #include #include -#include "itemlibraryinfo.h" +#include #include namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/components/eventlist/eventlist.cpp b/src/plugins/qmldesigner/components/eventlist/eventlist.cpp index 24adad74192..919a74193a3 100644 --- a/src/plugins/qmldesigner/components/eventlist/eventlist.cpp +++ b/src/plugins/qmldesigner/components/eventlist/eventlist.cpp @@ -6,7 +6,6 @@ #include "nodelistview.h" #include "bindingproperty.h" -#include "metainfo.h" #include "projectexplorer/project.h" #include "projectexplorer/projectmanager.h" #include "qmldesignerplugin.h" @@ -14,6 +13,7 @@ #include "utils/fileutils.h" #include "utils/qtcassert.h" #include "variantproperty.h" +#include #include #include diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp index 9a51c9f3722..e363e9bb11d 100644 --- a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp @@ -3,16 +3,16 @@ #include "dragtool.h" +#include "assetslibrarymodel.h" +#include "assetslibrarywidget.h" #include "formeditorscene.h" #include "formeditorview.h" -#include "assetslibrarywidget.h" -#include "assetslibrarymodel.h" #include "materialutils.h" -#include +#include "qmldesignerconstants.h" +#include #include #include #include -#include "qmldesignerconstants.h" #include diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 01e37671a01..854a210565d 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -8,7 +8,9 @@ #include "qmlvisualnode.h" #include -#include +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include #include #include @@ -72,8 +74,8 @@ DesignDocument::DesignDocument(ProjectStorageDependencies projectStorageDependen #else : m_documentModel( Model::create("QtQuick.Item", 1, 0, nullptr, std::make_unique())) -#endif , m_subComponentManager(new SubComponentManager(m_documentModel.get(), externalDependencies)) +#endif , m_rewriterView(new RewriterView(externalDependencies, RewriterView::Amend)) , m_documentLoaded(false) , m_currentTarget(nullptr) @@ -165,7 +167,9 @@ ModelPointer DesignDocument::createInFileComponentModel() nullptr, std::make_unique()); model->setFileUrl(m_documentModel->fileUrl()); +#ifndef QDS_USE_PROJECTSTORAGE model->setMetaInfo(m_documentModel->metaInfo()); +#endif return model; } @@ -523,6 +527,7 @@ void DesignDocument::close() emit designDocumentClosed(); } +#ifndef QDS_USE_PROJECTSTORAGE void DesignDocument::updateSubcomponentManager() { Q_ASSERT(m_subComponentManager); @@ -534,6 +539,7 @@ void DesignDocument::addSubcomponentManagerImport(const Import &import) { m_subComponentManager->addAndParseImport(import); } +#endif void DesignDocument::deleteSelected() { diff --git a/src/plugins/qmldesigner/components/integration/designdocument.h b/src/plugins/qmldesigner/components/integration/designdocument.h index 7c0fe3941f8..c5c1bab27f9 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.h +++ b/src/plugins/qmldesigner/components/integration/designdocument.h @@ -9,7 +9,9 @@ #include #include #include -#include +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include #include @@ -49,9 +51,10 @@ public: void loadDocument(QPlainTextEdit *edit); void attachRewriterToModel(); void close(); +#ifndef QDS_USE_PROJECTSTORAGE void updateSubcomponentManager(); void addSubcomponentManagerImport(const Import &import); - +#endif bool isUndoAvailable() const; bool isRedoAvailable() const; @@ -138,8 +141,9 @@ private: // variables QPointer m_textEditor; QScopedPointer m_documentTextModifier; QScopedPointer m_inFileComponentTextModifier; +#ifndef QDS_USE_PROJECTSTORAGE QScopedPointer m_subComponentManager; - +#endif QScopedPointer m_rewriterView; bool m_documentLoaded; ProjectExplorer::Target *m_currentTarget; diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryitem.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryitem.h index 449103976b1..1bc091d0054 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryitem.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryitem.h @@ -8,7 +8,7 @@ #include #include -#include "itemlibraryinfo.h" +#include namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp index 3f611a0dbba..c9aafc48fb7 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp @@ -3,10 +3,10 @@ #include "itemlibrarymodel.h" #include "itemlibrarycategoriesmodel.h" -#include "itemlibraryimport.h" #include "itemlibrarycategory.h" +#include "itemlibraryentry.h" +#include "itemlibraryimport.h" #include "itemlibraryitem.h" -#include "itemlibraryinfo.h" #include #include @@ -304,7 +304,7 @@ Import ItemLibraryModel::entryToImport(const ItemLibraryEntry &entry) } -void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model) +void ItemLibraryModel::update([[maybe_unused]] ItemLibraryInfo *itemLibraryInfo, Model *model) { if (!model) return; @@ -365,9 +365,14 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model) } const bool blockNewImports = document->inFileComponentModelActive(); - const QList itemLibEntries = itemLibraryInfo->entries(); + const QList itemLibEntries = model->itemLibraryEntries(); for (const ItemLibraryEntry &entry : itemLibEntries) { - NodeMetaInfo metaInfo = model->metaInfo(entry.typeName()); + NodeMetaInfo metaInfo; + + if constexpr (useProjectStorage()) + metaInfo = entry.metaInfo(); + else + metaInfo = model->metaInfo(entry.typeName()); bool valid = metaInfo.isValid() && (metaInfo.majorVersion() >= entry.majorVersion() diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp index 3082ee442ac..a6adc0d4f7d 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp @@ -76,9 +76,11 @@ void ItemLibraryView::modelAboutToBeDetached(Model *model) void ItemLibraryView::importsChanged(const Imports &addedImports, const Imports &removedImports) { +#ifndef QDS_USE_PROJECTSTORAGE DesignDocument *document = QmlDesignerPlugin::instance()->currentDesignDocument(); for (const auto &import : addedImports) document->addSubcomponentManagerImport(import); +#endif updateImports(); m_widget->updatePossibleImports(model()->possibleImports()); @@ -114,9 +116,11 @@ void ItemLibraryView::importsChanged(const Imports &addedImports, const Imports void ItemLibraryView::possibleImportsChanged(const Imports &possibleImports) { +#ifndef QDS_USE_PROJECTSTORAGE DesignDocument *document = QmlDesignerPlugin::instance()->currentDesignDocument(); for (const auto &import : possibleImports) document->addSubcomponentManagerImport(import); +#endif m_widget->updatePossibleImports(possibleImports); } diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp index 8d3603ea841..7703f352b0e 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp @@ -14,15 +14,20 @@ #include #include #include +#include #include -#include +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include -#include #include #include #include #include #include +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include #include @@ -176,6 +181,7 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache) ItemLibraryWidget::~ItemLibraryWidget() = default; +#ifndef QDS_USE_PROJECTSTORAGE void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo) { if (m_itemLibraryInfo.data() == itemLibraryInfo) @@ -192,6 +198,7 @@ void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo) } delayedUpdateModel(); } +#endif QList ItemLibraryWidget::createToolBarWidgets() { @@ -271,8 +278,9 @@ void ItemLibraryWidget::setModel(Model *model) m_itemToDrag = {}; return; } - +#ifndef QDS_USE_PROJECTSTORAGE setItemLibraryInfo(model->metaInfo().itemLibraryInfo()); +#endif if (DesignDocument *document = QmlDesignerPlugin::instance()->currentDesignDocument()) { const bool subCompEditMode = document->inFileComponentModelActive(); @@ -321,7 +329,9 @@ void ItemLibraryWidget::updateModel() m_compressionTimer.stop(); } +#ifndef QDS_USE_PROJECTSTORAGE m_itemLibraryModel->update(m_itemLibraryInfo.data(), m_model.data()); +#endif if (m_itemLibraryModel->rowCount() == 0 && !m_updateRetry) { m_updateRetry = true; // Only retry once to avoid endless loops diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h index e791fceb698..b56532b2185 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h @@ -3,7 +3,9 @@ #pragma once -#include "itemlibraryinfo.h" +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include "import.h" #include @@ -51,7 +53,9 @@ public: ItemLibraryWidget(AsynchronousImageCache &imageCache); ~ItemLibraryWidget(); +#ifndef QDS_USE_PROJECTSTORAGE void setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo); +#endif QList createToolBarWidgets(); static QString qmlSourcesPath(); @@ -97,8 +101,9 @@ private: QTimer m_compressionTimer; QSize m_itemIconSize; +#ifndef QDS_USE_PROJECTSTORAGE QPointer m_itemLibraryInfo; - +#endif QPointer m_itemLibraryModel; QPointer m_addModuleModel; diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp index 487d300ef97..6d17a350f4f 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp @@ -4,16 +4,15 @@ #include "materialeditorview.h" #include "asset.h" -#include "bindingproperty.h" #include "auxiliarydataproperties.h" +#include "bindingproperty.h" #include "designdocument.h" #include "designmodewidget.h" #include "dynamicpropertiesmodel.h" #include "externaldependenciesinterface.h" -#include "itemlibraryinfo.h" -#include "materialeditorqmlbackend.h" #include "materialeditorcontextobject.h" #include "materialeditordynamicpropertiesproxymodel.h" +#include "materialeditorqmlbackend.h" #include "materialeditortransaction.h" #include "metainfo.h" #include "nodeinstanceview.h" @@ -25,6 +24,7 @@ #include "qmldesignerplugin.h" #include "qmltimeline.h" #include "variantproperty.h" +#include #include #include @@ -704,7 +704,7 @@ void MaterialEditorView::delayedTypeUpdate() m_typeUpdateTimer.start(); } -static Import entryToImport(const ItemLibraryEntry &entry) +[[maybe_unused]] static Import entryToImport(const ItemLibraryEntry &entry) { if (entry.majorVersion() == -1 && entry.minorVersion() == -1) return Import::createFileImport(entry.requiredImport()); @@ -721,7 +721,15 @@ void MaterialEditorView::updatePossibleTypes() if (!m_qmlBackEnd) return; - // Ensure basic types are always first +#ifdef QDS_USE_PROJECTSTORAGE + auto heirs = model()->qtQuick3DMaterialMetaInfo().heirs(); + heirs.push_back(model()->qtQuick3DMaterialMetaInfo()); + auto entries = Utils::transform(heirs, [&](const auto &heir) { + return toItemLibraryEntries(heir.itemLibrariesEntries(), *model()->projectStorage()); + }); + + // I am unsure about the code intention here +#else // Ensure basic types are always first QStringList nonQuick3dTypes; QStringList allTypes; @@ -755,6 +763,7 @@ void MaterialEditorView::updatePossibleTypes() allTypes.append(nonQuick3dTypes); m_qmlBackEnd->contextObject()->setPossibleTypes(allTypes); +#endif } void MaterialEditorView::modelAttached(Model *model) @@ -774,6 +783,7 @@ void MaterialEditorView::modelAttached(Model *model) m_ensureMatLibTimer.start(500); } +#ifndef QDS_USE_PROJECTSTORAGE if (m_itemLibraryInfo.data() != model->metaInfo().itemLibraryInfo()) { if (m_itemLibraryInfo) { disconnect(m_itemLibraryInfo.data(), &ItemLibraryInfo::entriesChanged, @@ -785,6 +795,7 @@ void MaterialEditorView::modelAttached(Model *model) this, &MaterialEditorView::delayedTypeUpdate); } } +#endif if (!m_setupCompleted) { reloadQml(); diff --git a/src/plugins/qmldesigner/components/navigator/iconcheckboxitemdelegate.cpp b/src/plugins/qmldesigner/components/navigator/iconcheckboxitemdelegate.cpp index d5701ac5691..c24aa1933bf 100644 --- a/src/plugins/qmldesigner/components/navigator/iconcheckboxitemdelegate.cpp +++ b/src/plugins/qmldesigner/components/navigator/iconcheckboxitemdelegate.cpp @@ -10,7 +10,6 @@ #include "navigatortreemodel.h" #include "qproxystyle.h" -#include #include #include diff --git a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp index 1a3814f9618..aacaf6dc0d9 100644 --- a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp +++ b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp @@ -11,7 +11,6 @@ #include "choosefrompropertylistdialog.h" #include "qproxystyle.h" -#include #include #include #include diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp index 6abda00dbac..33ed88ed722 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp @@ -16,8 +16,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp index 6e1532155f5..8de0fb1b01c 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp @@ -12,7 +12,6 @@ #include -#include #include #include diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index 456f44e43c6..a4a7ead0426 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -13,18 +13,18 @@ #include #include #include -#include +#include #include #include #include #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include #include diff --git a/src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp b/src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp index eeb1dbe88d6..6fcedfa7434 100644 --- a/src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp +++ b/src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include "pathtool.h" diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp index d088dd7a26a..47d85c4dbc3 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h index 7baa07e9d30..dd5e0b0cc98 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include #include @@ -119,7 +118,6 @@ private: bool m_initializingPreviewData = false; QPointer m_colorDialog; - QPointer m_itemLibraryInfo; DynamicPropertiesModel *m_dynamicPropertiesModel = nullptr; }; diff --git a/src/plugins/qmldesigner/designercore/exceptions/invalidmetainfoexception.cpp b/src/plugins/qmldesigner/designercore/exceptions/invalidmetainfoexception.cpp index 3dc8c19d393..fbf32676896 100644 --- a/src/plugins/qmldesigner/designercore/exceptions/invalidmetainfoexception.cpp +++ b/src/plugins/qmldesigner/designercore/exceptions/invalidmetainfoexception.cpp @@ -18,9 +18,9 @@ namespace QmlDesigner { the __FILE__ macro. */ InvalidMetaInfoException::InvalidMetaInfoException(int line, - const QByteArray &function, - const QByteArray &file) - : Exception(line, function, file) + const QByteArray &function, + const QByteArray &file) + : Exception(line, function, file) { createWarning(); } diff --git a/src/plugins/qmldesigner/designercore/imagecache/imagecachecollector.cpp b/src/plugins/qmldesigner/designercore/imagecache/imagecachecollector.cpp index 344bd4a0191..4530290fbe3 100644 --- a/src/plugins/qmldesigner/designercore/imagecache/imagecachecollector.cpp +++ b/src/plugins/qmldesigner/designercore/imagecache/imagecachecollector.cpp @@ -4,9 +4,9 @@ #include "imagecachecollector.h" #include "imagecacheconnectionmanager.h" -#include #include #include +#include #include #include @@ -21,7 +21,7 @@ namespace QmlDesigner { namespace { -QByteArray fileToByteArray(QString const &filename) +QByteArray fileToByteArray(const QString &filename) { QFile file(filename); QFileInfo fleInfo(file); diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h index 0a3350b693b..71c675fd3cb 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/designercore/include/abstractview.h @@ -79,7 +79,7 @@ public: ~AbstractView() override; - Model *model() const; + Model *model() const { return m_model.data(); } bool isAttached() const; RewriterTransaction beginRewriterTransaction(const QByteArray &identifier); diff --git a/src/plugins/qmldesigner/designercore/include/itemlibraryentry.h b/src/plugins/qmldesigner/designercore/include/itemlibraryentry.h new file mode 100644 index 00000000000..f88f9e35c6f --- /dev/null +++ b/src/plugins/qmldesigner/designercore/include/itemlibraryentry.h @@ -0,0 +1,93 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "qmldesignercorelib_global.h" + +#include "propertycontainer.h" + +#include + +#include +#include +#include +#include + +namespace QmlDesigner { + +namespace Internal { + +class ItemLibraryEntryData; +class MetaInfoPrivate; +} // namespace Internal + +class ItemLibraryEntry; +class NodeMetaInfo; + +QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, + const ItemLibraryEntry &itemLibraryEntry); +QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, + ItemLibraryEntry &itemLibraryEntry); +QMLDESIGNERCORE_EXPORT QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry); + +class QMLDESIGNERCORE_EXPORT ItemLibraryEntry +{ + friend QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, + const ItemLibraryEntry &itemLibraryEntry); + friend QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, + ItemLibraryEntry &itemLibraryEntry); + friend QMLDESIGNERCORE_EXPORT QDebug operator<<(QDebug debug, + const ItemLibraryEntry &itemLibraryEntry); + +public: + ItemLibraryEntry(); + explicit ItemLibraryEntry(const Storage::Info::ItemLibraryEntry &entry, + const ProjectStorageType &projectStorage); + ~ItemLibraryEntry() = default; + + QString name() const; + TypeName typeName() const; + const NodeMetaInfo &metaInfo() const; + QIcon typeIcon() const; + QString libraryEntryIconPath() const; + int majorVersion() const; + int minorVersion() const; + QString category() const; + QString qmlSource() const; + QString requiredImport() const; + QString customComponentSource() const; + QStringList extraFilePaths() const; + QString toolTip() const; + + using Property = QmlDesigner::PropertyContainer; + + QList properties() const; + QHash hints() const; + + void setType(const TypeName &typeName, int majorVersion = -1, int minorVersion = -1); + void setName(const QString &name); + void setLibraryEntryIconPath(const QString &libraryEntryIconPath); + void addProperty(const Property &p); + void addProperty(PropertyName &name, QString &type, QVariant &value); + void setTypeIcon(const QIcon &typeIcon); + void setCategory(const QString &category); + void setQmlPath(const QString &qml); + void setRequiredImport(const QString &requiredImport); + void setToolTip(const QString &tooltip); + void addHints(const QHash &hints); + void setCustomComponentSource(const QString &source); + void addExtraFilePath(const QString &extraFile); + +private: + std::shared_ptr m_data; +}; + +using ItemLibraryEntries = QList; + +QMLDESIGNERCORE_EXPORT QList toItemLibraryEntries( + const Storage::Info::ItemLibraryEntries &entries, const ProjectStorageType &projectStorage); + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::ItemLibraryEntry) diff --git a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h index 2974d58d0b5..99c10f11ed2 100644 --- a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h +++ b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h @@ -3,76 +3,12 @@ #pragma once -#include "qmldesignercorelib_global.h" +#ifndef QDS_USE_PROJECTSTORAGE -#include "propertycontainer.h" -#include -#include -#include -#include +# include "itemlibraryentry.h" namespace QmlDesigner { -namespace Internal { - -class ItemLibraryEntryData; -class MetaInfoPrivate; -} - -class ItemLibraryEntry; - -QMLDESIGNERCORE_EXPORT QDataStream& operator<<(QDataStream& stream, const ItemLibraryEntry &itemLibraryEntry); -QMLDESIGNERCORE_EXPORT QDataStream& operator>>(QDataStream& stream, ItemLibraryEntry &itemLibraryEntry); -QMLDESIGNERCORE_EXPORT QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry); - -class QMLDESIGNERCORE_EXPORT ItemLibraryEntry -{ - friend QMLDESIGNERCORE_EXPORT QDataStream& operator<<(QDataStream& stream, const ItemLibraryEntry &itemLibraryEntry); - friend QMLDESIGNERCORE_EXPORT QDataStream& operator>>(QDataStream& stream, ItemLibraryEntry &itemLibraryEntry); - friend QMLDESIGNERCORE_EXPORT QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry); - -public: - ItemLibraryEntry(); - ~ItemLibraryEntry() = default; - - QString name() const; - TypeName typeName() const; - QIcon typeIcon() const; - QString libraryEntryIconPath() const; - int majorVersion() const; - int minorVersion() const; - QString category() const; - QIcon dragIcon() const; - QString qmlPath() const; - QString qmlSource() const; - QString requiredImport() const; - QString customComponentSource() const; - QStringList extraFilePaths() const; - QString toolTip() const; - - using Property = QmlDesigner::PropertyContainer; - - QList properties() const; - QHash hints() const; - - void setType(const TypeName &typeName, int majorVersion = -1, int minorVersion = -1); - void setName(const QString &name); - void setLibraryEntryIconPath(const QString &libraryEntryIconPath); - void addProperty(const Property &p); - void addProperty(PropertyName &name, QString &type, QVariant &value); - void setTypeIcon(const QIcon &typeIcon); - void setCategory(const QString &category); - void setQmlPath(const QString &qml); - void setRequiredImport(const QString &requiredImport); - void setToolTip(const QString &tooltip); - void addHints(const QHash &hints); - void setCustomComponentSource(const QString &source); - void addExtraFilePath(const QString &extraFile); - -private: - std::shared_ptr m_data; -}; - class QMLDESIGNERCORE_EXPORT ItemLibraryInfo : public QObject { Q_OBJECT @@ -101,5 +37,4 @@ private: // variables }; } // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ItemLibraryEntry) +#endif diff --git a/src/plugins/qmldesigner/designercore/include/metainfo.h b/src/plugins/qmldesigner/designercore/include/metainfo.h index 914be96db7b..b176831eb6d 100644 --- a/src/plugins/qmldesigner/designercore/include/metainfo.h +++ b/src/plugins/qmldesigner/designercore/include/metainfo.h @@ -3,13 +3,15 @@ #pragma once -#include "qmldesignercorelib_global.h" +#ifndef QDS_USE_PROJECTSTORAGE -#include -#include +# include "qmldesignercorelib_global.h" -#include -#include "itemlibraryinfo.h" +# include +# include + +# include +# include "itemlibraryinfo.h" namespace QmlDesigner { @@ -63,3 +65,4 @@ private: }; } //namespace QmlDesigner +#endif diff --git a/src/plugins/qmldesigner/designercore/include/metainforeader.h b/src/plugins/qmldesigner/designercore/include/metainforeader.h index b10c7413c59..c12d507ed9c 100644 --- a/src/plugins/qmldesigner/designercore/include/metainforeader.h +++ b/src/plugins/qmldesigner/designercore/include/metainforeader.h @@ -3,13 +3,15 @@ #pragma once -#include "qmldesignercorelib_global.h" -#include +#ifndef QDS_USE_PROJECTSTORAGE -#include +# include "qmldesignercorelib_global.h" +# include -#include -#include +# include + +# include +# include namespace QmlDesigner { @@ -106,3 +108,5 @@ private: } } + +#endif diff --git a/src/plugins/qmldesigner/designercore/include/model.h b/src/plugins/qmldesigner/designercore/include/model.h index cc3b4aadf9c..9816857db65 100644 --- a/src/plugins/qmldesigner/designercore/include/model.h +++ b/src/plugins/qmldesigner/designercore/include/model.h @@ -10,11 +10,13 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -44,6 +46,7 @@ class AbstractProperty; class RewriterView; class NodeInstanceView; class TextModifier; +class ItemLibraryEntry; using PropertyListType = QList>; @@ -125,15 +128,18 @@ public: SourceId fileUrlSourceId() const; void setFileUrl(const QUrl &url); +#ifndef QDS_USE_PROJECTSTORAGE const MetaInfo metaInfo() const; MetaInfo metaInfo(); + void setMetaInfo(const MetaInfo &metaInfo); +#endif + Module module(Utils::SmallStringView moduleName); NodeMetaInfo metaInfo(const TypeName &typeName, int majorVersion = -1, int minorVersion = -1) const; NodeMetaInfo metaInfo(Module module, Utils::SmallStringView typeName, Storage::Version version = Storage::Version{}) const; bool hasNodeMetaInfo(const TypeName &typeName, int majorVersion = -1, int minorVersion = -1) const; - void setMetaInfo(const MetaInfo &metaInfo); NodeMetaInfo boolMetaInfo() const; NodeMetaInfo doubleMetaInfo() const; @@ -148,10 +154,15 @@ public: NodeMetaInfo qtQmlModelsListElementMetaInfo() const; NodeMetaInfo qtQuick3DBakedLightmapMetaInfo() const; NodeMetaInfo qtQuick3DDefaultMaterialMetaInfo() const; + NodeMetaInfo qtQuick3DDirectionalLightMetaInfo() const; NodeMetaInfo qtQuick3DMaterialMetaInfo() const; NodeMetaInfo qtQuick3DModelMetaInfo() const; NodeMetaInfo qtQuick3DNodeMetaInfo() const; + NodeMetaInfo qtQuick3DOrthographicCameraMetaInfo() const; + NodeMetaInfo qtQuick3DPerspectiveCameraMetaInfo() const; + NodeMetaInfo qtQuick3DPointLightMetaInfo() const; NodeMetaInfo qtQuick3DPrincipledMaterialMetaInfo() const; + NodeMetaInfo qtQuick3DSpotLightMetaInfo() const; NodeMetaInfo qtQuick3DTextureMetaInfo() const; NodeMetaInfo qtQuickConnectionsMetaInfo() const; NodeMetaInfo qtQuickControlsTextAreaMetaInfo() const; @@ -169,6 +180,9 @@ public: NodeMetaInfo vector2dMetaInfo() const; NodeMetaInfo vector3dMetaInfo() const; NodeMetaInfo vector4dMetaInfo() const; + QVarLengthArray metaInfosForModule(Module module) const; + + QList itemLibraryEntries() const; void attachView(AbstractView *view); void detachView(AbstractView *view, ViewNotification emitDetachNotify = NotifyView); diff --git a/src/plugins/qmldesigner/designercore/include/nodehints.h b/src/plugins/qmldesigner/designercore/include/nodehints.h index 8bdb30f5a38..9e67c2d99b3 100644 --- a/src/plugins/qmldesigner/designercore/include/nodehints.h +++ b/src/plugins/qmldesigner/designercore/include/nodehints.h @@ -58,8 +58,9 @@ public: private: explicit NodeHints(const ModelNode &modelNode); + explicit NodeHints(const NodeMetaInfo &metaInfo); explicit NodeHints(const ItemLibraryEntry &entry); - ModelNode modelNode() const; + const ModelNode &modelNode() const; bool isValid() const; Model *model() const; bool evaluateBooleanExpression(const QString &hintName, bool defaultValue, const ModelNode potentialParent = ModelNode()) const; diff --git a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h index 02a0c81ca4a..58cdeba228e 100644 --- a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h +++ b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h @@ -33,6 +33,8 @@ enum class MetaInfoType { None, Reference, Value, Sequence }; class QMLDESIGNERCORE_EXPORT NodeMetaInfo { + using NodeMetaInfos = std::vector; + public: NodeMetaInfo(); NodeMetaInfo(Model *model, const TypeName &typeName, int majorVersion, int minorVersion); @@ -59,6 +61,20 @@ public: bool isFileComponent() const; bool isProjectComponent() const; bool isInProjectModule() const; + FlagIs canBeContainer() const; + FlagIs forceClip() const; + FlagIs doesLayoutChildren() const; + FlagIs canBeDroppedInFormEditor() const; + FlagIs canBeDroppedInNavigator() const; + FlagIs canBeDroppedInView3D() const; + FlagIs isMovable() const; + FlagIs isResizable() const; + FlagIs hasFormEditorItem() const; + FlagIs isStackedContainer() const; + FlagIs takesOverRenderingOfChildren() const; + FlagIs visibleInNavigator() const; + FlagIs visibleInLibrary() const; + bool hasProperty(::Utils::SmallStringView propertyName) const; PropertyMetaInfos properties() const; PropertyMetaInfos localProperties() const; @@ -69,8 +85,9 @@ public: PropertyMetaInfo defaultProperty() const; bool hasDefaultProperty() const; - std::vector selfAndPrototypes() const; - std::vector prototypes() const; + NodeMetaInfos selfAndPrototypes() const; + NodeMetaInfos prototypes() const; + NodeMetaInfos heirs() const; NodeMetaInfo commonBase(const NodeMetaInfo &metaInfo) const; bool defaultPropertyIsComponent() const; @@ -83,6 +100,10 @@ public: Storage::Info::ExportedTypeNames allExportedTypeNames() const; Storage::Info::ExportedTypeNames exportedTypeNamesForSourceId(SourceId sourceId) const; + Storage::Info::TypeHints typeHints() const; + Utils::PathString iconPath() const; + Storage::Info::ItemLibraryEntries itemLibrariesEntries() const; + SourceId sourceId() const; QString componentFileName() const; diff --git a/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h b/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h index dbc89c1cccd..7fa23488543 100644 --- a/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h +++ b/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h @@ -3,18 +3,20 @@ #pragma once -#include "qmldesignercorelib_global.h" +#ifndef QDS_USE_PROJECTSTORAGE -#include +# include "qmldesignercorelib_global.h" -#include -#include -#include -#include -#include -#include -#include -#include +# include + +# include +# include +# include +# include +# include +# include +# include +# include namespace QmlDesigner { @@ -63,3 +65,4 @@ private: // variables }; } // namespace QmlDesigner +#endif diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index 641455910a0..e187d4986f4 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include diff --git a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryentry.cpp b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryentry.cpp new file mode 100644 index 00000000000..806da7e7c4d --- /dev/null +++ b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryentry.cpp @@ -0,0 +1,306 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "../include/itemlibraryentry.h" +#include "nodemetainfo.h" +#include "qregularexpression.h" + +#include +#include + +#include + +#include +#include + +namespace QmlDesigner { + +namespace Internal { + +class ItemLibraryEntryData +{ +public: + QString name; + TypeName typeName; + NodeMetaInfo metaInfo; + QString category; + int majorVersion{-1}; + int minorVersion{-1}; + QString libraryEntryIconPath; + QIcon typeIcon = QIcon(":/ItemLibrary/images/item-default-icon.png"); + QList properties; + QString qml; + QString qmlSource; + QString requiredImport; + QHash hints; + QString customComponentSource; + QStringList extraFilePaths; + QString toolTip; +}; + +} // namespace Internal + +void ItemLibraryEntry::setTypeIcon(const QIcon &icon) +{ + m_data->typeIcon = icon; +} + +void ItemLibraryEntry::addProperty(const Property &property) +{ + m_data->properties.append(property); +} + +QList ItemLibraryEntry::properties() const +{ + return m_data->properties; +} + +QHash ItemLibraryEntry::hints() const +{ + return m_data->hints; +} + +ItemLibraryEntry::ItemLibraryEntry() + : m_data(std::make_shared()) +{} + +ItemLibraryEntry::ItemLibraryEntry(const Storage::Info::ItemLibraryEntry &entry, + const ProjectStorageType &projectStorage) + : ItemLibraryEntry{} +{ + m_data->name = entry.name.toQString(); + m_data->metaInfo = {entry.typeId, &projectStorage}; + m_data->category = entry.category.toQString(); + if (entry.iconPath.size()) + m_data->libraryEntryIconPath = entry.iconPath.toQString(); + m_data->requiredImport = entry.import.toQString(); + m_data->toolTip = entry.toolTip.toQString(); + m_data->qmlSource = entry.templatePath.toQString(); + m_data->properties.reserve(Utils::ssize(entry.properties)); + for (const auto &property : entry.properties) { + m_data->properties.emplace_back(property.name.toQByteArray(), + property.type.toQString(), + QVariant{property.value}); + } + m_data->extraFilePaths.reserve(Utils::ssize(entry.extraFilePaths)); + for (const auto &extraFilePath : entry.extraFilePaths) + m_data->extraFilePaths.emplace_back(extraFilePath.toQString()); +} + +QString ItemLibraryEntry::name() const +{ + return m_data->name; +} + +TypeName ItemLibraryEntry::typeName() const +{ + return m_data->typeName; +} + +const NodeMetaInfo &ItemLibraryEntry::metaInfo() const +{ + return m_data->metaInfo; +} + +QString ItemLibraryEntry::qmlSource() const +{ + return m_data->qmlSource; +} + +QString ItemLibraryEntry::requiredImport() const +{ + return m_data->requiredImport; +} + +QString ItemLibraryEntry::customComponentSource() const +{ + return m_data->customComponentSource; +} + +QStringList ItemLibraryEntry::extraFilePaths() const +{ + return m_data->extraFilePaths; +} + +QString ItemLibraryEntry::toolTip() const +{ + return m_data->toolTip; +} + +int ItemLibraryEntry::majorVersion() const +{ + return m_data->majorVersion; +} + +int ItemLibraryEntry::minorVersion() const +{ + return m_data->minorVersion; +} + +QString ItemLibraryEntry::category() const +{ + return m_data->category; +} + +void ItemLibraryEntry::setCategory(const QString &category) +{ + m_data->category = category; +} + +QIcon ItemLibraryEntry::typeIcon() const +{ + return m_data->typeIcon; +} + +QString ItemLibraryEntry::libraryEntryIconPath() const +{ + return m_data->libraryEntryIconPath; +} + +void ItemLibraryEntry::setName(const QString &name) +{ + m_data->name = name; +} + +void ItemLibraryEntry::setType(const TypeName &typeName, int majorVersion, int minorVersion) +{ + m_data->typeName = typeName; + m_data->majorVersion = majorVersion; + m_data->minorVersion = minorVersion; +} + +void ItemLibraryEntry::setLibraryEntryIconPath(const QString &iconPath) +{ + m_data->libraryEntryIconPath = iconPath; +} + +static QByteArray getSourceForUrl(const QString &fileURl) +{ + Utils::FileReader fileReader; + + if (fileReader.fetch(Utils::FilePath::fromString(fileURl))) + return fileReader.data(); + else + return Utils::FileReader::fetchQrc(fileURl); +} + +void ItemLibraryEntry::setQmlPath(const QString &qml) +{ + m_data->qml = qml; + + m_data->qmlSource = QString::fromUtf8(getSourceForUrl(qml)); +} + +void ItemLibraryEntry::setRequiredImport(const QString &requiredImport) +{ + m_data->requiredImport = requiredImport; +} + +void ItemLibraryEntry::setToolTip(const QString &tooltip) +{ + static QRegularExpression regularExpressionPattern(QLatin1String("^qsTr\\(\"(.*)\"\\)$")); + const QRegularExpressionMatch match = regularExpressionPattern.match(tooltip); + if (match.hasMatch()) + m_data->toolTip = match.captured(1); + else + m_data->toolTip = tooltip; +} + +void ItemLibraryEntry::addHints(const QHash &hints) +{ + Utils::addToHash(&m_data->hints, hints); +} + +void ItemLibraryEntry::setCustomComponentSource(const QString &source) +{ + m_data->customComponentSource = source; +} + +void ItemLibraryEntry::addExtraFilePath(const QString &extraFile) +{ + m_data->extraFilePaths.append(extraFile); +} + +void ItemLibraryEntry::addProperty(PropertyName &name, QString &type, QVariant &value) +{ + Property property; + property.set(name, type, value); + addProperty(property); +} + +QDataStream &operator<<(QDataStream &stream, const ItemLibraryEntry &itemLibraryEntry) +{ + stream << itemLibraryEntry.name(); + stream << itemLibraryEntry.typeName(); + stream << itemLibraryEntry.majorVersion(); + stream << itemLibraryEntry.minorVersion(); + stream << itemLibraryEntry.typeIcon(); + stream << itemLibraryEntry.libraryEntryIconPath(); + stream << itemLibraryEntry.category(); + stream << itemLibraryEntry.requiredImport(); + stream << itemLibraryEntry.hints(); + + stream << itemLibraryEntry.m_data->properties; + stream << itemLibraryEntry.m_data->qml; + stream << itemLibraryEntry.m_data->qmlSource; + stream << itemLibraryEntry.m_data->customComponentSource; + stream << itemLibraryEntry.m_data->extraFilePaths; + + return stream; +} + +QDataStream &operator>>(QDataStream &stream, ItemLibraryEntry &itemLibraryEntry) +{ + // Clear containers so that we don't simply append to them in case the object is reused + itemLibraryEntry.m_data->hints.clear(); + itemLibraryEntry.m_data->properties.clear(); + + stream >> itemLibraryEntry.m_data->name; + stream >> itemLibraryEntry.m_data->typeName; + stream >> itemLibraryEntry.m_data->majorVersion; + stream >> itemLibraryEntry.m_data->minorVersion; + stream >> itemLibraryEntry.m_data->typeIcon; + stream >> itemLibraryEntry.m_data->libraryEntryIconPath; + stream >> itemLibraryEntry.m_data->category; + stream >> itemLibraryEntry.m_data->requiredImport; + stream >> itemLibraryEntry.m_data->hints; + + stream >> itemLibraryEntry.m_data->properties; + stream >> itemLibraryEntry.m_data->qml; + stream >> itemLibraryEntry.m_data->qmlSource; + stream >> itemLibraryEntry.m_data->customComponentSource; + stream >> itemLibraryEntry.m_data->extraFilePaths; + + return stream; +} + +QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry) +{ + debug << itemLibraryEntry.m_data->name; + debug << itemLibraryEntry.m_data->typeName; + debug << itemLibraryEntry.m_data->majorVersion; + debug << itemLibraryEntry.m_data->minorVersion; + debug << itemLibraryEntry.m_data->typeIcon; + debug << itemLibraryEntry.m_data->libraryEntryIconPath; + debug << itemLibraryEntry.m_data->category; + debug << itemLibraryEntry.m_data->requiredImport; + debug << itemLibraryEntry.m_data->hints; + + debug << itemLibraryEntry.m_data->properties; + debug << itemLibraryEntry.m_data->qml; + debug << itemLibraryEntry.m_data->qmlSource; + debug << itemLibraryEntry.m_data->customComponentSource; + debug << itemLibraryEntry.m_data->extraFilePaths; + + return debug.space(); +} + +QList toItemLibraryEntries(const Storage::Info::ItemLibraryEntries &entries, + const ProjectStorageType &projectStorage) +{ + return Utils::transform>(entries, [&](const auto &entry) { + return ItemLibraryEntry{entry, projectStorage}; + }); +} + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp index 9f542826156..9f8b43f9209 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp @@ -2,280 +2,12 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "../include/itemlibraryinfo.h" -#include "nodemetainfo.h" -#include "qregularexpression.h" #include #include -#include - -#include -#include - namespace QmlDesigner { -namespace Internal { - -class ItemLibraryEntryData -{ -public: - QString name; - TypeName typeName; - QString category; - int majorVersion{-1}; - int minorVersion{-1}; - QString libraryEntryIconPath; - QIcon typeIcon = QIcon(":/ItemLibrary/images/item-default-icon.png"); - QList properties; - QString qml; - QString qmlSource; - QString requiredImport; - QHash hints; - QString customComponentSource; - QStringList extraFilePaths; - QString toolTip; -}; - -} // namespace Internal - -void ItemLibraryEntry::setTypeIcon(const QIcon &icon) -{ - m_data->typeIcon = icon; -} - -void ItemLibraryEntry::addProperty(const Property &property) -{ - m_data->properties.append(property); -} - -QList ItemLibraryEntry::properties() const -{ - return m_data->properties; -} - -QHash ItemLibraryEntry::hints() const -{ - return m_data->hints; -} - -ItemLibraryEntry::ItemLibraryEntry() : m_data(new Internal::ItemLibraryEntryData) -{ - m_data->name.clear(); -} - -QString ItemLibraryEntry::name() const -{ - return m_data->name; -} - -TypeName ItemLibraryEntry::typeName() const -{ - return m_data->typeName; -} - -QString ItemLibraryEntry::qmlPath() const -{ - return m_data->qml; -} - -QString ItemLibraryEntry::qmlSource() const -{ - return m_data->qmlSource; -} - -QString ItemLibraryEntry::requiredImport() const -{ - return m_data->requiredImport; -} - -QString ItemLibraryEntry::customComponentSource() const -{ - return m_data->customComponentSource; -} - -QStringList ItemLibraryEntry::extraFilePaths() const -{ - return m_data->extraFilePaths; -} - -QString ItemLibraryEntry::toolTip() const -{ - return m_data->toolTip; -} - -int ItemLibraryEntry::majorVersion() const -{ - return m_data->majorVersion; -} - -int ItemLibraryEntry::minorVersion() const -{ - return m_data->minorVersion; -} - -QString ItemLibraryEntry::category() const -{ - return m_data->category; -} - -void ItemLibraryEntry::setCategory(const QString &category) -{ - m_data->category = category; -} - -QIcon ItemLibraryEntry::typeIcon() const -{ - return m_data->typeIcon; -} - -QString ItemLibraryEntry::libraryEntryIconPath() const -{ - return m_data->libraryEntryIconPath; -} - -void ItemLibraryEntry::setName(const QString &name) -{ - m_data->name = name; -} - -void ItemLibraryEntry::setType(const TypeName &typeName, int majorVersion, int minorVersion) -{ - m_data->typeName = typeName; - m_data->majorVersion = majorVersion; - m_data->minorVersion = minorVersion; -} - -void ItemLibraryEntry::setLibraryEntryIconPath(const QString &iconPath) -{ - m_data->libraryEntryIconPath = iconPath; -} - -static QByteArray getSourceForUrl(const QString &fileURl) -{ - Utils::FileReader fileReader; - - if (fileReader.fetch(Utils::FilePath::fromString(fileURl))) - return fileReader.data(); - else - return Utils::FileReader::fetchQrc(fileURl); -} - -void ItemLibraryEntry::setQmlPath(const QString &qml) -{ - m_data->qml = qml; - - m_data->qmlSource = QString::fromUtf8(getSourceForUrl(qml)); -} - -void ItemLibraryEntry::setRequiredImport(const QString &requiredImport) -{ - m_data->requiredImport = requiredImport; -} - -void ItemLibraryEntry::setToolTip(const QString &tooltip) -{ - static QRegularExpression regularExpressionPattern(QLatin1String("^qsTr\\(\"(.*)\"\\)$")); - const QRegularExpressionMatch match = regularExpressionPattern.match(tooltip); - if (match.hasMatch()) - m_data->toolTip = match.captured(1); - else - m_data->toolTip = tooltip; -} - -void ItemLibraryEntry::addHints(const QHash &hints) -{ - Utils::addToHash(&m_data->hints, hints); -} - -void ItemLibraryEntry::setCustomComponentSource(const QString &source) -{ - m_data->customComponentSource = source; -} - -void ItemLibraryEntry::addExtraFilePath(const QString &extraFile) -{ - m_data->extraFilePaths.append(extraFile); -} - -void ItemLibraryEntry::addProperty(PropertyName &name, QString &type, QVariant &value) -{ - Property property; - property.set(name, type, value); - addProperty(property); -} - -QDataStream& operator<<(QDataStream& stream, const ItemLibraryEntry &itemLibraryEntry) -{ - stream << itemLibraryEntry.name(); - stream << itemLibraryEntry.typeName(); - stream << itemLibraryEntry.majorVersion(); - stream << itemLibraryEntry.minorVersion(); - stream << itemLibraryEntry.typeIcon(); - stream << itemLibraryEntry.libraryEntryIconPath(); - stream << itemLibraryEntry.category(); - stream << itemLibraryEntry.requiredImport(); - stream << itemLibraryEntry.hints(); - - stream << itemLibraryEntry.m_data->properties; - stream << itemLibraryEntry.m_data->qml; - stream << itemLibraryEntry.m_data->qmlSource; - stream << itemLibraryEntry.m_data->customComponentSource; - stream << itemLibraryEntry.m_data->extraFilePaths; - - return stream; -} - -QDataStream& operator>>(QDataStream& stream, ItemLibraryEntry &itemLibraryEntry) -{ - // Clear containers so that we don't simply append to them in case the object is reused - itemLibraryEntry.m_data->hints.clear(); - itemLibraryEntry.m_data->properties.clear(); - - stream >> itemLibraryEntry.m_data->name; - stream >> itemLibraryEntry.m_data->typeName; - stream >> itemLibraryEntry.m_data->majorVersion; - stream >> itemLibraryEntry.m_data->minorVersion; - stream >> itemLibraryEntry.m_data->typeIcon; - stream >> itemLibraryEntry.m_data->libraryEntryIconPath; - stream >> itemLibraryEntry.m_data->category; - stream >> itemLibraryEntry.m_data->requiredImport; - stream >> itemLibraryEntry.m_data->hints; - - stream >> itemLibraryEntry.m_data->properties; - stream >> itemLibraryEntry.m_data->qml; - stream >> itemLibraryEntry.m_data->qmlSource; - stream >> itemLibraryEntry.m_data->customComponentSource; - stream >> itemLibraryEntry.m_data->extraFilePaths; - - return stream; -} - -QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry) -{ - debug << itemLibraryEntry.m_data->name; - debug << itemLibraryEntry.m_data->typeName; - debug << itemLibraryEntry.m_data->majorVersion; - debug << itemLibraryEntry.m_data->minorVersion; - debug << itemLibraryEntry.m_data->typeIcon; - debug << itemLibraryEntry.m_data->libraryEntryIconPath; - debug << itemLibraryEntry.m_data->category; - debug << itemLibraryEntry.m_data->requiredImport; - debug << itemLibraryEntry.m_data->hints; - - debug << itemLibraryEntry.m_data->properties; - debug << itemLibraryEntry.m_data->qml; - debug << itemLibraryEntry.m_data->qmlSource; - debug << itemLibraryEntry.m_data->customComponentSource; - debug << itemLibraryEntry.m_data->extraFilePaths; - - return debug.space(); -} - -// -// ItemLibraryInfo -// - ItemLibraryInfo::ItemLibraryInfo(QObject *parent) : QObject(parent) { @@ -306,7 +38,7 @@ QList ItemLibraryInfo::entries() const return list; } -static inline QString keyForEntry(const ItemLibraryEntry &entry) +inline static QString keyForEntry(const ItemLibraryEntry &entry) { return entry.name() + entry.category() + QString::number(entry.majorVersion()); } diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp index 8cdc590135f..149bb768777 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp @@ -6,10 +6,11 @@ #include "metainfo.h" #include -#include -#include +#include #include #include +#include +#include #include @@ -21,7 +22,9 @@ #include -#include +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include @@ -65,8 +68,15 @@ static QVariant evaluateExpression(const QString &expression, const ModelNode &m } //Internal -QmlDesigner::NodeHints::NodeHints(const ModelNode &node) : m_modelNode(node) +QmlDesigner::NodeHints::NodeHints(const ModelNode &node) +#ifdef QDS_USE_PROJECTSTORAGE + : NodeHints{node.metaInfo()} +#else + : m_modelNode(node) +#endif { +#ifndef QDS_USE_PROJECTSTORAGE + if (!isValid()) return; @@ -92,13 +102,31 @@ QmlDesigner::NodeHints::NodeHints(const ModelNode &node) : m_modelNode(node) } } +#endif +} + +NodeHints::NodeHints(const NodeMetaInfo &metaInfo) +{ + for (const auto &[name, expression] : metaInfo.typeHints()) + m_hints.insert(name.toQString(), expression.toQString()); } NodeHints::NodeHints(const ItemLibraryEntry &entry) +#ifdef QDS_USE_PROJECTSTORAGE + : NodeHints{entry.metaInfo()} +#endif { - m_hints = entry.hints(); + if constexpr (!useProjectStorage()) + m_hints = entry.hints(); } +namespace { +bool convert(FlagIs flagIs) +{ + return flagIs == FlagIs::True ? true : false; +} +} // namespace + bool NodeHints::canBeContainerFor(const ModelNode &potenialChild) const { /* The default is true for now to avoid confusion. Once our .metaInfo files in Qt @@ -107,6 +135,11 @@ bool NodeHints::canBeContainerFor(const ModelNode &potenialChild) const if (!isValid()) return true; + auto flagIs = m_modelNode.metaInfo().canBeContainer(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("canBeContainer", true, potenialChild); } @@ -118,6 +151,11 @@ bool NodeHints::forceClip() const if (isSwipeView(modelNode())) return true; + auto flagIs = m_modelNode.metaInfo().forceClip(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("forceClip", false); } @@ -129,21 +167,50 @@ bool NodeHints::doesLayoutChildren() const if (isSwipeView(modelNode())) return true; + auto flagIs = m_modelNode.metaInfo().doesLayoutChildren(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("doesLayoutChildren", false); } bool NodeHints::canBeDroppedInFormEditor() const { + if (!isValid()) + return true; + + auto flagIs = m_modelNode.metaInfo().canBeDroppedInFormEditor(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("canBeDroppedInFormEditor", true); } bool NodeHints::canBeDroppedInNavigator() const { + if (!isValid()) + return true; + + auto flagIs = m_modelNode.metaInfo().canBeDroppedInNavigator(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("canBeDroppedInNavigator", true); } bool NodeHints::canBeDroppedInView3D() const { + if (!isValid()) + return false; + + auto flagIs = m_modelNode.metaInfo().canBeDroppedInView3D(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("canBeDroppedInView3D", false); } @@ -152,16 +219,37 @@ bool NodeHints::isMovable() const if (!isValid()) return true; + auto flagIs = m_modelNode.metaInfo().isMovable(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("isMovable", true); } bool NodeHints::isResizable() const { + if (!isValid()) + return true; + + auto flagIs = m_modelNode.metaInfo().isResizable(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("isResizable", true); } bool NodeHints::hasFormEditorItem() const { + if (!isValid()) + return true; + + auto flagIs = m_modelNode.metaInfo().hasFormEditorItem(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("hasFormEditorItem", true); } @@ -173,6 +261,11 @@ bool NodeHints::isStackedContainer() const if (isSwipeView(modelNode())) return true; + auto flagIs = m_modelNode.metaInfo().isStackedContainer(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("isStackedContainer", false); } @@ -215,6 +308,11 @@ bool NodeHints::takesOverRenderingOfChildren() const if (!isValid()) return false; + auto flagIs = m_modelNode.metaInfo().takesOverRenderingOfChildren(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("takesOverRenderingOfChildren", false); } @@ -223,11 +321,24 @@ bool NodeHints::visibleInNavigator() const if (!isValid()) return false; + auto flagIs = m_modelNode.metaInfo().visibleInNavigator(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("visibleInNavigator", false); } bool NodeHints::visibleInLibrary() const { + if (!isValid()) + return true; + + auto flagIs = m_modelNode.metaInfo().visibleInLibrary(); + + if (flagIs != FlagIs::Set) + return convert(flagIs); + return evaluateBooleanExpression("visibleInLibrary", true); } @@ -297,7 +408,7 @@ NodeHints NodeHints::fromItemLibraryEntry(const ItemLibraryEntry &entry) return NodeHints(entry); } -ModelNode NodeHints::modelNode() const +const ModelNode &NodeHints::modelNode() const { return m_modelNode; } diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 5ed270bf8cb..d21d8b44f86 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -1478,12 +1478,12 @@ MetaInfoType NodeMetaInfo::type() const { if constexpr (useProjectStorage()) { if (isValid()) { - switch (typeData().traits) { - case Storage::TypeTraits::Reference: + switch (typeData().traits.kind) { + case Storage::TypeTraitsKind::Reference: return MetaInfoType::Reference; - case Storage::TypeTraits::Value: + case Storage::TypeTraitsKind::Value: return MetaInfoType::Value; - case Storage::TypeTraits::Sequence: + case Storage::TypeTraitsKind::Sequence: return MetaInfoType::Sequence; default: break; @@ -1497,7 +1497,7 @@ MetaInfoType NodeMetaInfo::type() const bool NodeMetaInfo::isFileComponent() const { if constexpr (useProjectStorage()) - return isValid() && bool(typeData().traits & Storage::TypeTraits::IsFileComponent); + return isValid() && typeData().traits.isFileComponent; else return isValid() && m_privateData->isFileComponent(); } @@ -1505,7 +1505,7 @@ bool NodeMetaInfo::isFileComponent() const bool NodeMetaInfo::isProjectComponent() const { if constexpr (useProjectStorage()) { - return isValid() && bool(typeData().traits & Storage::TypeTraits::IsProjectComponent); + return isValid() && typeData().traits.isProjectComponent; } return false; @@ -1514,12 +1514,168 @@ bool NodeMetaInfo::isProjectComponent() const bool NodeMetaInfo::isInProjectModule() const { if constexpr (useProjectStorage()) { - return isValid() && bool(typeData().traits & Storage::TypeTraits::IsInProjectModule); + return isValid() && typeData().traits.isInProjectModule; } return false; } +FlagIs NodeMetaInfo::canBeContainer() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.canBeContainer; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::forceClip() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.forceClip; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::doesLayoutChildren() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.doesLayoutChildren; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::canBeDroppedInFormEditor() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.canBeDroppedInFormEditor; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::canBeDroppedInNavigator() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.canBeDroppedInNavigator; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::canBeDroppedInView3D() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.canBeDroppedInView3D; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::isMovable() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.isMovable; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::isResizable() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.isResizable; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::hasFormEditorItem() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.hasFormEditorItem; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::isStackedContainer() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.isStackedContainer; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::takesOverRenderingOfChildren() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.takesOverRenderingOfChildren; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::visibleInNavigator() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.visibleInNavigator; + + return FlagIs::False; + } + + return FlagIs::Set; +} + +FlagIs NodeMetaInfo::visibleInLibrary() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return typeData().traits.visibleInLibrary; + + return FlagIs::False; + } + + return FlagIs::Set; +} + namespace { [[maybe_unused]] auto propertyId(const ProjectStorageType &projectStorage, @@ -1820,6 +1976,36 @@ Storage::Info::ExportedTypeNames NodeMetaInfo::exportedTypeNamesForSourceId(Sour return {}; } +Storage::Info::TypeHints NodeMetaInfo::typeHints() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return m_projectStorage->typeHints(m_typeId); + } + + return {}; +} + +Utils::PathString NodeMetaInfo::iconPath() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return m_projectStorage->typeIconPath(m_typeId); + } + + return {}; +} + +Storage::Info::ItemLibraryEntries NodeMetaInfo::itemLibrariesEntries() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) + return m_projectStorage->itemLibraryEntries(m_typeId); + } + + return {}; +} + SourceId NodeMetaInfo::sourceId() const { if constexpr (useProjectStorage()) { @@ -2230,7 +2416,7 @@ bool NodeMetaInfo::isView() const bool NodeMetaInfo::usesCustomParser() const { if constexpr (useProjectStorage()) { - return isValid() && bool(typeData().traits & Storage::TypeTraits::UsesCustomParser); + return isValid() && typeData().traits.usesCustomParser; } else { if (!isValid()) return false; @@ -3129,7 +3315,7 @@ bool NodeMetaInfo::isQtQuick3DEffect() const bool NodeMetaInfo::isEnumeration() const { if constexpr (useProjectStorage()) - return isValid() && bool(typeData().traits & Storage::TypeTraits::IsEnum); + return isValid() && typeData().traits.isEnum; return false; } @@ -3402,6 +3588,19 @@ NodeMetaInfo NodeMetaInfo::commonBase(const NodeMetaInfo &metaInfo) const return {}; } +NodeMetaInfo::NodeMetaInfos NodeMetaInfo::heirs() const +{ + if constexpr (useProjectStorage()) { + if (isValid()) { + return Utils::transform(m_projectStorage->heirIds(m_typeId), [&](TypeId typeId) { + return NodeMetaInfo{typeId, m_projectStorage}; + }); + } + } + + return {}; +} + namespace { void addCompoundProperties(CompoundPropertyMetaInfos &inflatedProperties, diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index a982d8dc5e5..ff332ee3b2d 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -129,12 +129,6 @@ WidgetInfo AbstractView::createWidgetInfo(QWidget *widget, return widgetInfo; } -// Returns the model of the view. -Model* AbstractView::model() const -{ - return m_model.data(); -} - bool AbstractView::isAttached() const { return model(); diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 7b5868d6cf5..b85a0d8b403 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -17,7 +17,10 @@ #include "internalproperty.h" #include "internalsignalhandlerproperty.h" #include "internalvariantproperty.h" -#include "metainfo.h" +#include "itemlibraryentry.h" +#ifndef QDS_USE_PROJECTSTORAGE +# include "metainfo.h" +#endif #include "nodeinstanceview.h" #include "nodemetainfo.h" @@ -84,7 +87,7 @@ ModelPrivate::ModelPrivate(Model *model, m_currentTimelineNode = m_rootInternalNode; if constexpr (useProjectStorage()) - projectStorage->addRefreshCallback(&m_metaInfoRefreshCallback); + projectStorage->addObserver(this); } ModelPrivate::ModelPrivate(Model *model, @@ -108,7 +111,7 @@ ModelPrivate::ModelPrivate(Model *model, m_currentTimelineNode = m_rootInternalNode; if constexpr (useProjectStorage()) - projectStorage->addRefreshCallback(&m_metaInfoRefreshCallback); + projectStorage->addObserver(this); } ModelPrivate::ModelPrivate(Model *model, @@ -132,14 +135,11 @@ ModelPrivate::ModelPrivate(Model *model, ModelPrivate::~ModelPrivate() { if constexpr (useProjectStorage()) - projectStorage->removeRefreshCallback(&m_metaInfoRefreshCallback); + projectStorage->removeObserver(this); }; void ModelPrivate::detachAllViews() { - if constexpr (useProjectStorage()) - projectStorage->removeRefreshCallback(&m_metaInfoRefreshCallback); - for (const QPointer &view : std::as_const(m_viewList)) detachView(view.data(), true); @@ -394,11 +394,6 @@ void ModelPrivate::setTypeId(InternalNode *node, Utils::SmallStringView typeName } } -void ModelPrivate::emitRefreshMetaInfos(const TypeIds &deletedTypeIds) -{ - notifyNodeInstanceViewLast([&](AbstractView *view) { view->refreshMetaInfos(deletedTypeIds); }); -} - void ModelPrivate::handleResourceSet(const ModelResourceSet &resourceSet) { for (const ModelNode &node : resourceSet.removeModelNodes) { @@ -411,6 +406,11 @@ void ModelPrivate::handleResourceSet(const ModelResourceSet &resourceSet) setBindingProperties(resourceSet.setExpressions); } +void ModelPrivate::removedTypeIds(const TypeIds &removedTypeIds) +{ + notifyNodeInstanceViewLast([&](AbstractView *view) { view->refreshMetaInfos(removedTypeIds); }); +} + void ModelPrivate::removeAllSubNodes(const InternalNodePointer &node) { for (const InternalNodePointer &subNode : node->allSubNodes()) @@ -459,6 +459,7 @@ InternalNodePointer ModelPrivate::rootNode() const return m_rootInternalNode; } +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo ModelPrivate::metaInfo() const { return m_metaInfo; @@ -468,6 +469,7 @@ void ModelPrivate::setMetaInfo(const MetaInfo &metaInfo) { m_metaInfo = metaInfo; } +#endif void ModelPrivate::changeNodeId(const InternalNodePointer &node, const QString &id) { @@ -2061,23 +2063,21 @@ void Model::setFileUrl(const QUrl &url) d->setFileUrl(url); } -/*! - \brief Returns list of QML types available within the model. - */ -const MetaInfo Model::metaInfo() const -{ - return d->metaInfo(); -} - bool Model::hasNodeMetaInfo(const TypeName &typeName, int majorVersion, int minorVersion) const { return metaInfo(typeName, majorVersion, minorVersion).isValid(); } +#ifndef QDS_USE_PROJECTSTORAGE +const MetaInfo Model::metaInfo() const +{ + return d->metaInfo(); +} void Model::setMetaInfo(const MetaInfo &metaInfo) { d->setMetaInfo(metaInfo); } +#endif NodeMetaInfo Model::boolMetaInfo() const { @@ -2287,6 +2287,45 @@ NodeMetaInfo Model::qtQuick3DNodeMetaInfo() const } } +NodeMetaInfo Model::qtQuick3DPointLightMetaInfo() const +{ + if constexpr (useProjectStorage()) { + using namespace Storage::Info; + return createNodeMetaInfo(); + } else { + return metaInfo("QtQuick3D.PointLight"); + } +} + +NodeMetaInfo Model::qtQuick3DSpotLightMetaInfo() const +{ + if constexpr (useProjectStorage()) { + using namespace Storage::Info; + return createNodeMetaInfo(); + } else { + return metaInfo("QtQuick3D.SpotLight"); + } +} + +NodeMetaInfo Model::qtQuick3DOrthographicCameraMetaInfo() const +{ + if constexpr (useProjectStorage()) { + using namespace Storage::Info; + return createNodeMetaInfo(); + } else { + return metaInfo("QtQuick3D.OrthographicCamera"); + } +} + +NodeMetaInfo Model::qtQuick3DPerspectiveCameraMetaInfo() const +{ + if constexpr (useProjectStorage()) { + using namespace Storage::Info; + return createNodeMetaInfo(); + } else { + return metaInfo("QtQuick3D.PerspectiveCamera"); + } +} NodeMetaInfo Model::qtQuick3DTextureMetaInfo() const { if constexpr (useProjectStorage()) { @@ -2327,6 +2366,16 @@ NodeMetaInfo Model::qtQuick3DDefaultMaterialMetaInfo() const } } +NodeMetaInfo Model::qtQuick3DDirectionalLightMetaInfo() const +{ + if constexpr (useProjectStorage()) { + using namespace Storage::Info; + return createNodeMetaInfo(); + } else { + return metaInfo("QtQuick3D.DirectionalLight"); + } +} + NodeMetaInfo Model::qtQuick3DPrincipledMaterialMetaInfo() const { if constexpr (useProjectStorage()) { @@ -2407,6 +2456,30 @@ NodeMetaInfo Model::vector4dMetaInfo() const } } +QVarLengthArray Model::metaInfosForModule(Module module) const +{ + if constexpr (useProjectStorage()) { + using namespace Storage::Info; + return Utils::transform>( + d->projectStorage->typeIds(module.id()), [&](TypeId id) { + return NodeMetaInfo{id, d->projectStorage}; + }); + } else { + return {}; + } +} + +QList Model::itemLibraryEntries() const +{ +#ifdef QDS_USE_PROJECTSTORAGE + using namespace Storage::Info; + return toItemLibraryEntries(d->projectStorage->itemLibraryEntries(d->m_sourceId), + *d->projectStorage); +#else + return d->metaInfo().itemLibraryInfo()->entries(); +#endif +} + NodeMetaInfo Model::qtQuickTimelineKeyframeGroupMetaInfo() const { if constexpr (useProjectStorage()) { @@ -2460,13 +2533,12 @@ NodeMetaInfo Model::metaInfo(Module module, Utils::SmallStringView typeName, Sto } } -/*! - \brief Returns list of QML types available within the model. - */ +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo Model::metaInfo() { return d->metaInfo(); } +#endif Module Model::module(Utils::SmallStringView moduleName) { diff --git a/src/plugins/qmldesigner/designercore/model/model_p.h b/src/plugins/qmldesigner/designercore/model/model_p.h index d09e4054ca2..d7743b028e2 100644 --- a/src/plugins/qmldesigner/designercore/model/model_p.h +++ b/src/plugins/qmldesigner/designercore/model/model_p.h @@ -6,7 +6,9 @@ #include "qmldesignercorelib_global.h" #include "abstractview.h" -#include "metainfo.h" +#ifndef QDS_USE_PROJECTSTORAGE +# include "metainfo.h" +#endif #include "modelnode.h" #include "skipiterator.h" @@ -82,7 +84,8 @@ public: {} }; -class ModelPrivate : public QObject +class ModelPrivate : public QObject, + protected ProjectStorageObserver { Q_OBJECT @@ -137,8 +140,10 @@ public: InternalNodePointer rootNode() const; InternalNodePointer findNode(const QString &id) const; +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo metaInfo() const; void setMetaInfo(const MetaInfo &metaInfo); +#endif void attachView(AbstractView *view); void detachView(AbstractView *view, bool notifyView); @@ -303,6 +308,9 @@ public: return m_nodeMetaInfoCache; } +protected: + void removedTypeIds(const TypeIds &removedTypeIds) override; + private: void removePropertyWithoutNotification(InternalProperty *property); void removeAllSubNodes(const InternalNodePointer &node); @@ -317,7 +325,6 @@ private: EnabledViewRange enabledViews() const; ImportedTypeNameId importedTypeNameId(Utils::SmallStringView typeName); void setTypeId(InternalNode *node, Utils::SmallStringView typeName); - void emitRefreshMetaInfos(const TypeIds &deletedTypeIds); public: NotNullPointer projectStorage = nullptr; @@ -325,9 +332,9 @@ public: private: Model *m_model = nullptr; +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo m_metaInfo; - std::function m_metaInfoRefreshCallback{ - [&](const TypeIds &deletedTypeIds) { emitRefreshMetaInfos(deletedTypeIds); }}; +#endif Imports m_imports; Imports m_possibleImportList; Imports m_usedImportList; diff --git a/src/plugins/qmldesigner/designercore/model/modelnode.cpp b/src/plugins/qmldesigner/designercore/model/modelnode.cpp index 56f50223c9e..94d431dda6f 100644 --- a/src/plugins/qmldesigner/designercore/model/modelnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/modelnode.cpp @@ -1368,6 +1368,15 @@ bool ModelNode::isComponent() const QIcon ModelNode::typeIcon() const { +#ifdef QDS_USE_PROJECTSTORAGE + if (!isValid()) + return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png")); + + if (auto iconPath = metaInfo().iconPath(); iconPath.size()) + return QIcon(iconPath.toQString()); + else + return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png")); +#else if (isValid()) { // if node has no own icon, search for it in the itemlibrary const ItemLibraryInfo *libraryInfo = model()->metaInfo().itemLibraryInfo(); @@ -1381,6 +1390,7 @@ QIcon ModelNode::typeIcon() const } return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png")); +#endif } QString ModelNode::behaviorPropertyName() const diff --git a/src/plugins/qmldesigner/designercore/model/propertyparser.cpp b/src/plugins/qmldesigner/designercore/model/propertyparser.cpp index 107cc41b07a..788530c291a 100644 --- a/src/plugins/qmldesigner/designercore/model/propertyparser.cpp +++ b/src/plugins/qmldesigner/designercore/model/propertyparser.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/src/plugins/qmldesigner/designercore/model/qml3dnode.cpp b/src/plugins/qmldesigner/designercore/model/qml3dnode.cpp index 4db2567e36d..12befa942f1 100644 --- a/src/plugins/qmldesigner/designercore/model/qml3dnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qml3dnode.cpp @@ -5,13 +5,11 @@ #include "auxiliarydataproperties.h" #include "bindingproperty.h" #include "invalidmodelnodeexception.h" -#include "itemlibraryinfo.h" #include "nodehints.h" #include "nodelistproperty.h" #include "qmlanchors.h" #include "qmlchangeset.h" #include "variantproperty.h" -#include #include "plaintexteditmodifier.h" #include "rewriterview.h" diff --git a/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp b/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp index 889a5a38650..134a9a91375 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp @@ -6,7 +6,6 @@ #include "rewritertransaction.h" #include "variantproperty.h" #include "abstractview.h" -#include #include diff --git a/src/plugins/qmldesigner/designercore/model/qmlconnections.cpp b/src/plugins/qmldesigner/designercore/model/qmlconnections.cpp index 9c98399cb30..7a63e73d629 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlconnections.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlconnections.cpp @@ -3,7 +3,6 @@ #include "qmlconnections.h" -#include #include #include #include diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 175d3291183..0ce155ca6b9 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -2,14 +2,12 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qmlitemnode.h" -#include #include "nodelistproperty.h" #include "nodehints.h" #include "nodeproperty.h" #include "variantproperty.h" #include "bindingproperty.h" #include "qmlanchors.h" -#include "itemlibraryinfo.h" #include #include diff --git a/src/plugins/qmldesigner/designercore/model/qmlstate.cpp b/src/plugins/qmldesigner/designercore/model/qmlstate.cpp index 7d681071088..55864745a96 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlstate.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlstate.cpp @@ -5,7 +5,6 @@ #include "abstractview.h" #include #include -#include #include #include "bindingproperty.h" #include "qmlchangeset.h" diff --git a/src/plugins/qmldesigner/designercore/model/qmltimeline.cpp b/src/plugins/qmldesigner/designercore/model/qmltimeline.cpp index fc0e2d4f988..ae0f675d793 100644 --- a/src/plugins/qmldesigner/designercore/model/qmltimeline.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmltimeline.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include diff --git a/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframegroup.cpp b/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframegroup.cpp index d40616a0226..7cee6095bb4 100644 --- a/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframegroup.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframegroup.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include diff --git a/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp index 6ccab365bd1..75db18b5a22 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp @@ -2,14 +2,13 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qmlvisualnode.h" -#include -#include "qmlchangeset.h" -#include "nodelistproperty.h" -#include "nodehints.h" -#include "variantproperty.h" #include "bindingproperty.h" +#include "itemlibraryentry.h" +#include "nodehints.h" +#include "nodelistproperty.h" #include "qmlanchors.h" -#include "itemlibraryinfo.h" +#include "qmlchangeset.h" +#include "variantproperty.h" #include diff --git a/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h b/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h index e7b41c559e3..41f894356ab 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h @@ -38,6 +38,7 @@ inline constexpr char Control[] = "Control"; inline constexpr char CubeMapTexture[] = "CubeMapTexture"; inline constexpr char DefaultMaterial[] = "DefaultMaterial"; inline constexpr char Dialog[] = "Dialog"; +inline constexpr char DirectionalLight[] = "DirectionalLight"; inline constexpr char DoubleType[] = "double"; inline constexpr char Effect[] = "Effect"; inline constexpr char FloatType[] = "float"; @@ -52,12 +53,12 @@ inline constexpr char GroupItem[] = "GroupItem"; inline constexpr char Image[] = "Image"; inline constexpr char InstanceListEntry[] = "InstanceListEntry"; inline constexpr char InstanceList[] = "InstanceList"; -inline constexpr char Light[] = "Light"; inline constexpr char IntType[] = "int"; inline constexpr char Item[] = "Item"; inline constexpr char KeyframeGroup[] = "KeyframeGroup"; inline constexpr char Keyframe[] = "Keyframe"; inline constexpr char Layout[] = "Layout"; +inline constexpr char Light[] = "Light"; inline constexpr char ListElement[] = "ListElement"; inline constexpr char ListModel[] = "ListModel"; inline constexpr char ListView[] = "ListView"; @@ -66,17 +67,19 @@ inline constexpr char Material[] = "Material"; inline constexpr char Model[] = "Model"; inline constexpr char MouseArea[] = "MouseArea"; inline constexpr char Node[] = "Node"; +inline constexpr char OrthographicCamera[] = "OrthographicCamera"; inline constexpr char Particle3D[] = "Particle3D"; inline constexpr char ParticleEmitter3D[] = "ParticleEmitter3D"; inline constexpr char Pass[] = "Pass"; inline constexpr char PathView[] = "PathView"; inline constexpr char Path[] = "Path"; inline constexpr char PauseAnimation[] = "PauseAnimation"; +inline constexpr char PerspectiveCamera[] = "PerspectiveCamera"; inline constexpr char Picture[] = "Picture"; +inline constexpr char PointLight[] = "PointLight"; inline constexpr char Popup[] = "Popup"; inline constexpr char Positioner[] = "Positioner"; inline constexpr char PrincipledMaterial[] = "PrincipledMaterial"; -inline constexpr char SpecularGlossyMaterial[] = "SpecularGlossyMaterial"; inline constexpr char PropertyAnimation[] = "PropertyAnimation"; inline constexpr char PropertyChanges[] = "PropertyChanges"; inline constexpr char QML[] = "QML"; @@ -91,7 +94,6 @@ inline constexpr char QtQuick3D[] = "QtQuick3D"; inline constexpr char QtQuick3D_Particles3D[] = "QtQuick3D.Particles3D"; inline constexpr char QtQuick3D_Particles3D_cppnative[] = "QtQuick3D.Particles3D-cppnative"; inline constexpr char QtQuick[] = "QtQuick"; -inline constexpr char QtQuick_cppnative[] = "QtQuick-cppnative"; inline constexpr char QtQuick_Controls[] = "QtQuick.Controls"; inline constexpr char QtQuick_Dialogs[] = "QtQuick.Dialogs"; inline constexpr char QtQuick_Extras[] = "QtQuick.Extras"; @@ -100,6 +102,7 @@ inline constexpr char QtQuick_Studio_Components[] = "QtQuick.Studio.Components"; inline constexpr char QtQuick_Templates[] = "QtQuick.Templates"; inline constexpr char QtQuick_Timeline[] = "QtQuick.Timeline"; inline constexpr char QtQuick_Window[] = "QtQuick.Window"; +inline constexpr char QtQuick_cppnative[] = "QtQuick-cppnative"; inline constexpr char Qt_SafeRenderer[] = "Qt.SafeRenderer"; inline constexpr char Rectangle[] = "Rectangle"; inline constexpr char Repeater[] = "Repeater"; @@ -108,7 +111,9 @@ inline constexpr char SafeRendererPicture[] = "SafeRendererPicture"; inline constexpr char SceneEnvironment[] = "SceneEnvironment"; inline constexpr char Shader[] = "Shader"; inline constexpr char SoundEffect[] = "SoundEffect"; +inline constexpr char SpecularGlossyMaterial[] = "SpecularGlossyMaterial"; inline constexpr char SplitView[] = "SplitView"; +inline constexpr char SpotLight[] = "SpotLight"; inline constexpr char SpriteParticle3D[] = "SpriteParticle3D"; inline constexpr char StateGroup[] = "StateGroup"; inline constexpr char State[] = "State"; @@ -201,6 +206,7 @@ class CommonTypeCache CacheType, CacheType, CacheType, + CacheType, CacheType, CacheType, CacheType, @@ -208,11 +214,15 @@ class CommonTypeCache CacheType, CacheType, CacheType, + CacheType, CacheType, + CacheType, + CacheType, CacheType, CacheType, - CacheType, CacheType, + CacheType, + CacheType, CacheType, CacheType, CacheType, @@ -262,6 +272,12 @@ public: updateTypeIdsWithoutProperties(); } + void clearForTestsOnly() + { + std::apply([](auto &...type) { ((type.typeId = QmlDesigner::TypeId{}), ...); }, m_types); + std::fill(std::begin(m_typesWithoutProperties), std ::end(m_typesWithoutProperties), TypeId{}); + } + template TypeId typeId() const { diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h index cc4de52663e..f2bdaa4a26c 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h @@ -86,6 +86,8 @@ public: relinkablePrototypes, relinkableExtensions, package.updatedSourceIds); + synchronizeTypeAnnotations(package.typeAnnotations, + package.updatedTypeAnnotationSourceIds); synchronizePropertyEditorQmlPaths(package.propertyEditorQmlPaths, package.updatedPropertyEditorQmlPathSourceIds); @@ -123,15 +125,11 @@ public: }); } - void addRefreshCallback(std::function *callback) override - { - m_refreshCallbacks.push_back(callback); - } + void addObserver(ProjectStorageObserver *observer) override { observers.push_back(observer); } - void removeRefreshCallback(std::function *callback) override + void removeObserver(ProjectStorageObserver *observer) override { - m_refreshCallbacks.erase( - std::find(m_refreshCallbacks.begin(), m_refreshCallbacks.end(), callback)); + observers.removeOne(observer); } ModuleId moduleId(Utils::SmallStringView moduleName) const override @@ -171,6 +169,12 @@ public: return Sqlite::withDeferredTransaction(database, [&] { return fetchTypeId(typeNameId); }); } + QVarLengthArray typeIds(ModuleId moduleId) const override + { + return selectTypeIdsByModuleIdStatement + .template valuesWithTransaction>(moduleId); + } + Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId) const override { return selectExportedTypesByTypeIdStatement @@ -251,6 +255,98 @@ public: typeId); } + Utils::PathString typeIconPath(TypeId typeId) const override + { + return selectTypeIconPathStatement.template valueWithTransaction(typeId); + } + + Storage::Info::TypeHints typeHints(TypeId typeId) const override + { + return selectTypeHintsStatement.template valuesWithTransaction( + typeId); + } + + Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const override + { + using Storage::Info::ItemLibraryProperties; + Storage::Info::ItemLibraryEntries entries; + + auto callback = [&](TypeId typeId_, + Utils::SmallStringView name, + Utils::SmallStringView iconPath, + Utils::SmallStringView category, + Utils::SmallStringView import, + Utils::SmallStringView toolTip, + Utils::SmallStringView properties, + Utils::SmallStringView extraFilePaths, + Utils::SmallStringView templatePath) { + auto &last = entries.emplace_back( + typeId_, name, iconPath, category, import, toolTip, templatePath); + if (properties.size()) + selectItemLibraryPropertiesStatement.readTo(last.properties, properties); + if (extraFilePaths.size()) + selectItemLibraryExtraFilePathsStatement.readTo(last.extraFilePaths, extraFilePaths); + }; + + selectItemLibraryEntriesByTypeIdStatement.readCallbackWithTransaction(callback, typeId); + + return entries; + } + + Storage::Info::ItemLibraryEntries itemLibraryEntries(SourceId sourceId) const override + { + using Storage::Info::ItemLibraryProperties; + Storage::Info::ItemLibraryEntries entries; + + auto callback = [&](TypeId typeId, + Utils::SmallStringView name, + Utils::SmallStringView iconPath, + Utils::SmallStringView category, + Utils::SmallStringView import, + Utils::SmallStringView toolTip, + Utils::SmallStringView properties, + Utils::SmallStringView extraFilePaths, + Utils::SmallStringView templatePath) { + auto &last = entries.emplace_back( + typeId, name, iconPath, category, import, toolTip, templatePath); + if (properties.size()) + selectItemLibraryPropertiesStatement.readTo(last.properties, properties); + if (extraFilePaths.size()) + selectItemLibraryExtraFilePathsStatement.readTo(last.extraFilePaths, extraFilePaths); + }; + + selectItemLibraryEntriesBySourceIdStatement.readCallbackWithTransaction(callback, sourceId); + + return entries; + } + + Storage::Info::ItemLibraryEntries allItemLibraryEntries() const override + { + using Storage::Info::ItemLibraryProperties; + Storage::Info::ItemLibraryEntries entries; + + auto callback = [&](TypeId typeId, + Utils::SmallStringView name, + Utils::SmallStringView iconPath, + Utils::SmallStringView category, + Utils::SmallStringView import, + Utils::SmallStringView toolTip, + Utils::SmallStringView properties, + Utils::SmallStringView extraFilePaths, + Utils::SmallStringView templatePath) { + auto &last = entries.emplace_back( + typeId, name, iconPath, category, import, toolTip, templatePath); + if (properties.size()) + selectItemLibraryPropertiesStatement.readTo(last.properties, properties); + if (extraFilePaths.size()) + selectItemLibraryExtraFilePathsStatement.readTo(last.extraFilePaths, extraFilePaths); + }; + + selectItemLibraryEntriesStatement.readCallbackWithTransaction(callback); + + return entries; + } + std::vector signalDeclarationNames(TypeId typeId) const override { return selectSignalDeclarationNamesForTypeStatement @@ -304,6 +400,11 @@ public: .template valuesWithTransaction(type); } + TypeIds heirIds(TypeId typeId) const override + { + return selectHeirTypeIdsStatement.template valuesWithTransaction(typeId); + } + template bool isBasedOn_(TypeId typeId, TypeIds... baseTypeIds) const { @@ -565,6 +666,13 @@ public: .template valuesWithTransaction(); } + void resetForTestsOnly() + { + database.clearAllTablesForTestsOnly(); + commonTypeCache_.clearForTestsOnly(); + moduleCache.clearForTestOnly(); + } + private: class ModuleStorageAdapter { @@ -624,8 +732,10 @@ private: void callRefreshMetaInfoCallback(const TypeIds &deletedTypeIds) { - for (auto *callback : m_refreshCallbacks) - (*callback)(deletedTypeIds); + if (deletedTypeIds.size()) { + for (ProjectStorageObserver *observer : observers) + observer->removedTypeIds(deletedTypeIds); + } } class AliasPropertyDeclaration @@ -768,6 +878,99 @@ private: sourceIds.erase(newEnd, sourceIds.end()); } + void synchronizeTypeTraits(TypeId typeId, Storage::TypeTraits traits) + { + updateTypeAnnotationTraitStatement.write(typeId, traits.annotation); + } + + class TypeAnnotationView + { + public: + TypeAnnotationView(TypeId typeId, + Utils::SmallStringView iconPath, + Utils::SmallStringView itemLibraryJson, + Utils::SmallStringView hintsJson) + : typeId{typeId} + , iconPath{iconPath} + , itemLibraryJson{itemLibraryJson} + , hintsJson{hintsJson} + {} + + public: + TypeId typeId; + Utils::SmallStringView iconPath; + Utils::SmallStringView itemLibraryJson; + Utils::PathString hintsJson; + }; + + void updateTypeIdInTypeAnnotations(Storage::Synchronization::TypeAnnotations &typeAnnotations) + { + for (auto &annotation : typeAnnotations) { + annotation.typeId = fetchTypeIdByModuleIdAndExportedName(annotation.moduleId, + annotation.typeName); + } + } + + void synchronizeTypeAnnotations(Storage::Synchronization::TypeAnnotations &typeAnnotations, + const SourceIds &updatedTypeAnnotationSourceIds) + { + using Storage::Synchronization::TypeAnnotation; + + updateTypeIdInTypeAnnotations(typeAnnotations); + + auto compareKey = [](auto &&first, auto &&second) { return first.typeId - second.typeId; }; + + std::sort(typeAnnotations.begin(), typeAnnotations.end(), [&](auto &&first, auto &&second) { + return first.typeId < second.typeId; + }); + + auto range = selectTypeAnnotationsForSourceIdsStatement.template range( + toIntegers(updatedTypeAnnotationSourceIds)); + + auto insert = [&](const TypeAnnotation &annotation) { + if (!annotation.sourceId) + throw TypeAnnotationHasInvalidSourceId{}; + + synchronizeTypeTraits(annotation.typeId, annotation.traits); + + insertTypeAnnotationStatement.write(annotation.typeId, + annotation.sourceId, + annotation.iconPath, + annotation.itemLibraryJson, + annotation.hintsJson); + }; + + auto update = [&](const TypeAnnotationView &annotationFromDatabase, + const TypeAnnotation &annotation) { + synchronizeTypeTraits(annotation.typeId, annotation.traits); + + if (annotationFromDatabase.iconPath != annotation.iconPath + || annotationFromDatabase.itemLibraryJson != annotation.itemLibraryJson + || annotationFromDatabase.hintsJson != annotation.hintsJson) { + updateTypeAnnotationStatement.write(annotation.typeId, + annotation.iconPath, + annotation.itemLibraryJson, + annotation.hintsJson); + return Sqlite::UpdateChange::Update; + } + + return Sqlite::UpdateChange::No; + }; + + auto remove = [&](const TypeAnnotationView &annotationFromDatabase) { + synchronizeTypeTraits(annotationFromDatabase.typeId, Storage::TypeTraits{}); + + deleteTypeAnnotationStatement.write(annotationFromDatabase.typeId); + }; + + Sqlite::insertUpdateDelete(range, typeAnnotations, compareKey, insert, update, remove); + } + + void synchronizeTypeTrait(const Storage::Synchronization::Type &type) + { + updateTypeTraitStatement.write(type.typeId, type.traits.type); + } + void synchronizeTypes(Storage::Synchronization::Types &types, TypeIds &updatedTypeIds, AliasPropertyDeclarations &insertedAliasPropertyDeclarations, @@ -792,6 +995,7 @@ private: throw TypeHasInvalidSourceId{}; TypeId typeId = declareType(type); + synchronizeTypeTrait(type); sourceIdsOfTypes.push_back(type.sourceId); updatedTypeIds.push_back(typeId); if (type.changeLevel != Storage::Synchronization::ChangeLevel::ExcludeExportedTypes) { @@ -1016,7 +1220,7 @@ private: void handleAliasPropertyDeclarationsWithPropertyType( TypeId typeId, AliasPropertyDeclarations &relinkableAliasPropertyDeclarations) { - auto callback = [&](TypeId typeId, + auto callback = [&](TypeId typeId_, PropertyDeclarationId propertyDeclarationId, ImportedTypeNameId propertyImportedTypeNameId, PropertyDeclarationId aliasPropertyDeclarationId, @@ -1029,7 +1233,7 @@ private: aliasPropertyDeclarationTailId); relinkableAliasPropertyDeclarations - .emplace_back(TypeId{typeId}, + .emplace_back(TypeId{typeId_}, PropertyDeclarationId{propertyDeclarationId}, ImportedTypeNameId{propertyImportedTypeNameId}, std::move(aliasPropertyName), @@ -1965,9 +2169,7 @@ private: return type.typeId; } - type.typeId = upsertTypeStatement.template value(type.sourceId, - type.typeName, - type.traits); + type.typeId = insertTypeStatement.template value(type.sourceId, type.typeName); if (!type.typeId) type.typeId = selectTypeIdBySourceIdAndNameStatement.template value(type.sourceId, @@ -2142,7 +2344,7 @@ private: { TypeId typeId; ImportedTypeNameId typeNameId; - if (!std::visit([](auto &&typeName) -> bool { return typeName.name.isEmpty(); }, typeName)) { + if (!std::visit([](auto &&typeName_) -> bool { return typeName_.name.isEmpty(); }, typeName)) { typeNameId = fetchImportedTypeNameId(typeName, sourceId); typeId = fetchTypeId(typeNameId); @@ -2430,6 +2632,7 @@ private: createFileStatusesTable(database); createProjectDatasTable(database); createPropertyEditorPathsTable(database); + createTypeAnnotionsTable(database); } database.setIsInitialized(true); } @@ -2478,21 +2681,23 @@ private: auto &sourceIdColumn = typesTable.addColumn("sourceId", Sqlite::StrictColumnType::Integer); auto &typesNameColumn = typesTable.addColumn("name", Sqlite::StrictColumnType::Text); typesTable.addColumn("traits", Sqlite::StrictColumnType::Integer); - typesTable.addForeignKeyColumn("prototypeId", - typesTable, - Sqlite::ForeignKeyAction::NoAction, - Sqlite::ForeignKeyAction::Restrict); + auto &prototypeIdColumn = typesTable.addForeignKeyColumn("prototypeId", + typesTable, + Sqlite::ForeignKeyAction::NoAction, + Sqlite::ForeignKeyAction::Restrict); typesTable.addColumn("prototypeNameId", Sqlite::StrictColumnType::Integer); - typesTable.addForeignKeyColumn("extensionId", - typesTable, - Sqlite::ForeignKeyAction::NoAction, - Sqlite::ForeignKeyAction::Restrict); + auto &extensionIdColumn = typesTable.addForeignKeyColumn("extensionId", + typesTable, + Sqlite::ForeignKeyAction::NoAction, + Sqlite::ForeignKeyAction::Restrict); typesTable.addColumn("extensionNameId", Sqlite::StrictColumnType::Integer); auto &defaultPropertyIdColumn = typesTable.addColumn("defaultPropertyId", Sqlite::StrictColumnType::Integer); - + typesTable.addColumn("annotationTraits", Sqlite::StrictColumnType::Integer); typesTable.addUniqueIndex({sourceIdColumn, typesNameColumn}); typesTable.addIndex({defaultPropertyIdColumn}); + typesTable.addIndex({prototypeIdColumn}); + typesTable.addIndex({extensionIdColumn}); typesTable.initialize(database); @@ -2779,6 +2984,25 @@ private: table.initialize(database); } + + void createTypeAnnotionsTable(Database &database) + { + Sqlite::StrictTable table; + table.setUseIfNotExists(true); + table.setUseWithoutRowId(true); + table.setName("typeAnnotations"); + auto &typeIdColumn = table.addColumn("typeId", + Sqlite::StrictColumnType::Integer, + {Sqlite::PrimaryKey{}}); + auto &sourceIdColumn = table.addColumn("sourceId", Sqlite::StrictColumnType::Integer); + table.addColumn("iconPath", Sqlite::StrictColumnType::Text); + table.addColumn("itemLibrary", Sqlite::StrictColumnType::Text); + table.addColumn("hints", Sqlite::StrictColumnType::Text); + + table.addUniqueIndex({sourceIdColumn, typeIdColumn}); + + table.initialize(database); + } }; public: @@ -2787,12 +3011,9 @@ public: Initializer initializer; mutable ModuleCache moduleCache{ModuleStorageAdapter{*this}}; Storage::Info::CommonTypeCache commonTypeCache_{*this}; - std::vector *> m_refreshCallbacks; - ReadWriteStatement<1, 3> upsertTypeStatement{ - "INSERT INTO types(sourceId, name, traits) VALUES(?1, ?2, ?3) ON CONFLICT DO " - "UPDATE SET traits=excluded.traits WHERE traits IS NOT " - "excluded.traits RETURNING typeId", - database}; + QVarLengthArray observers; + ReadWriteStatement<1, 2> insertTypeStatement{ + "INSERT OR IGNORE INTO types(sourceId, name) VALUES(?1, ?2) RETURNING typeId", database}; WriteStatement<5> updatePrototypeAndExtensionStatement{ "UPDATE types SET prototypeId=?2, prototypeNameId=?3, extensionId=?4, extensionNameId=?5 " "WHERE typeId=?1 AND (prototypeId IS NOT ?2 OR extensionId IS NOT ?3 AND prototypeId " @@ -2891,10 +3112,12 @@ public: "INSERT INTO sources(sourceContextId, sourceName) VALUES (?,?)", database}; mutable ReadStatement<3> selectAllSourcesStatement{ "SELECT sourceName, sourceContextId, sourceId FROM sources", database}; - mutable ReadStatement<7, 1> selectTypeByTypeIdStatement{ - "SELECT sourceId, t.name, t.typeId, prototypeId, extensionId, traits, pd.name " - "FROM types AS t LEFT JOIN propertyDeclarations AS pd " - " ON defaultPropertyId=propertyDeclarationId WHERE t.typeId=?", + mutable ReadStatement<8, 1> selectTypeByTypeIdStatement{ + "SELECT sourceId, t.name, t.typeId, prototypeId, extensionId, traits, annotationTraits, " + "pd.name " + "FROM types AS t LEFT JOIN propertyDeclarations AS pd ON " + "defaultPropertyId=propertyDeclarationId " + "WHERE t.typeId=?", database}; mutable ReadStatement<4, 1> selectExportedTypesByTypeIdStatement{ "SELECT moduleId, name, ifnull(majorVersion, -1), ifnull(minorVersion, -1) FROM " @@ -2905,11 +3128,16 @@ public: "FROM exportedTypeNames AS etn JOIN documentImports USING(moduleId) WHERE typeId=?1 AND " "sourceId=?2", database}; - mutable ReadStatement<7> selectTypesStatement{ - "SELECT sourceId, t.name, t.typeId, prototypeId, extensionId, traits, pd.name " - "FROM types AS t LEFT JOIN propertyDeclarations AS pd " - " ON defaultPropertyId=propertyDeclarationId", + mutable ReadStatement<8> selectTypesStatement{ + "SELECT sourceId, t.name, t.typeId, prototypeId, extensionId, traits, annotationTraits, " + "pd.name " + "FROM types AS t LEFT JOIN propertyDeclarations AS pd ON " + "defaultPropertyId=propertyDeclarationId", database}; + WriteStatement<2> updateTypeTraitStatement{"UPDATE types SET traits = ?2 WHERE typeId=?1", + database}; + WriteStatement<2> updateTypeAnnotationTraitStatement{ + "UPDATE types SET annotationTraits = ?2 WHERE typeId=?1", database}; ReadStatement<1, 2> selectNotUpdatedTypesInSourcesStatement{ "SELECT DISTINCT typeId FROM types WHERE (sourceId IN carray(?1) AND typeId NOT IN " "carray(?2))", @@ -3430,8 +3658,9 @@ public: "UPDATE types SET defaultPropertyId=?2 WHERE typeId=?1", database}; WriteStatement<1> updateDefaultPropertyIdToNullStatement{ "UPDATE types SET defaultPropertyId=NULL WHERE defaultPropertyId=?1", database}; - mutable ReadStatement<3, 1> selectInfoTypeByTypeIdStatement{ - "SELECT defaultPropertyId, sourceId, traits FROM types WHERE typeId=?", database}; + mutable ReadStatement<4, 1> selectInfoTypeByTypeIdStatement{ + "SELECT defaultPropertyId, sourceId, traits, annotationTraits FROM types WHERE typeId=?", + database}; mutable ReadStatement<1, 1> selectPrototypeIdsForTypeIdInOrderStatement{ "WITH RECURSIVE " " all_prototype_and_extension(typeId, prototypeId) AS (" @@ -3493,6 +3722,65 @@ public: database}; WriteStatement<1> deletePropertyEditorPathStatement{ "DELETE FROM propertyEditorPaths WHERE typeId=?1", database}; + mutable ReadStatement<4, 1> selectTypeAnnotationsForSourceIdsStatement{ + "SELECT typeId, iconPath, itemLibrary, hints FROM typeAnnotations WHERE " + "sourceId IN carray(?1) ORDER BY typeId", + database}; + WriteStatement<5> insertTypeAnnotationStatement{ + "INSERT INTO typeAnnotations(typeId, sourceId, iconPath, itemLibrary, hints) VALUES(?1, " + "?2, ?3, ?4, ?5)", + database}; + WriteStatement<4> updateTypeAnnotationStatement{ + "UPDATE typeAnnotations SET iconPath=?2, itemLibrary=?3, hints=?4 WHERE typeId=?1", database}; + WriteStatement<1> deleteTypeAnnotationStatement{"DELETE FROM typeAnnotations WHERE typeId=?1", + database}; + mutable ReadStatement<1, 1> selectTypeIconPathStatement{ + "SELECT iconPath FROM typeAnnotations WHERE typeId=?1", database}; + mutable ReadStatement<2, 1> selectTypeHintsStatement{ + "SELECT hints.key, hints.value " + "FROM typeAnnotations, json_each(typeAnnotations.hints) AS hints " + "WHERE typeId=?1", + database}; + mutable ReadStatement<9> selectItemLibraryEntriesStatement{ + "SELECT typeId, i.value->>'$.name', i.value->>'$.iconPath', i.value->>'$.category', " + " i.value->>'$.import', i.value->>'$.toolTip', i.value->>'$.properties', " + " i.value->>'$.extraFilePaths', i.value->>'$.templatePath' " + "FROM typeAnnotations, json_each(typeAnnotations.itemLibrary) AS i", + database}; + mutable ReadStatement<9, 1> selectItemLibraryEntriesByTypeIdStatement{ + "SELECT typeId, i.value->>'$.name', i.value->>'$.iconPath', i.value->>'$.category', " + " i.value->>'$.import', i.value->>'$.toolTip', i.value->>'$.properties', " + " i.value->>'$.extraFilePaths', i.value->>'$.templatePath' " + "FROM typeAnnotations, json_each(typeAnnotations.itemLibrary) AS i " + "WHERE typeId=?1", + database}; + mutable ReadStatement<9, 1> selectItemLibraryEntriesBySourceIdStatement{ + "SELECT typeId, i.value->>'$.name', i.value->>'$.iconPath', i.value->>'$.category', " + " i.value->>'$.import', i.value->>'$.toolTip', i.value->>'$.properties', " + " i.value->>'$.extraFilePaths', i.value->>'$.templatePath' " + "FROM typeAnnotations, json_each(typeAnnotations.itemLibrary) AS i " + "WHERE typeId IN (SELECT DISTINCT typeId " + " FROM documentImports AS di JOIN exportedTypeNames USING(moduleId) " + " WHERE di.sourceId=?)", + database}; + mutable ReadStatement<3, 1> selectItemLibraryPropertiesStatement{ + "SELECT p.value->>0, p.value->>1, p.value->>2 FROM json_each(?1) AS p", database}; + mutable ReadStatement<1, 1> selectItemLibraryExtraFilePathsStatement{ + "SELECT p.value FROM json_each(?1) AS p", database}; + mutable ReadStatement<1, 1> selectTypeIdsByModuleIdStatement{ + "SELECT DISTINCT typeId FROM exportedTypeNames WHERE moduleId=?", database}; + mutable ReadStatement<1, 1> selectHeirTypeIdsStatement{ + "WITH RECURSIVE " + " typeSelection(typeId) AS (" + " SELECT typeId FROM types WHERE prototypeId=?1 OR extensionId=?1" + " UNION ALL " + " SELECT t.typeId " + " FROM types AS t JOIN typeSelection AS ts " + " WHERE prototypeId=ts.typeId OR extensionId=ts.typeId)" + "SELECT typeId FROM typeSelection", + database}; }; + extern template class ProjectStorage; + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.cpp b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.cpp index 9f7e72784b8..efe9bc58f5d 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.cpp +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.cpp @@ -112,4 +112,9 @@ ExportedTypeCannotBeInserted::ExportedTypeCannotBeInserted(std::string_view erro : ProjectStorageErrorWithMessage{"ExportedTypeCannotBeInserted"sv, errorMessage} {} +const char *TypeAnnotationHasInvalidSourceId::what() const noexcept +{ + return "The source id in a type annotation is invalid!"; +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.h index a9a9a5c8856..412dd4a9ff9 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageexceptions.h @@ -136,4 +136,10 @@ public: const char *what() const noexcept override; }; +class QMLDESIGNERCORE_EXPORT TypeAnnotationHasInvalidSourceId : public ProjectStorageError +{ +public: + const char *what() const noexcept override; +}; + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinfotypes.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinfotypes.h index bf73a3c724c..427c0ff8d61 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinfotypes.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinfotypes.h @@ -5,6 +5,7 @@ #include "projectstorageids.h" +#include #include #include @@ -21,15 +22,19 @@ constexpr std::underlying_type_t to_underlying(Enumeration enumerat return static_cast>(enumeration); } +enum class FlagIs : unsigned int { False, Set, True }; + } // namespace QmlDesigner namespace QmlDesigner::Storage { + enum class PropertyDeclarationTraits : int { None = 0, IsReadOnly = 1 << 0, IsPointer = 1 << 1, IsList = 1 << 2 }; + constexpr PropertyDeclarationTraits operator|(PropertyDeclarationTraits first, PropertyDeclarationTraits second) { @@ -41,27 +46,100 @@ constexpr bool operator&(PropertyDeclarationTraits first, PropertyDeclarationTra return static_cast(first) & static_cast(second); } -enum class TypeTraits : int { +enum class TypeTraitsKind : unsigned int { None, Reference, Value, Sequence, - IsEnum = 1 << 8, - IsFileComponent = 1 << 9, - IsProjectComponent = 1 << 10, - IsInProjectModule = 1 << 11, - UsesCustomParser = 1 << 12 }; -constexpr TypeTraits operator|(TypeTraits first, TypeTraits second) +struct TypeTraits { - return static_cast(static_cast(first) | static_cast(second)); -} + constexpr TypeTraits() + : kind{TypeTraitsKind::None} + , isEnum{false} + , isFileComponent{false} + , isProjectComponent{false} + , isInProjectModule{false} + , usesCustomParser{false} + , dummy{0U} + , canBeContainer{FlagIs::False} + , forceClip{FlagIs::False} + , doesLayoutChildren{FlagIs::False} + , canBeDroppedInFormEditor{FlagIs::False} + , canBeDroppedInNavigator{FlagIs::False} + , canBeDroppedInView3D{FlagIs::False} + , isMovable{FlagIs::False} + , isResizable{FlagIs::False} + , hasFormEditorItem{FlagIs::False} + , isStackedContainer{FlagIs::False} + , takesOverRenderingOfChildren{FlagIs::False} + , visibleInNavigator{FlagIs::False} + , visibleInLibrary{FlagIs::False} + , dummy2{0U} + {} -constexpr TypeTraits operator&(TypeTraits first, TypeTraits second) -{ - return static_cast(static_cast(first) & static_cast(second)); -} + constexpr TypeTraits(TypeTraitsKind aKind) + : TypeTraits{} + { + kind = aKind; + } + + explicit constexpr TypeTraits(long long type, long long int annotation) + : type{static_cast(type)} + , annotation{static_cast(annotation)} + {} + + explicit constexpr TypeTraits(unsigned int type, unsigned int annotation) + : type{type} + , annotation{annotation} + {} + + friend bool operator==(TypeTraits first, TypeTraits second) + { + return first.type == second.type && first.annotation == second.annotation; + } + + union { + struct + { + TypeTraitsKind kind : 4; + unsigned int isEnum : 1; + unsigned int isFileComponent : 1; + unsigned int isProjectComponent : 1; + unsigned int isInProjectModule : 1; + unsigned int usesCustomParser : 1; + unsigned int dummy : 23; + }; + + unsigned int type; + }; + + union { + struct + { + FlagIs canBeContainer : 2; + FlagIs forceClip : 2; + FlagIs doesLayoutChildren : 2; + FlagIs canBeDroppedInFormEditor : 2; + FlagIs canBeDroppedInNavigator : 2; + FlagIs canBeDroppedInView3D : 2; + FlagIs isMovable : 2; + FlagIs isResizable : 2; + FlagIs hasFormEditorItem : 2; + FlagIs isStackedContainer : 2; + FlagIs takesOverRenderingOfChildren : 2; + FlagIs visibleInNavigator : 2; + FlagIs visibleInLibrary : 2; + unsigned int dummy2 : 6; + }; + + unsigned int annotation; + }; +}; + +static_assert(sizeof(TypeTraits) == sizeof(unsigned int) * 2, + "TypeTraits must be of size unsigned long long!"); using TypeNameString = ::Utils::BasicSmallString<63>; @@ -132,6 +210,83 @@ public: namespace QmlDesigner::Storage::Info { +struct TypeHint +{ + TypeHint(Utils::SmallStringView name, Utils::SmallStringView expression) + : name{name} + , expression{expression} + {} + + Utils::SmallString name; + Utils::PathString expression; +}; + +using TypeHints = QVarLengthArray; + +struct ItemLibraryProperty +{ + ItemLibraryProperty(Utils::SmallStringView name, Utils::SmallStringView type, Sqlite::ValueView value) + : name{name} + , type{type} + , value{value} + {} + + Utils::SmallString name; + Utils::SmallString type; + Sqlite::Value value; +}; + +using ItemLibraryProperties = QVarLengthArray; + +using ToolTipString = Utils::BasicSmallString<94>; + +struct ItemLibraryEntry +{ + ItemLibraryEntry(TypeId typeId, + Utils::SmallStringView name, + Utils::SmallStringView iconPath, + Utils::SmallStringView category, + Utils::SmallStringView import, + Utils::SmallStringView toolTip, + Utils::SmallStringView templatePath) + : typeId{typeId} + , name{name} + , iconPath{iconPath} + , category{category} + , import{import} + , toolTip{toolTip} + , templatePath{templatePath} + {} + + ItemLibraryEntry(TypeId typeId, + Utils::SmallStringView name, + Utils::SmallStringView iconPath, + Utils::SmallStringView category, + Utils::SmallStringView import, + Utils::SmallStringView toolTip, + ItemLibraryProperties properties) + : typeId{typeId} + , name{name} + , iconPath{iconPath} + , category{category} + , import{import} + , toolTip{toolTip} + , properties{std::move(properties)} + {} + + TypeId typeId; + Utils::SmallString name; + Utils::PathString iconPath; + Utils::SmallString category; + Utils::SmallString import; + ToolTipString toolTip; + Utils::PathString templatePath; + ItemLibraryProperties properties; + std::vector extraFilePaths; +}; + +using ItemLibraryEntries = QVarLengthArray; + class ExportedTypeName { public: @@ -196,6 +351,15 @@ public: class Type { public: + Type(PropertyDeclarationId defaultPropertyId, + SourceId sourceId, + long long typeTraits, + long long typeAnnotationTraits) + : defaultPropertyId{defaultPropertyId} + , sourceId{sourceId} + , traits{typeTraits, typeAnnotationTraits} + {} + Type(PropertyDeclarationId defaultPropertyId, SourceId sourceId, TypeTraits traits) : defaultPropertyId{defaultPropertyId} , sourceId{sourceId} diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h index e6962602b38..266c6ee7caa 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h @@ -6,6 +6,7 @@ #include "commontypecache.h" #include "filestatus.h" #include "projectstorageids.h" +#include "projectstorageobserver.h" #include "projectstoragetypes.h" #include @@ -27,8 +28,8 @@ public: virtual void synchronize(Storage::Synchronization::SynchronizationPackage package) = 0; virtual void synchronizeDocumentImports(const Storage::Imports imports, SourceId sourceId) = 0; - virtual void addRefreshCallback(std::function *callback) = 0; - virtual void removeRefreshCallback(std::function *callback) = 0; + virtual void addObserver(ProjectStorageObserver *observer) = 0; + virtual void removeObserver(ProjectStorageObserver *observer) = 0; virtual ModuleId moduleId(::Utils::SmallStringView name) const = 0; virtual std::optional @@ -38,6 +39,7 @@ public: Storage::Version version) const = 0; virtual TypeId typeId(ImportedTypeNameId typeNameId) const = 0; + virtual QVarLengthArray typeIds(ModuleId moduleId) const = 0; virtual Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId) const = 0; virtual Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId, SourceId sourceId) const @@ -53,12 +55,18 @@ public: ::Utils::SmallStringView propertyName) const = 0; virtual std::optional type(TypeId typeId) const = 0; + virtual Utils::PathString typeIconPath(TypeId typeId) const = 0; + virtual Storage::Info::TypeHints typeHints(TypeId typeId) const = 0; + virtual Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const = 0; + virtual Storage::Info::ItemLibraryEntries itemLibraryEntries(SourceId sourceId) const = 0; + virtual Storage::Info::ItemLibraryEntries allItemLibraryEntries() const = 0; virtual std::vector<::Utils::SmallString> signalDeclarationNames(TypeId typeId) const = 0; virtual std::vector<::Utils::SmallString> functionDeclarationNames(TypeId typeId) const = 0; virtual std::optional<::Utils::SmallString> propertyName(PropertyDeclarationId propertyDeclarationId) const = 0; virtual TypeIds prototypeAndSelfIds(TypeId type) const = 0; virtual TypeIds prototypeIds(TypeId type) const = 0; + virtual TypeIds heirIds(TypeId typeId) const = 0; virtual bool isBasedOn(TypeId, TypeId) const = 0; virtual bool isBasedOn(TypeId, TypeId, TypeId) const = 0; virtual bool isBasedOn(TypeId, TypeId, TypeId, TypeId) const = 0; diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageobserver.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageobserver.h new file mode 100644 index 00000000000..c3393c91d4c --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageobserver.h @@ -0,0 +1,15 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "projectstorageids.h" + +namespace QmlDesigner { + +class ProjectStorageObserver +{ +public: + virtual void removedTypeIds(const TypeIds &removedTypeIds) = 0; +}; +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h index 7c7cab80e27..18c39312496 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h @@ -7,6 +7,7 @@ #include "projectstorageids.h" #include "projectstorageinfotypes.h" +#include #include #include @@ -637,6 +638,19 @@ public: , changeLevel{changeLevel} {} + explicit Type(::Utils::SmallStringView typeName, + TypeId prototypeId, + TypeId extensionId, + long long typeTraits, + long long typeAnnotationTraits, + SourceId sourceId) + : typeName{typeName} + , traits{typeTraits, typeAnnotationTraits} + , sourceId{sourceId} + , prototypeId{prototypeId} + , extensionId{extensionId} + {} + explicit Type(::Utils::SmallStringView typeName, TypeId prototypeId, TypeId extensionId, @@ -679,11 +693,12 @@ public: TypeId typeId, TypeId prototypeId, TypeId extensionId, - TypeTraits traits, + long long typeTraits, + long long typeAnnotationTraits, ::Utils::SmallStringView defaultPropertyName) : typeName{typeName} , defaultPropertyName{defaultPropertyName} - , traits{traits} + , traits{typeTraits, typeAnnotationTraits} , sourceId{sourceId} , typeId{typeId} , prototypeId{prototypeId} @@ -712,7 +727,7 @@ public: FunctionDeclarations functionDeclarations; SignalDeclarations signalDeclarations; EnumerationDeclarations enumerationDeclarations; - TypeTraits traits = TypeTraits::None; + TypeTraits traits; SourceId sourceId; TypeId typeId; TypeId prototypeId; @@ -768,6 +783,41 @@ public: using ProjectDatas = std::vector; +class TypeAnnotation +{ +public: + TypeAnnotation(SourceId sourceId) + : sourceId{sourceId} + {} + TypeAnnotation(SourceId sourceId, + Utils::SmallStringView typeName, + ModuleId moduleId, + Utils::SmallStringView iconPath, + TypeTraits traits, + Utils::SmallStringView hintsJson, + Utils::SmallStringView itemLibraryJson) + : typeName{typeName} + , iconPath{iconPath} + , itemLibraryJson{itemLibraryJson} + , hintsJson{hintsJson} + , sourceId{sourceId} + , moduleId{moduleId} + , traits{traits} + {} + +public: + TypeNameString typeName; + Utils::PathString iconPath; + Utils::PathString itemLibraryJson; + Utils::PathString hintsJson; + TypeId typeId; + SourceId sourceId; + ModuleId moduleId; + TypeTraits traits; +}; + +using TypeAnnotations = std::vector; + class SynchronizationPackage { public: @@ -822,6 +872,8 @@ public: ModuleIds updatedModuleIds; PropertyEditorQmlPaths propertyEditorQmlPaths; SourceIds updatedPropertyEditorQmlPathSourceIds; + TypeAnnotations typeAnnotations; + SourceIds updatedTypeAnnotationSourceIds; }; } // namespace Synchronization diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp index 3759736cfaf..62fcf310f65 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp @@ -373,6 +373,14 @@ void ProjectStorageUpdater::updatePropertyEditorPaths( } } +void ProjectStorageUpdater::updateTypeAnnotations( + const QString & /*propertyEditorResourcesPath*/, + Storage::Synchronization::SynchronizationPackage & /*package*/, + NotUpdatedSourceIds & /*notUpdatedSourceIds*/) +{ + // const auto typeAnnotations = dir.entryInfoList({"*.metainfo"}, QDir::Files); +} + void ProjectStorageUpdater::updatePropertyEditorPath( const QString &directoryPath, Storage::Synchronization::SynchronizationPackage &package, @@ -649,7 +657,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil package.updatedSourceIds.push_back(sourceId); type.typeName = SourcePath{qmlFilePath}.name(); - type.traits = Storage::TypeTraits::Reference; + type.traits = Storage::TypeTraitsKind::Reference; type.sourceId = sourceId; type.exportedTypes = std::move(exportedTypes); @@ -675,7 +683,7 @@ void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId, auto type = m_qmlDocumentParser.parse(content, package.imports, sourceId, sourcePath.directory()); type.typeName = sourcePath.name(); - type.traits = Storage::TypeTraits::Reference; + type.traits = Storage::TypeTraitsKind::Reference; type.sourceId = sourceId; type.changeLevel = Storage::Synchronization::ChangeLevel::ExcludeExportedTypes; diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h index 6a77f353e20..187a2219d09 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h @@ -145,6 +145,9 @@ private: void updatePropertyEditorPaths(const QString &propertyEditorResourcesPath, Storage::Synchronization::SynchronizationPackage &package, NotUpdatedSourceIds ¬UpdatedSourceIds); + void updateTypeAnnotations(const QString &propertyEditorResourcesPath, + Storage::Synchronization::SynchronizationPackage &package, + NotUpdatedSourceIds ¬UpdatedSourceIds); void updatePropertyEditorPath(const QString &path, Storage::Synchronization::SynchronizationPackage &package, SourceId directorySourceId); diff --git a/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp b/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp index 41f568e66d2..3768535299a 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp +++ b/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp @@ -84,16 +84,16 @@ Storage::TypeTraits createAccessTypeTraits(QQmlJSScope::AccessSemantics accessSe { switch (accessSematics) { case QQmlJSScope::AccessSemantics::Reference: - return Storage::TypeTraits::Reference; + return Storage::TypeTraitsKind::Reference; case QQmlJSScope::AccessSemantics::Value: - return Storage::TypeTraits::Value; + return Storage::TypeTraitsKind::Value; case QQmlJSScope::AccessSemantics::None: - return Storage::TypeTraits::None; + return Storage::TypeTraitsKind::None; case QQmlJSScope::AccessSemantics::Sequence: - return Storage::TypeTraits::Sequence; + return Storage::TypeTraitsKind::Sequence; } - return Storage::TypeTraits::None; + return Storage::TypeTraitsKind::None; } Storage::TypeTraits createTypeTraits(QQmlJSScope::AccessSemantics accessSematics, bool hasCustomParser) @@ -101,7 +101,7 @@ Storage::TypeTraits createTypeTraits(QQmlJSScope::AccessSemantics accessSematics auto typeTrait = createAccessTypeTraits(accessSematics); if (hasCustomParser) - typeTrait = typeTrait | Storage::TypeTraits::UsesCustomParser; + typeTrait.usesCustomParser = true; return typeTrait; } @@ -348,10 +348,12 @@ void addEnumerationType(EnumerationTypes &enumerationTypes, Utils::SmallStringView enumerationAlias) { auto fullTypeName = addEnumerationType(enumerationTypes, typeName, enumerationName); + Storage::TypeTraits typeTraits{Storage::TypeTraitsKind::Value}; + typeTraits.isEnum = true; types.emplace_back(fullTypeName, Storage::Synchronization::ImportedType{TypeNameString{}}, Storage::Synchronization::ImportedType{}, - Storage::TypeTraits::Value | Storage::TypeTraits::IsEnum, + typeTraits, sourceId, createCppEnumerationExports(typeName, cppModuleId, diff --git a/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h b/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h index f2d6841052d..85c6147d2c7 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h @@ -62,17 +62,17 @@ class StorageCache return StorageCacheIndex{id + amount}; } - constexpr friend bool operator==(StorageCacheIndex first, StorageCacheIndex second) noexcept + friend constexpr bool operator==(StorageCacheIndex first, StorageCacheIndex second) noexcept { return first.id == second.id && first.isValid() && second.isValid(); } - constexpr friend bool operator<(StorageCacheIndex first, StorageCacheIndex second) noexcept + friend constexpr bool operator<(StorageCacheIndex first, StorageCacheIndex second) noexcept { return first.id < second.id; } - constexpr friend bool operator>=(StorageCacheIndex first, StorageCacheIndex second) noexcept + friend constexpr bool operator>=(StorageCacheIndex first, StorageCacheIndex second) noexcept { return first.id >= second.id; } @@ -286,6 +286,12 @@ public: Mutex &mutex() const { return m_mutex; } + void clearForTestOnly() + { + m_entries.clear(); + m_indices.clear(); + } + private: void updateIndices() { diff --git a/src/plugins/qmldesigner/designercore/projectstorage/typeannotationreader.cpp b/src/plugins/qmldesigner/designercore/projectstorage/typeannotationreader.cpp new file mode 100644 index 00000000000..b829e9db36d --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/typeannotationreader.cpp @@ -0,0 +1,490 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "typeannotationreader.h" + +#include "projectstorage.h" + +#include + +#include + +#include +#include +#include +#include + +namespace QmlDesigner::Storage { +using namespace Qt::StringLiterals; + +namespace { +constexpr auto rootElementName = "MetaInfo"_L1; +constexpr auto typeElementName = "Type"_L1; +constexpr auto itemLibraryEntryElementName = "ItemLibraryEntry"_L1; +constexpr auto hintsElementName = "Hints"_L1; +constexpr auto qmlSourceElementNamentName = "QmlSource"_L1; +constexpr auto propertyElementName = "Property"_L1; +constexpr auto extraFileElementName = "ExtraFile"_L1; +} // namespace + +Synchronization::TypeAnnotations TypeAnnotationReader::parseTypeAnnotation(const QString &content, + const QString &directoryPath, + SourceId sourceId) +{ + m_sourceId = sourceId; + m_directoryPath = directoryPath; + m_parserState = ParsingDocument; + if (!SimpleAbstractStreamReader::readFromSource(content)) { + m_parserState = Error; + throw TypeAnnoationParsingError(errors()); + } + + if (!errors().isEmpty()) { + m_parserState = Error; + throw TypeAnnoationParsingError(errors()); + } + + return takeTypeAnnotations(); +} + +QStringList TypeAnnotationReader::errors() +{ + return QmlJS::SimpleAbstractStreamReader::errors(); +} + +void TypeAnnotationReader::elementStart(const QString &name, + [[maybe_unused]] const QmlJS::SourceLocation &nameLocation) +{ + switch (parserState()) { + case ParsingDocument: + setParserState(readDocument(name)); + break; + case ParsingMetaInfo: + setParserState(readMetaInfoRootElement(name)); + break; + case ParsingType: + setParserState(readTypeElement(name)); + break; + case ParsingItemLibrary: + setParserState(readItemLibraryEntryElement(name)); + break; + case ParsingProperty: + setParserState(readPropertyElement(name)); + break; + case ParsingQmlSource: + setParserState(readQmlSourceElement(name)); + break; + case ParsingExtraFile: + setParserState(readExtraFileElement(name)); + break; + case ParsingHints: + case Finished: + case Undefined: + setParserState(Error); + addError(TypeAnnotationReader::tr("Illegal state while parsing."), currentSourceLocation()); + [[fallthrough]]; + case Error: + break; + } +} + +void TypeAnnotationReader::elementEnd() +{ + switch (parserState()) { + case ParsingMetaInfo: + setParserState(Finished); + break; + case ParsingType: + if (m_itemLibraryEntries.size()) + m_typeAnnotations.back().itemLibraryJson = to_string(m_itemLibraryEntries); + setParserState(ParsingMetaInfo); + break; + case ParsingItemLibrary: + setParserState((ParsingType)); + break; + case ParsingHints: + addHints(); + setParserState(ParsingType); + break; + case ParsingProperty: + insertProperty(); + setParserState(ParsingItemLibrary); + break; + case ParsingQmlSource: + setParserState(ParsingItemLibrary); + break; + case ParsingExtraFile: + setParserState(ParsingItemLibrary); + break; + case ParsingDocument: + case Finished: + case Undefined: + setParserState(Error); + addError(TypeAnnotationReader::tr("Illegal state while parsing."), currentSourceLocation()); + [[fallthrough]]; + case Error: + break; + } +} + +void TypeAnnotationReader::propertyDefinition(const QString &name, + [[maybe_unused]] const QmlJS::SourceLocation &nameLocation, + const QVariant &value, + [[maybe_unused]] const QmlJS::SourceLocation &valueLocation) +{ + switch (parserState()) { + case ParsingType: + readTypeProperty(name, value); + break; + case ParsingItemLibrary: + readItemLibraryEntryProperty(name, value); + break; + case ParsingProperty: + readPropertyProperty(name, value); + break; + case ParsingQmlSource: + readQmlSourceProperty(name, value); + break; + case ParsingExtraFile: + readExtraFileProperty(name, value); + break; + case ParsingMetaInfo: + addError(TypeAnnotationReader::tr("No property definition allowed."), currentSourceLocation()); + break; + case ParsingDocument: + case ParsingHints: + readHint(name, value); + break; + case Finished: + case Undefined: + setParserState(Error); + addError(TypeAnnotationReader::tr("Illegal state while parsing."), currentSourceLocation()); + [[fallthrough]]; + case Error: + break; + } +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readDocument(const QString &name) +{ + if (name == rootElementName) { + return ParsingMetaInfo; + } else { + addErrorInvalidType(name); + return Error; + } +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readMetaInfoRootElement(const QString &name) +{ + if (name == typeElementName) { + m_typeAnnotations.emplace_back(m_sourceId); + m_itemLibraryEntries = json::array(); + return ParsingType; + } else { + addErrorInvalidType(name); + return Error; + } +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readTypeElement(const QString &name) +{ + if (name == itemLibraryEntryElementName) { + m_itemLibraryEntries.push_back({}); + + return ParsingItemLibrary; + } else if (name == hintsElementName) { + return ParsingHints; + } else { + addErrorInvalidType(name); + return Error; + } +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readItemLibraryEntryElement(const QString &name) +{ + if (name == qmlSourceElementNamentName) { + return ParsingQmlSource; + } else if (name == propertyElementName) { + m_currentProperty = {}; + return ParsingProperty; + } else if (name == extraFileElementName) { + return ParsingExtraFile; + } else { + addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation()); + return Error; + } +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readPropertyElement(const QString &name) +{ + addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation()); + return Error; +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readQmlSourceElement(const QString &name) +{ + addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation()); + return Error; +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::readExtraFileElement(const QString &name) +{ + addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation()); + return Error; +} + +namespace { +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wunneeded-internal-declaration") + +std::pair decomposeTypePath(Utils::SmallStringView typeName) +{ + auto found = std::find(typeName.rbegin(), typeName.rend(), '.'); + + if (found == typeName.rend()) + return {{}, typeName}; + + return {{typeName.begin(), std::prev(found.base())}, {found.base(), typeName.end()}}; +} + +QT_WARNING_POP +} // namespace + +void TypeAnnotationReader::readTypeProperty(QStringView name, const QVariant &value) +{ + if (name == "name"_L1) { + Utils::PathString fullTypeName = value.toString(); + auto [moduleName, typeName] = decomposeTypePath(fullTypeName); + + m_typeAnnotations.back().typeName = typeName; + m_typeAnnotations.back().moduleId = m_projectStorage.moduleId(moduleName); + + } else if (name == "icon"_L1) { + m_typeAnnotations.back().iconPath = absoluteFilePathForDocument(value.toString()); + } else { + addError(TypeAnnotationReader::tr("Unknown property for Type %1").arg(name), + currentSourceLocation()); + setParserState(Error); + } +} + +void TypeAnnotationReader::readItemLibraryEntryProperty(QStringView name, const QVariant &variant) +{ + auto value = variant.toString().toStdString(); + if (name == "name"_L1) { + m_itemLibraryEntries.back()["name"] = value; + } else if (name == "category"_L1) { + m_itemLibraryEntries.back()["category"] = value; + } else if (name == "libraryIcon"_L1) { + m_itemLibraryEntries.back()["iconPath"] = value; + } else if (name == "version"_L1) { + // setVersion(value.toString()); + } else if (name == "requiredImport"_L1) { + m_itemLibraryEntries.back()["import"] = value; + } else if (name == "toolTip"_L1) { + m_itemLibraryEntries.back()["toolTip"] = value; + } else { + addError(TypeAnnotationReader::tr("Unknown property for ItemLibraryEntry %1").arg(name), + currentSourceLocation()); + setParserState(Error); + } +} + +namespace { +QString deEscape(const QString &value) +{ + QString result = value; + + result.replace(R"(\")"_L1, R"(")"_L1); + result.replace(R"(\\")"_L1, R"(\)"_L1); + + return result; +} + +QVariant deEscapeVariant(const QVariant &value) +{ + if (value.typeId() == QVariant::String) + return deEscape(value.toString()); + return value; +} +} // namespace + +void TypeAnnotationReader::readPropertyProperty(QStringView name, const QVariant &value) +{ + if (name == "name"_L1) { + m_currentProperty.name = value.toByteArray(); + } else if (name == "type"_L1) { + m_currentProperty.type = value.toString(); + } else if (name == "value"_L1) { + m_currentProperty.value = deEscapeVariant(value); + } else { + addError(TypeAnnotationReader::tr("Unknown property for Property %1").arg(name), + currentSourceLocation()); + setParserState(Error); + } +} + +void TypeAnnotationReader::readQmlSourceProperty(QStringView name, const QVariant &value) +{ + if (name == "source"_L1) { + m_itemLibraryEntries.back()["templatePath"] = absoluteFilePathForDocument(value.toString()); + } else { + addError(TypeAnnotationReader::tr("Unknown property for QmlSource %1").arg(name), + currentSourceLocation()); + setParserState(Error); + } +} + +void TypeAnnotationReader::readExtraFileProperty(QStringView name, const QVariant &value) +{ + if (name == "source"_L1) { + m_itemLibraryEntries.back()["extraFilePaths"].push_back( + absoluteFilePathForDocument(value.toString())); + } else { + addError(TypeAnnotationReader::tr("Unknown property for ExtraFile %1").arg(name), + currentSourceLocation()); + setParserState(Error); + } +} + +namespace { +FlagIs createFlag(QStringView expression) +{ + using namespace Qt::StringLiterals; + if (expression == "true"_L1) + return FlagIs::True; + + if (expression == "false"_L1) + return FlagIs::False; + + return FlagIs::Set; +} + +template +void setTrait(QStringView name, FlagIs flag, Storage::TypeTraits &traits) +{ + using namespace Qt::StringLiterals; + + if (name == "canBeContainer"_L1) { + traits.canBeContainer = flag; + } else if (name == "forceClip"_L1) { + traits.forceClip = flag; + } else if (name == "doesLayoutChildren"_L1) { + traits.doesLayoutChildren = flag; + } else if (name == "canBeDroppedInFormEditor"_L1) { + traits.canBeDroppedInFormEditor = flag; + } else if (name == "canBeDroppedInNavigator"_L1) { + traits.canBeDroppedInNavigator = flag; + } else if (name == "canBeDroppedInView3D"_L1) { + traits.canBeDroppedInView3D = flag; + } else if (name == "isMovable"_L1) { + traits.isMovable = flag; + } else if (name == "isResizable"_L1) { + traits.isResizable = flag; + } else if (name == "hasFormEditorItem"_L1) { + traits.hasFormEditorItem = flag; + } else if (name == "isStackedContainer"_L1) { + traits.isStackedContainer = flag; + } else if (name == "takesOverRenderingOfChildren"_L1) { + traits.takesOverRenderingOfChildren = flag; + } else if (name == "visibleInNavigator"_L1) { + traits.visibleInNavigator = flag; + } else if (name == "visibleInLibrary"_L1) { + traits.visibleInLibrary = flag; + } +} + +void setComplexHint(nlohmann::json &hints, const QString &name, const QString &expression) +{ + hints[name.toStdString()] = expression.toStdString(); +} + +} // namespace + +void TypeAnnotationReader::readHint(const QString &name, const QVariant &value) +{ + auto expression = value.toString(); + + auto flag = createFlag(expression); + setTrait(name, flag, m_typeAnnotations.back().traits); + if (flag == FlagIs::Set) + setComplexHint(m_hints, name, expression); +} + +void TypeAnnotationReader::addHints() +{ + if (m_hints.size()) { + m_typeAnnotations.back().hintsJson = to_string(m_hints); + m_hints.clear(); + } +} + +void TypeAnnotationReader::setVersion(const QString &versionNumber) +{ + // const TypeName typeName = m_currentEntry.typeName(); + int major = 1; + int minor = 0; + + if (!versionNumber.isEmpty()) { + int val; + bool ok; + if (versionNumber.contains('.'_L1)) { + val = versionNumber.split('.'_L1).constFirst().toInt(&ok); + major = ok ? val : major; + val = versionNumber.split('.'_L1).constLast().toInt(&ok); + minor = ok ? val : minor; + } else { + val = versionNumber.toInt(&ok); + major = ok ? val : major; + } + } + // m_currentEntry.setType(typeName, major, minor); +} + +TypeAnnotationReader::ParserSate TypeAnnotationReader::parserState() const +{ + return m_parserState; +} + +void TypeAnnotationReader::setParserState(ParserSate newParserState) +{ + m_parserState = newParserState; +} + +using json = nlohmann::json; + +[[maybe_unused]] static void to_json(json &out, const TypeAnnotationReader::Property &property) +{ + out = json::array({}); + out.push_back(property.name); + out.push_back(property.type); + if (property.value.type() == QVariant::String) + out.push_back(Utils::PathString{property.value.toString()}); + else if (property.value.type() == QVariant::Int || property.value.type() == QVariant::LongLong) + out.push_back(property.value.toLongLong()); + else + out.push_back(property.value.toDouble()); +} + +void TypeAnnotationReader::insertProperty() +{ + m_itemLibraryEntries.back()["properties"].push_back(m_currentProperty); +} + +void TypeAnnotationReader::addErrorInvalidType(const QString &typeName) +{ + addError(TypeAnnotationReader::tr("Invalid type %1").arg(typeName), currentSourceLocation()); +} + +Utils::PathString TypeAnnotationReader::absoluteFilePathForDocument(Utils::PathString relativeFilePath) +{ + return Utils::PathString::join({m_directoryPath, "/", relativeFilePath}); +} + +const char *TypeAnnoationParsingError::what() const noexcept +{ + return "TypeAnnoationParsingError"; +} + +} // namespace QmlDesigner::Storage diff --git a/src/plugins/qmldesigner/designercore/projectstorage/typeannotationreader.h b/src/plugins/qmldesigner/designercore/projectstorage/typeannotationreader.h new file mode 100644 index 00000000000..9332d5bed94 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/typeannotationreader.h @@ -0,0 +1,129 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "qmldesignercorelib_global.h" + +#include "projectstoragetypes.h" + +#include + +#include <3rdparty/json/json.hpp> +#include +#include + +#include +#include +#include + +#include +#include + +namespace QmlDesigner::Storage { + +class ItemLibraryEntry; + +class TypeAnnoationParsingError : public std::exception +{ +public: + TypeAnnoationParsingError(QStringList errors) + : errors{std::move(errors)} + {} + + const char *what() const noexcept override; + + QStringList errors; +}; + +class TypeAnnotationReader : protected QmlJS::SimpleAbstractStreamReader +{ + Q_DECLARE_TR_FUNCTIONS(QmlDesigner::Internal::TypeAnnotationReader) + + using json = nlohmann::json; + +public: + TypeAnnotationReader(ProjectStorageType &projectStorage) + : m_projectStorage{projectStorage} + {} + + Synchronization::TypeAnnotations parseTypeAnnotation(const QString &content, + const QString &directoryPath, + SourceId sourceId); + + QStringList errors(); + + void setQualifcation(const TypeName &qualification); + + struct Property + { + Utils::SmallString name; + Utils::SmallString type; + QVariant value; + }; + +protected: + Synchronization::TypeAnnotations takeTypeAnnotations() { return std::move(m_typeAnnotations); } + + void elementStart(const QString &name, const QmlJS::SourceLocation &nameLocation) override; + void elementEnd() override; + void propertyDefinition(const QString &name, + const QmlJS::SourceLocation &nameLocation, + const QVariant &value, + const QmlJS::SourceLocation &valueLocation) override; + +private: + enum ParserSate { + Error, + Finished, + Undefined, + ParsingDocument, + ParsingMetaInfo, + ParsingType, + ParsingItemLibrary, + ParsingHints, + ParsingProperty, + ParsingQmlSource, + ParsingExtraFile + }; + + ParserSate readDocument(const QString &name); + + ParserSate readMetaInfoRootElement(const QString &name); + ParserSate readTypeElement(const QString &name); + ParserSate readItemLibraryEntryElement(const QString &name); + ParserSate readPropertyElement(const QString &name); + ParserSate readQmlSourceElement(const QString &name); + ParserSate readExtraFileElement(const QString &name); + + void readTypeProperty(QStringView name, const QVariant &value); + void readItemLibraryEntryProperty(QStringView name, const QVariant &value); + void readPropertyProperty(QStringView name, const QVariant &value); + void readQmlSourceProperty(QStringView name, const QVariant &value); + void readExtraFileProperty(QStringView name, const QVariant &value); + void readHint(const QString &name, const QVariant &value); + void addHints(); + + void setVersion(const QString &versionNumber); + + ParserSate parserState() const; + void setParserState(ParserSate newParserState); + + void insertProperty(); + + void addErrorInvalidType(const QString &typeName); + + Utils::PathString absoluteFilePathForDocument(Utils::PathString relativeFilePath); + +private: + ProjectStorageType &m_projectStorage; + Utils::PathString m_directoryPath; + ParserSate m_parserState = Undefined; + Synchronization::TypeAnnotations m_typeAnnotations; + json m_hints; + json m_itemLibraryEntries; + Property m_currentProperty; + SourceId m_sourceId; +}; + +} // namespace QmlDesigner::Storage diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index f3b01c6bb78..40e3b681e48 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -25,7 +25,9 @@ #include #include #include -#include +#ifndef QDS_USE_PROJECTSTORAGE +# include +#endif #include #include #include @@ -545,7 +547,9 @@ void QmlDesignerPlugin::activateAutoSynchronization() d->mainWidget.setupNavigatorHistory(currentDesignDocument()->textEditor()); +#ifndef QDS_USE_PROJECTSTORAGE currentDesignDocument()->updateSubcomponentManager(); +#endif } void QmlDesignerPlugin::deactivateAutoSynchronization() @@ -607,7 +611,9 @@ void QmlDesignerPlugin::enforceDelayedInitialize() return QString(p + postfix); }); +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo::initializeGlobal(pluginPaths, d->externalDependencies); +#endif d->viewManager.registerView(std::make_unique(d->externalDependencies)); diff --git a/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt b/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt index e80627a00e1..66ac125a450 100644 --- a/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt +++ b/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt @@ -12,6 +12,7 @@ add_qtc_test(tst_qml_testcore IDE_DATA_PATH="${PROJECT_BINARY_DIR}/${IDE_DATA_PATH}" TESTSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}" QMLDESIGNERCORE_STATIC_LIBRARY QMLDESIGNERUTILS_STATIC_LIBRARY + $<$:QDS_USE_PROJECTSTORAGE> INCLUDES "${CMAKE_CURRENT_LIST_DIR}/../../../../../share/qtcreator/qml/qmlpuppet/commands" SOURCES diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index ed2b110e967..8d80f7e547a 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -22,11 +21,15 @@ #include #include #include -#include #include #include #include +#ifndef QDS_USE_PROJECTSTORAGE +#include +#include +#endif + #include "../testconnectionmanager.h" #include "../testview.h" #include @@ -230,7 +233,9 @@ tst_TestCore::~tst_TestCore() = default; void tst_TestCore::initTestCase() { QmlModelNodeFacade::enableUglyWorkaroundForIsValidQmlModelNodeFacadeInTests(); +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo::disableParseItemLibraryDescriptionsUgly(); +#endif Exception::setShouldAssert(false); if (!QmlJS::ModelManagerInterface::instance()) @@ -257,7 +262,9 @@ void tst_TestCore::initTestCase() qDebug() << pluginPath; Q_ASSERT(QFileInfo::exists(pluginPath)); +#ifndef QDS_USE_PROJECTSTORAGE MetaInfo::initializeGlobal({pluginPath}, *externalDependencies); +#endif QFileInfo builtins(IDE_DATA_PATH "/qml-type-descriptions/builtins.qmltypes"); QStringList errors, warnings; @@ -4497,6 +4504,7 @@ bool contains(const QmlDesigner::PropertyMetaInfos &properties, QUtf8StringView } } // namespace +#ifndef QDS_USE_PROJECTSTORAGE void tst_TestCore::testSubComponentManager() { const QString qmlString("import QtQuick 2.15\n" @@ -4529,10 +4537,10 @@ void tst_TestCore::testSubComponentManager() auto model(createModel("QtQuick.Rectangle", 2, 15)); model->setFileUrl(QUrl::fromLocalFile(fileName)); ExternalDependenciesFake externalDependenciesFake{model.get()}; + QScopedPointer subComponentManager( new SubComponentManager(model.get(), externalDependenciesFake)); subComponentManager->update(QUrl::fromLocalFile(fileName), model->imports()); - QVERIFY(model->hasNodeMetaInfo("QtQuick.Rectangle", 2, 15)); QVERIFY(contains(model->metaInfo("QtQuick.Rectangle").properties(), "border.width")); @@ -4553,6 +4561,7 @@ void tst_TestCore::testSubComponentManager() QVERIFY(contains(myButtonMetaInfo.properties(), "border.width")); QVERIFY(myButtonMetaInfo.hasProperty("border.width")); } +#endif void tst_TestCore::testAnchorsAndRewriting() { diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h index 1304f4aa654..a38bf36faf7 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h @@ -171,7 +171,9 @@ private slots: void testCopyModelRewriter2(); void testMergeModelRewriter1_data(); void testMergeModelRewriter1(); +#ifndef QDS_USE_PROJECTSTORAGE void testSubComponentManager(); +#endif void testAnchorsAndRewriting(); void testAnchorsAndRewritingCenter(); diff --git a/tests/unit/tests/matchers/CMakeLists.txt b/tests/unit/tests/matchers/CMakeLists.txt index 32a7dad99c3..1eba9d4747e 100644 --- a/tests/unit/tests/matchers/CMakeLists.txt +++ b/tests/unit/tests/matchers/CMakeLists.txt @@ -7,6 +7,7 @@ add_qtc_library(TestMatchers OBJECT SOURCES info_exportedtypenames-matcher.h import-matcher.h + projectstorage-matcher.h strippedstring-matcher.h unittest-matchers.h version-matcher.h diff --git a/tests/unit/tests/matchers/projectstorage-matcher.h b/tests/unit/tests/matchers/projectstorage-matcher.h new file mode 100644 index 00000000000..5ce6512c14e --- /dev/null +++ b/tests/unit/tests/matchers/projectstorage-matcher.h @@ -0,0 +1,55 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../utils/googletest.h" + +#include + +MATCHER_P2(IsTypeHint, + name, + expression, + std::string(negation ? "isn't " : "is ") + + PrintToString(QmlDesigner::Storage::Info::TypeHint{name, expression})) +{ + const QmlDesigner::Storage::Info::TypeHint &typeHint = arg; + + return typeHint.name == name && typeHint.expression == expression; +} + +template +auto IsItemLibraryEntry(QmlDesigner::TypeId typeId, + Utils::SmallStringView name, + Utils::SmallStringView iconPath, + Utils::SmallStringView category, + Utils::SmallStringView import, + Utils::SmallStringView toolTip, + Utils::SmallStringView templatePath, + PropertiesMatcher propertiesMatcher, + ExtraFilePathsMatcher extraFilePathsMatcher) +{ + using QmlDesigner::Storage::Info::ItemLibraryEntry; + return AllOf(Field("typeId", &ItemLibraryEntry::typeId, typeId), + Field("name", &ItemLibraryEntry::name, name), + Field("iconPath", &ItemLibraryEntry::iconPath, iconPath), + Field("category", &ItemLibraryEntry::category, category), + Field("import", &ItemLibraryEntry::import, import), + Field("toolTip", &ItemLibraryEntry::toolTip, toolTip), + Field("templatePath", &ItemLibraryEntry::templatePath, templatePath), + Field("properties", &ItemLibraryEntry::properties, propertiesMatcher), + Field("extraFilePaths", &ItemLibraryEntry::extraFilePaths, extraFilePathsMatcher)); +} + +MATCHER_P3(IsItemLibraryProperty, + name, + type, + value, + std::string(negation ? "isn't " : "is ") + + PrintToString(QmlDesigner::Storage::Info::ItemLibraryProperty( + name, type, Sqlite::ValueView::create(value)))) +{ + const QmlDesigner::Storage::Info::ItemLibraryProperty &property = arg; + + return property.name == name && property.type == type && property.value == value; +} diff --git a/tests/unit/tests/matchers/strippedstring-matcher.h b/tests/unit/tests/matchers/strippedstring-matcher.h index 3c491cba8f8..f3acbfb09e5 100644 --- a/tests/unit/tests/matchers/strippedstring-matcher.h +++ b/tests/unit/tests/matchers/strippedstring-matcher.h @@ -19,6 +19,11 @@ public: : m_content(strip(std::move(content))) {} + bool MatchAndExplain(std::string_view s, testing::MatchResultListener *listener) const + { + return MatchAndExplain(QString::fromUtf8(s.data(), Utils::ssize(s)), listener); + } + bool MatchAndExplain(const QString &s, testing::MatchResultListener *listener) const { auto strippedContent = strip(s); @@ -79,3 +84,9 @@ inline auto StrippedStringEq(const QStringView &content) { return ::testing::PolymorphicMatcher(Internal::StippedStringEqMatcher(content.toString())); } + +inline auto StrippedStringEq(const std::string_view &content) +{ + return ::testing::PolymorphicMatcher( + Internal::StippedStringEqMatcher(QString::fromUtf8(content.data(), Utils::ssize(content)))); +} diff --git a/tests/unit/tests/mocks/CMakeLists.txt b/tests/unit/tests/mocks/CMakeLists.txt index bd34e15c68c..d2090432626 100644 --- a/tests/unit/tests/mocks/CMakeLists.txt +++ b/tests/unit/tests/mocks/CMakeLists.txt @@ -24,6 +24,7 @@ add_qtc_library(TestMocks OBJECT propertycomponentgeneratormock.h projectstoragemock.cpp projectstoragemock.h + projectstorageobservermock.h projectstoragepathwatchermock.h projectstoragepathwatchernotifiermock.h qmldocumentparsermock.h diff --git a/tests/unit/tests/mocks/projectstoragemock.cpp b/tests/unit/tests/mocks/projectstoragemock.cpp index ac829d21a3f..83ff85fe9a3 100644 --- a/tests/unit/tests/mocks/projectstoragemock.cpp +++ b/tests/unit/tests/mocks/projectstoragemock.cpp @@ -203,6 +203,29 @@ void ProjectStorageMock::setPropertyEditorPathId(QmlDesigner::TypeId typeId, ON_CALL(*this, propertyEditorPathId(Eq(typeId))).WillByDefault(Return(sourceId)); } +void ProjectStorageMock::setTypeHints(QmlDesigner::TypeId typeId, + const Storage::Info::TypeHints &typeHints) +{ + ON_CALL(*this, typeHints(Eq(typeId))).WillByDefault(Return(typeHints)); +} + +void ProjectStorageMock::setTypeIconPath(QmlDesigner::TypeId typeId, Utils::SmallStringView path) +{ + ON_CALL(*this, typeIconPath(Eq(typeId))).WillByDefault(Return(path)); +} + +void ProjectStorageMock::setItemLibraryEntries( + QmlDesigner::TypeId typeId, const QmlDesigner::Storage::Info::ItemLibraryEntries &entries) +{ + ON_CALL(*this, itemLibraryEntries(TypedEq(typeId))).WillByDefault(Return(entries)); +} + +void ProjectStorageMock::setItemLibraryEntries( + QmlDesigner::SourceId sourceId, const QmlDesigner::Storage::Info::ItemLibraryEntries &entries) +{ + ON_CALL(*this, itemLibraryEntries(TypedEq(sourceId))).WillByDefault(Return(entries)); +} + namespace { void addBaseProperties(TypeId typeId, TypeIds baseTypeIds, ProjectStorageMock &storage) { @@ -310,7 +333,7 @@ TypeId ProjectStorageMock::createObject(ModuleId moduleId, defaultPropertyName, defaultPropertyTraits, defaultPropertyTypeId, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, baseTypeIds, sourceId); } @@ -319,14 +342,19 @@ TypeId ProjectStorageMock::createObject(ModuleId moduleId, Utils::SmallStringView typeName, TypeIds baseTypeIds) { - return createType(moduleId, typeName, Storage::TypeTraits::Reference, baseTypeIds); + return createType(moduleId, typeName, Storage::TypeTraitsKind::Reference, baseTypeIds); } QmlDesigner::TypeId ProjectStorageMock::createValue(QmlDesigner::ModuleId moduleId, Utils::SmallStringView typeName, QmlDesigner::TypeIds baseTypeIds) { - return createType(moduleId, typeName, Storage::TypeTraits::Value, baseTypeIds); + return createType(moduleId, typeName, Storage::TypeTraitsKind::Value, baseTypeIds); +} + +void ProjectStorageMock::setHeirs(QmlDesigner::TypeId typeId, QmlDesigner::TypeIds heirIds) +{ + ON_CALL(*this, heirIds(typeId)).WillByDefault(Return(heirIds)); } ProjectStorageMock::ProjectStorageMock() diff --git a/tests/unit/tests/mocks/projectstoragemock.h b/tests/unit/tests/mocks/projectstoragemock.h index e55841f4786..198e54b370b 100644 --- a/tests/unit/tests/mocks/projectstoragemock.h +++ b/tests/unit/tests/mocks/projectstoragemock.h @@ -84,6 +84,8 @@ public: Utils::SmallStringView typeName, QmlDesigner::TypeIds baseTypeIds = {}); + void setHeirs(QmlDesigner::TypeId typeId, QmlDesigner::TypeIds heirIds); + QmlDesigner::PropertyDeclarationId createProperty( QmlDesigner::TypeId typeId, Utils::SmallString name, @@ -100,6 +102,14 @@ public: void createFunction(QmlDesigner::TypeId typeId, Utils::SmallString name); void setPropertyEditorPathId(QmlDesigner::TypeId typeId, QmlDesigner::SourceId sourceId); + void setTypeHints(QmlDesigner::TypeId typeId, + const QmlDesigner::Storage::Info::TypeHints &typeHints); + void setTypeIconPath(QmlDesigner::TypeId typeId, Utils::SmallStringView path); + void setItemLibraryEntries(QmlDesigner::TypeId typeId, + const QmlDesigner::Storage::Info::ItemLibraryEntries &entries); + void setItemLibraryEntries(QmlDesigner::SourceId sourceId, + const QmlDesigner::Storage::Info::ItemLibraryEntries &entries); + MOCK_METHOD(void, synchronize, (QmlDesigner::Storage::Synchronization::SynchronizationPackage package), @@ -109,14 +119,8 @@ public: (const QmlDesigner::Storage::Imports imports, QmlDesigner::SourceId sourceId), (override)); - MOCK_METHOD(void, - addRefreshCallback, - (std::function * callback), - (override)); - MOCK_METHOD(void, - removeRefreshCallback, - (std::function * callback), - (override)); + MOCK_METHOD(void, addObserver, (QmlDesigner::ProjectStorageObserver *), (override)); + MOCK_METHOD(void, removeObserver, (QmlDesigner::ProjectStorageObserver *), (override)); MOCK_METHOD(QmlDesigner::ModuleId, moduleId, (::Utils::SmallStringView), (const, override)); @@ -140,7 +144,10 @@ public: ::Utils::SmallStringView exportedTypeName, QmlDesigner::Storage::Version version), (const, override)); - + MOCK_METHOD((QVarLengthArray), + typeIds, + (QmlDesigner::ModuleId moduleId), + (const, override)); MOCK_METHOD(QmlDesigner::Storage::Info::ExportedTypeNames, exportedTypeNames, (QmlDesigner::TypeId), @@ -179,6 +186,23 @@ public: type, (QmlDesigner::TypeId typeId), (const, override)); + MOCK_METHOD(Utils::PathString, typeIconPath, (QmlDesigner::TypeId typeId), (const, override)); + MOCK_METHOD(QmlDesigner::Storage::Info::TypeHints, + typeHints, + (QmlDesigner::TypeId typeId), + (const, override)); + MOCK_METHOD(QmlDesigner::Storage::Info::ItemLibraryEntries, + itemLibraryEntries, + (QmlDesigner::TypeId typeId), + (const, override)); + MOCK_METHOD(QmlDesigner::Storage::Info::ItemLibraryEntries, + itemLibraryEntries, + (QmlDesigner::SourceId sourceId), + (const, override)); + MOCK_METHOD(QmlDesigner::Storage::Info::ItemLibraryEntries, + allItemLibraryEntries, + (), + (const, override)); MOCK_METHOD(std::vector<::Utils::SmallString>, signalDeclarationNames, (QmlDesigner::TypeId typeId), @@ -193,6 +217,7 @@ public: (const, override)); MOCK_METHOD(QmlDesigner::TypeIds, prototypeAndSelfIds, (QmlDesigner::TypeId type), (const, override)); MOCK_METHOD(QmlDesigner::TypeIds, prototypeIds, (QmlDesigner::TypeId type), (const, override)); + MOCK_METHOD(QmlDesigner::TypeIds, heirIds, (QmlDesigner::TypeId type), (const, override)); MOCK_METHOD(bool, isBasedOn, (QmlDesigner::TypeId typeId, QmlDesigner::TypeId), (const, override)); MOCK_METHOD(bool, isBasedOn, diff --git a/tests/unit/tests/mocks/projectstorageobservermock.h b/tests/unit/tests/mocks/projectstorageobservermock.h new file mode 100644 index 00000000000..93a14bc09d0 --- /dev/null +++ b/tests/unit/tests/mocks/projectstorageobservermock.h @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../utils/googletest.h" + +#include + +class ProjectStorageObserverMock : public QmlDesigner::ProjectStorageObserver +{ +public: + MOCK_METHOD(void, removedTypeIds, (const QmlDesigner::TypeIds &), (override)); +}; diff --git a/tests/unit/tests/printers/gtest-creator-printing.cpp b/tests/unit/tests/printers/gtest-creator-printing.cpp index 81572a7b359..f8a9fc48a68 100644 --- a/tests/unit/tests/printers/gtest-creator-printing.cpp +++ b/tests/unit/tests/printers/gtest-creator-printing.cpp @@ -157,6 +157,11 @@ void PrintTo(const Utils::SmallString &text, ::std::ostream *os) *os << "\"" << text << "\""; } +void PrintTo(const Utils::BasicSmallString<94> &text, ::std::ostream *os) +{ + *os << "\"" << text << "\""; +} + void PrintTo(const Utils::PathString &text, ::std::ostream *os) { *os << "\"" << text << "\""; @@ -511,6 +516,23 @@ std::ostream &operator<<(std::ostream &out, const ModelResourceSet &set) << set.setExpressions << ")"; } +std::ostream &operator<<(std::ostream &out, FlagIs flagIs) +{ + switch (flagIs) { + case QmlDesigner::FlagIs::False: + out << "False"; + break; + case QmlDesigner::FlagIs::True: + out << "True"; + break; + case QmlDesigner::FlagIs::Set: + out << "Set"; + break; + } + + return out; +} + namespace Cache { std::ostream &operator<<(std::ostream &out, const SourceContext &sourceContext) @@ -521,45 +543,87 @@ std::ostream &operator<<(std::ostream &out, const SourceContext &sourceContext) namespace Storage { -namespace { -TypeTraits cleanFlags(TypeTraits traits) +std::ostream &operator<<(std::ostream &out, TypeTraitsKind kind) { - auto data = static_cast(traits); - data &= ~static_cast(TypeTraits::IsEnum); - return static_cast(data); -} - -const char *typeTraitsToString(TypeTraits traits) -{ - switch (cleanFlags(traits)) { - case TypeTraits::None: - return "None"; - case TypeTraits::Reference: - return "Reference"; - case TypeTraits::Sequence: - return "Sequence"; - case TypeTraits::Value: - return "Value"; + switch (kind) { + case TypeTraitsKind::None: + out << "None"; + break; + case TypeTraitsKind::Reference: + out << "Reference"; + break; + case TypeTraitsKind::Sequence: + out << "Sequence"; + break; + case TypeTraitsKind::Value: + out << "Value"; + break; default: break; } - return ""; + return out; } -const char *typeTraitsFlagsToString(TypeTraits traits) -{ - if (bool(traits & TypeTraits::IsEnum)) - return "(IsEnum)"; - - return ""; -} - -} // namespace - std::ostream &operator<<(std::ostream &out, TypeTraits traits) { - return out << typeTraitsToString(traits) << typeTraitsFlagsToString(traits); + out << "(" << traits.kind; + + if (traits.isEnum) + out << " | isEnum"; + + if (traits.isFileComponent) + out << " | isFileComponent"; + + if (traits.isProjectComponent) + out << " | isProjectComponent"; + + if (traits.isInProjectModule) + out << " | isInProjectModule"; + + if (traits.usesCustomParser) + out << " | usesCustomParser"; + + if (traits.canBeContainer != QmlDesigner::FlagIs::False) + out << " | canBeContainer(" << traits.canBeContainer << ")"; + + if (traits.forceClip != QmlDesigner::FlagIs::False) + out << " | forceClip(" << traits.forceClip << ")"; + + if (traits.doesLayoutChildren != QmlDesigner::FlagIs::False) + out << " | doesLayoutChildren(" << traits.doesLayoutChildren << ")"; + + if (traits.canBeDroppedInFormEditor != QmlDesigner::FlagIs::False) + out << " | canBeDroppedInFormEditor(" << traits.canBeDroppedInFormEditor << ")"; + + if (traits.canBeDroppedInNavigator != QmlDesigner::FlagIs::False) + out << " | canBeDroppedInNavigator(" << traits.canBeDroppedInNavigator << ")"; + + if (traits.canBeDroppedInView3D != QmlDesigner::FlagIs::False) + out << " | canBeDroppedInView3D(" << traits.canBeDroppedInView3D << ")"; + + if (traits.isMovable != QmlDesigner::FlagIs::False) + out << " | isMovable(" << traits.isMovable << ")"; + + if (traits.isResizable != QmlDesigner::FlagIs::False) + out << " | isResizable(" << traits.isResizable << ")"; + + if (traits.hasFormEditorItem != QmlDesigner::FlagIs::False) + out << " | hasFormEditorItem(" << traits.hasFormEditorItem << ")"; + + if (traits.isStackedContainer != QmlDesigner::FlagIs::False) + out << " | isStackedContainer(" << traits.isStackedContainer << ")"; + + if (traits.takesOverRenderingOfChildren != QmlDesigner::FlagIs::False) + out << " | takesOverRenderingOfChildren(" << traits.takesOverRenderingOfChildren << ")"; + + if (traits.visibleInNavigator != QmlDesigner::FlagIs::False) + out << " | visibleInNavigator(" << traits.visibleInNavigator << ")"; + + if (traits.visibleInLibrary != QmlDesigner::FlagIs::False) + out << " | visibleInLibrary(" << traits.visibleInLibrary << ")"; + + return out << ")"; } std::ostream &operator<<(std::ostream &out, PropertyDeclarationTraits traits) @@ -615,8 +679,27 @@ std::ostream &operator<<(std::ostream &out, const Type &type) std::ostream &operator<<(std::ostream &out, const ExportedTypeName &name) { - return out << "(\"" << name.name << "\"," << name.moduleId << ", " << name.version << ")"; + return out << "(\"" << name.name << "\", " << name.moduleId << ", " << name.version << ")"; } + +std::ostream &operator<<(std::ostream &out, const TypeHint &hint) +{ + return out << "(\"" << hint.name << "\", \"" << hint.expression << "\")"; +} + +std::ostream &operator<<(std::ostream &out, const ItemLibraryProperty &property) +{ + return out << "(\"" << property.name << "\"," << property.type << "," << property.value << ")"; +} + +std::ostream &operator<<(std::ostream &out, const ItemLibraryEntry &entry) +{ + return out << R"((")" << entry.name << R"(", ")" << entry.iconPath << R"(", ")" + << entry.category << R"(", ")" << entry.import << R"(", ")" << entry.toolTip + << R"(", ")" << entry.templatePath << R"(", )" << entry.properties << ", " + << entry.extraFilePaths << ")"; +} + } // namespace Storage::Info namespace Storage::Synchronization { @@ -815,6 +898,14 @@ std::ostream &operator<<(std::ostream &out, const PropertyEditorQmlPath &path) return out << "(" << path.moduleId << ", " << path.typeName << ", " << path.pathId << ")"; } +std::ostream &operator<<(std::ostream &out, const TypeAnnotation &annotation) +{ + return out << R"x((")x" << annotation.typeName << R"(", )" << annotation.moduleId << ", " + << annotation.sourceId << R"(, ")" << annotation.iconPath << R"(", )" + << annotation.traits << R"(, ")" << annotation.hintsJson << R"(", ")" + << annotation.itemLibraryJson << R"x("))x"; +} + } // namespace Storage::Synchronization namespace ImageCache { diff --git a/tests/unit/tests/printers/gtest-creator-printing.h b/tests/unit/tests/printers/gtest-creator-printing.h index b01bbf1fb8d..8d0c77888ec 100644 --- a/tests/unit/tests/printers/gtest-creator-printing.h +++ b/tests/unit/tests/printers/gtest-creator-printing.h @@ -93,6 +93,7 @@ void PrintTo(const std::optional &optional, ::std::ostream *os) void PrintTo(Utils::SmallStringView text, ::std::ostream *os); void PrintTo(const Utils::SmallString &text, ::std::ostream *os); +void PrintTo(const Utils::BasicSmallString<94> &text, ::std::ostream *os); void PrintTo(const Utils::PathString &text, ::std::ostream *os); } // namespace Utils @@ -124,6 +125,7 @@ class Import; class NodeMetaInfo; class PropertyMetaInfo; struct CompoundPropertyMetaInfo; +enum class FlagIs : unsigned int; std::ostream &operator<<(std::ostream &out, const ModelNode &node); std::ostream &operator<<(std::ostream &out, const VariantProperty &property); @@ -139,6 +141,7 @@ std::ostream &operator<<(std::ostream &out, const ModelResourceSet &modelResourc std::ostream &operator<<(std::ostream &out, const NodeMetaInfo &metaInfo); std::ostream &operator<<(std::ostream &out, const PropertyMetaInfo &metaInfo); std::ostream &operator<<(std::ostream &out, const CompoundPropertyMetaInfo &metaInfo); +std::ostream &operator<<(std::ostream &out, FlagIs flagIs); namespace Cache { class SourceContext; @@ -158,12 +161,14 @@ std::ostream &operator<<(std::ostream &out, const FontCollectorSizesAuxiliaryDat namespace Storage { enum class PropertyDeclarationTraits : int; -enum class TypeTraits : int; +enum class TypeTraitsKind : unsigned int; +struct TypeTraits; class Import; class Version; class VersionNumber; std::ostream &operator<<(std::ostream &out, PropertyDeclarationTraits traits); +std::ostream &operator<<(std::ostream &out, TypeTraitsKind kind); std::ostream &operator<<(std::ostream &out, TypeTraits traits); std::ostream &operator<<(std::ostream &out, const Import &import); std::ostream &operator<<(std::ostream &out, VersionNumber versionNumber); @@ -175,10 +180,16 @@ namespace Storage::Info { class ProjectDeclaration; class Type; class ExportedTypeName; +struct TypeHint; +struct ItemLibraryProperty; +struct ItemLibraryEntry; std::ostream &operator<<(std::ostream &out, const ProjectDeclaration &declaration); std::ostream &operator<<(std::ostream &out, const Type &type); std::ostream &operator<<(std::ostream &out, const ExportedTypeName &name); +std::ostream &operator<<(std::ostream &out, const TypeHint &hint); +std::ostream &operator<<(std::ostream &out, const ItemLibraryProperty &property); +std::ostream &operator<<(std::ostream &out, const ItemLibraryEntry &entry); } // namespace Storage::Info @@ -202,6 +213,7 @@ enum class FileType : char; enum class ChangeLevel : char; class ModuleExportedImport; class PropertyEditorQmlPath; +class TypeAnnotation; std::ostream &operator<<(std::ostream &out, const Type &type); std::ostream &operator<<(std::ostream &out, const ExportedType &exportedType); @@ -221,6 +233,7 @@ std::ostream &operator<<(std::ostream &out, FileType fileType); std::ostream &operator<<(std::ostream &out, ChangeLevel changeLevel); std::ostream &operator<<(std::ostream &out, const ModuleExportedImport &import); std::ostream &operator<<(std::ostream &out, const PropertyEditorQmlPath &path); +std::ostream &operator<<(std::ostream &out, const TypeAnnotation &annotation); } // namespace Storage::Synchronization diff --git a/tests/unit/tests/printers/gtest-qt-printing.h b/tests/unit/tests/printers/gtest-qt-printing.h index ceec63817cc..97e6822a7bd 100644 --- a/tests/unit/tests/printers/gtest-qt-printing.h +++ b/tests/unit/tests/printers/gtest-qt-printing.h @@ -6,6 +6,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -15,6 +16,24 @@ class QStringView; class QTextCharFormat; class QImage; class QIcon; +template +class QVarLengthArray; + +template +std::ostream &operator<<(std::ostream &out, const QVarLengthArray &array) +{ + out << "["; + + int i = 0; + for (auto &&value : array) { + i++; + out << value; + if (i < array.size()) + out << ", "; + } + + return out << "]"; +} std::ostream &operator<<(std::ostream &out, const QVariant &QVariant); std::ostream &operator<<(std::ostream &out, const QString &text); diff --git a/tests/unit/tests/testdesignercore/CMakeLists.txt b/tests/unit/tests/testdesignercore/CMakeLists.txt index 0847caa3230..df91b656eb5 100644 --- a/tests/unit/tests/testdesignercore/CMakeLists.txt +++ b/tests/unit/tests/testdesignercore/CMakeLists.txt @@ -61,9 +61,7 @@ add_qtc_library(TestDesignerCore OBJECT include/bindingproperty.h include/imagecacheauxiliarydata.h include/import.h - include/itemlibraryinfo.h - include/metainfo.h - include/metainforeader.h + include/itemlibraryentry.h include/modelnode.h include/module.h include/nodeabstractproperty.h @@ -78,9 +76,7 @@ add_qtc_library(TestDesignerCore OBJECT include/signalhandlerproperty.h include/synchronousimagecache.h include/variantproperty.h - metainfo/itemlibraryinfo.cpp - metainfo/metainfo.cpp - metainfo/metainforeader.cpp + metainfo/itemlibraryentry.cpp metainfo/nodemetainfo.cpp model/abstractproperty.cpp model/abstractview.cpp @@ -127,6 +123,7 @@ add_qtc_library(TestDesignerCore OBJECT projectstorage/nonlockingmutex.h projectstorage/projectstorageexceptions.cpp projectstorage/projectstorageexceptions.h projectstorage/projectstorageinterface.h + projectstorage/projectstorageobserver.h projectstorage/projectstorage.cpp projectstorage/projectstorage.h projectstorage/projectstoragepathwatcher.h projectstorage/projectstoragepathwatcherinterface.h @@ -143,6 +140,8 @@ add_qtc_library(TestDesignerCore OBJECT projectstorage/storagecache.h projectstorage/storagecacheentry.h projectstorage/storagecachefwd.h + projectstorage/typeannotationreader.cpp + projectstorage/typeannotationreader.h projectstorage/qmldocumentparserinterface.h projectstorage/qmltypesparserinterface.h rewritertransaction.cpp diff --git a/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp b/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp index c21d3259365..af8c4bd2209 100644 --- a/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp +++ b/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp @@ -4,6 +4,7 @@ #include "../utils/googletest.h" #include +#include #include #include @@ -13,8 +14,11 @@ namespace { +using QmlDesigner::FlagIs; using QmlDesigner::ModelNode; using QmlDesigner::ModelNodes; +using QmlDesigner::Storage::TypeTraits; +using QmlDesigner::Storage::TypeTraitsKind; template auto PropertyId(const Matcher &matcher) @@ -211,11 +215,10 @@ TEST_F(NodeMetaInfo, invalid_is_not_file_component) TEST_F(NodeMetaInfo, component_is_file_component) { - using QmlDesigner::Storage::TypeTraits; auto moduleId = projectStorageMock.createModule("/path/to/project"); - auto typeId = projectStorageMock.createType(moduleId, - "Foo", - TypeTraits::IsFileComponent | TypeTraits::Reference); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.isFileComponent = true; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; bool isFileComponent = metaInfo.isFileComponent(); @@ -225,9 +228,10 @@ TEST_F(NodeMetaInfo, component_is_file_component) TEST_F(NodeMetaInfo, is_project_component) { - using QmlDesigner::Storage::TypeTraits; auto moduleId = projectStorageMock.createModule("/path/to/project"); - auto typeId = projectStorageMock.createType(moduleId, "Foo", TypeTraits::IsProjectComponent); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.isProjectComponent = true; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; bool isProjectComponent = metaInfo.isProjectComponent(); @@ -258,9 +262,10 @@ TEST_F(NodeMetaInfo, invalid_is_not_project_component) TEST_F(NodeMetaInfo, is_in_project_module) { - using QmlDesigner::Storage::TypeTraits; auto moduleId = projectStorageMock.createModule("/path/to/project"); - auto typeId = projectStorageMock.createType(moduleId, "Foo", TypeTraits::IsInProjectModule); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.isInProjectModule = true; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; bool isInProjectModule = metaInfo.isInProjectModule(); @@ -793,6 +798,25 @@ TEST_F(NodeMetaInfo, prototypes_returns_empty_container_for_default) ASSERT_THAT(prototypes, IsEmpty()); } +TEST_F(NodeMetaInfo, heirs) +{ + auto metaInfo = model.qmlQtObjectMetaInfo(); + projectStorageMock.setHeirs(metaInfo.id(), {model.qtQuickItemMetaInfo().id()}); + + auto heirs = metaInfo.heirs(); + + ASSERT_THAT(heirs, ElementsAre(model.qtQuickItemMetaInfo())); +} + +TEST_F(NodeMetaInfo, heirs_returns_empty_container_for_default) +{ + auto metaInfo = QmlDesigner::NodeMetaInfo(); + + auto heirs = metaInfo.heirs(); + + ASSERT_THAT(heirs, IsEmpty()); +} + TEST_F(NodeMetaInfo, common_base_is_root) { auto metaInfo = model.flowViewFlowActionAreaMetaInfo(); @@ -2402,7 +2426,9 @@ TEST_F(NodeMetaInfo, default_is_not_view) TEST_F(NodeMetaInfo, is_enumeration) { - auto metaInfo = createMetaInfo("QML", "Foo", QmlDesigner::Storage::TypeTraits::IsEnum); + TypeTraits traits; + traits.isEnum = true; + auto metaInfo = createMetaInfo("QML", "Foo", traits); bool isType = metaInfo.isEnumeration(); @@ -2562,7 +2588,7 @@ TEST_F(NodeMetaInfo, default_property_editor_specifics_path_is_empty) TEST_F(NodeMetaInfo, is_reference) { - auto metaInfo = createMetaInfo("QtQuick", "Item", QmlDesigner::Storage::TypeTraits::Reference); + auto metaInfo = createMetaInfo("QtQuick", "Item", TypeTraitsKind::Reference); auto type = metaInfo.type(); @@ -2571,7 +2597,7 @@ TEST_F(NodeMetaInfo, is_reference) TEST_F(NodeMetaInfo, is_value) { - auto metaInfo = createMetaInfo("QML", "bool", QmlDesigner::Storage::TypeTraits::Value); + auto metaInfo = createMetaInfo("QML", "bool", TypeTraitsKind::Value); auto type = metaInfo.type(); @@ -2580,7 +2606,7 @@ TEST_F(NodeMetaInfo, is_value) TEST_F(NodeMetaInfo, is_sequence) { - auto metaInfo = createMetaInfo("QML", "QObjectList", QmlDesigner::Storage::TypeTraits::Sequence); + auto metaInfo = createMetaInfo("QML", "QObjectList", TypeTraitsKind::Sequence); auto type = metaInfo.type(); @@ -2589,7 +2615,7 @@ TEST_F(NodeMetaInfo, is_sequence) TEST_F(NodeMetaInfo, is_none) { - auto metaInfo = createMetaInfo("QML", "void", QmlDesigner::Storage::TypeTraits::None); + auto metaInfo = createMetaInfo("QML", "void", TypeTraitsKind::None); auto type = metaInfo.type(); @@ -2605,4 +2631,555 @@ TEST_F(NodeMetaInfo, default_is_none) ASSERT_THAT(type, QmlDesigner::MetaInfoType::None); } +TEST_F(NodeMetaInfo, object_can_not_be_container) +{ + auto canBeContainer = objectMetaInfo.canBeContainer(); + + ASSERT_THAT(canBeContainer, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_can_not_be_container) +{ + auto canBeContainer = QmlDesigner::NodeMetaInfo{}.canBeContainer(); + + ASSERT_THAT(canBeContainer, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_can_not_be_container) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto canBeContainer = metaInfo.canBeContainer(); + + ASSERT_THAT(canBeContainer, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_can_be_container) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeContainer = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto canBeContainer = metaInfo.canBeContainer(); + + ASSERT_THAT(canBeContainer, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_do_no_forces_clipping) +{ + auto forceClip = objectMetaInfo.forceClip(); + + ASSERT_THAT(forceClip, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_do_no_forces_clipping) +{ + auto forceClip = QmlDesigner::NodeMetaInfo{}.forceClip(); + + ASSERT_THAT(forceClip, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_do_no_forces_clipping) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto forceClip = metaInfo.forceClip(); + + ASSERT_THAT(forceClip, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_forces_clipping) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.forceClip = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto forceClip = metaInfo.forceClip(); + + ASSERT_THAT(forceClip, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_does_not_layout_children) +{ + auto doesLayoutChildren = objectMetaInfo.doesLayoutChildren(); + + ASSERT_THAT(doesLayoutChildren, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_does_not_layout_children) +{ + auto doesLayoutChildren = QmlDesigner::NodeMetaInfo{}.doesLayoutChildren(); + + ASSERT_THAT(doesLayoutChildren, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_does_not_layout_children) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto doesLayoutChildren = metaInfo.doesLayoutChildren(); + + ASSERT_THAT(doesLayoutChildren, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_layouts_children) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.doesLayoutChildren = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto doesLayoutChildren = metaInfo.doesLayoutChildren(); + + ASSERT_THAT(doesLayoutChildren, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_cannot_be_dropped_in_form_editor) +{ + auto canBeDroppedInFormEditor = objectMetaInfo.canBeDroppedInFormEditor(); + + ASSERT_THAT(canBeDroppedInFormEditor, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_cannot_be_dropped_in_form_editor) +{ + auto canBeDroppedInFormEditor = QmlDesigner::NodeMetaInfo{}.canBeDroppedInFormEditor(); + + ASSERT_THAT(canBeDroppedInFormEditor, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_cannot_be_dropped_in_form_editor) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto canBeDroppedInFormEditor = metaInfo.canBeDroppedInFormEditor(); + + ASSERT_THAT(canBeDroppedInFormEditor, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_can_be_dropped_in_form_editor) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeDroppedInFormEditor = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto canBeDroppedInFormEditor = metaInfo.canBeDroppedInFormEditor(); + + ASSERT_THAT(canBeDroppedInFormEditor, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_cannot_be_dropped_in_navigator) +{ + auto canBeDroppedInNavigator = objectMetaInfo.canBeDroppedInNavigator(); + + ASSERT_THAT(canBeDroppedInNavigator, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_cannot_be_dropped_in_navigator) +{ + auto canBeDroppedInNavigator = QmlDesigner::NodeMetaInfo{}.canBeDroppedInNavigator(); + + ASSERT_THAT(canBeDroppedInNavigator, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_cannot_be_dropped_in_navigator) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto canBeDroppedInNavigator = metaInfo.canBeDroppedInNavigator(); + + ASSERT_THAT(canBeDroppedInNavigator, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_can_be_dropped_in_navigator) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeDroppedInNavigator = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto canBeDroppedInNavigator = metaInfo.canBeDroppedInNavigator(); + + ASSERT_THAT(canBeDroppedInNavigator, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_cannot_be_dropped_in_3d_view) +{ + auto canBeDroppedInView3D = objectMetaInfo.canBeDroppedInView3D(); + + ASSERT_THAT(canBeDroppedInView3D, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_cannot_be_dropped_in_3d_view) +{ + auto canBeDroppedInView3D = QmlDesigner::NodeMetaInfo{}.canBeDroppedInView3D(); + + ASSERT_THAT(canBeDroppedInView3D, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_cannot_be_dropped_in_3d_view) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto canBeDroppedInView3D = metaInfo.canBeDroppedInView3D(); + + ASSERT_THAT(canBeDroppedInView3D, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_can_be_dropped_in_3d_view) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeDroppedInView3D = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto canBeDroppedInView3D = metaInfo.canBeDroppedInView3D(); + + ASSERT_THAT(canBeDroppedInView3D, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_is_not_movable) +{ + auto isMovable = objectMetaInfo.isMovable(); + + ASSERT_THAT(isMovable, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_is_not_movable) +{ + auto isMovable = QmlDesigner::NodeMetaInfo{}.isMovable(); + + ASSERT_THAT(isMovable, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_is_not_movable) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto isMovable = metaInfo.isMovable(); + + ASSERT_THAT(isMovable, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_is_movable) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.isMovable = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto isMovable = metaInfo.isMovable(); + + ASSERT_THAT(isMovable, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_is_not_resizable) +{ + auto isResizable = objectMetaInfo.isResizable(); + + ASSERT_THAT(isResizable, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_is_not_resizable) +{ + auto isResizable = QmlDesigner::NodeMetaInfo{}.isResizable(); + + ASSERT_THAT(isResizable, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_is_not_resizable) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto isResizable = metaInfo.isResizable(); + + ASSERT_THAT(isResizable, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_is_resizable) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.isResizable = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto isResizable = metaInfo.isResizable(); + + ASSERT_THAT(isResizable, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_has_not_form_editor_item) +{ + auto hasFormEditorItem = objectMetaInfo.hasFormEditorItem(); + + ASSERT_THAT(hasFormEditorItem, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_has_not_form_editor_item) +{ + auto hasFormEditorItem = QmlDesigner::NodeMetaInfo{}.hasFormEditorItem(); + + ASSERT_THAT(hasFormEditorItem, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_has_not_form_editor_item) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto hasFormEditorItem = metaInfo.hasFormEditorItem(); + + ASSERT_THAT(hasFormEditorItem, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_has_form_editor_item) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.hasFormEditorItem = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto hasFormEditorItem = metaInfo.hasFormEditorItem(); + + ASSERT_THAT(hasFormEditorItem, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_is_not_stacked_container) +{ + auto isStackedContainer = objectMetaInfo.isStackedContainer(); + + ASSERT_THAT(isStackedContainer, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_is_not_stacked_container) +{ + auto isStackedContainer = QmlDesigner::NodeMetaInfo{}.isStackedContainer(); + + ASSERT_THAT(isStackedContainer, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_is_not_stacked_container) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto isStackedContainer = metaInfo.isStackedContainer(); + + ASSERT_THAT(isStackedContainer, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_is_stacked_container) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.isStackedContainer = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto isStackedContainer = metaInfo.isStackedContainer(); + + ASSERT_THAT(isStackedContainer, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_dont_takes_over_rendering_of_children) +{ + auto takesOverRenderingOfChildren = objectMetaInfo.takesOverRenderingOfChildren(); + + ASSERT_THAT(takesOverRenderingOfChildren, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_dont_takes_over_rendering_of_children) +{ + auto takesOverRenderingOfChildren = QmlDesigner::NodeMetaInfo{}.takesOverRenderingOfChildren(); + + ASSERT_THAT(takesOverRenderingOfChildren, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_dont_takes_over_rendering_of_children) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto takesOverRenderingOfChildren = metaInfo.takesOverRenderingOfChildren(); + + ASSERT_THAT(takesOverRenderingOfChildren, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_takes_over_rendering_of_children) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.takesOverRenderingOfChildren = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto takesOverRenderingOfChildren = metaInfo.takesOverRenderingOfChildren(); + + ASSERT_THAT(takesOverRenderingOfChildren, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_is_not_visible_in_navigator) +{ + auto visibleInNavigator = objectMetaInfo.visibleInNavigator(); + + ASSERT_THAT(visibleInNavigator, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_is_not_visible_in_navigator) +{ + auto visibleInNavigator = QmlDesigner::NodeMetaInfo{}.visibleInNavigator(); + + ASSERT_THAT(visibleInNavigator, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_is_not_visible_in_navigator) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto visibleInNavigator = metaInfo.visibleInNavigator(); + + ASSERT_THAT(visibleInNavigator, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_is_visible_in_navigator) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.visibleInNavigator = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto visibleInNavigator = metaInfo.visibleInNavigator(); + + ASSERT_THAT(visibleInNavigator, FlagIs::True); +} + +TEST_F(NodeMetaInfo, object_is_not_visible_in_library) +{ + auto visibleInLibrary = objectMetaInfo.visibleInLibrary(); + + ASSERT_THAT(visibleInLibrary, FlagIs::False); +} + +TEST_F(NodeMetaInfo, default_is_not_visible_in_library) +{ + auto visibleInLibrary = QmlDesigner::NodeMetaInfo{}.visibleInLibrary(); + + ASSERT_THAT(visibleInLibrary, FlagIs::False); +} + +TEST_F(NodeMetaInfo, invalid_is_not_visible_in_library) +{ + auto node = model.createModelNode("Foo"); + auto metaInfo = node.metaInfo(); + + auto visibleInLibrary = metaInfo.visibleInLibrary(); + + ASSERT_THAT(visibleInLibrary, FlagIs::False); +} + +TEST_F(NodeMetaInfo, component_is_visible_in_library) +{ + auto moduleId = projectStorageMock.createModule("/path/to/project"); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.visibleInLibrary = FlagIs::True; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits); + QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; + + auto visibleInLibrary = metaInfo.visibleInLibrary(); + + ASSERT_THAT(visibleInLibrary, FlagIs::True); +} + +TEST_F(NodeMetaInfo, type_hints) +{ + projectStorageMock.setTypeHints(objectMetaInfo.id(), {{"inContainer", "true"}}); + + auto typeHints = objectMetaInfo.typeHints(); + + ASSERT_THAT(typeHints, ElementsAre(IsTypeHint("inContainer", "true"))); +} + +TEST_F(NodeMetaInfo, no_type_hints_for_default) +{ + QmlDesigner::NodeMetaInfo metaInfo; + + auto typeHints = metaInfo.typeHints(); + + ASSERT_THAT(typeHints, IsEmpty()); +} + +TEST_F(NodeMetaInfo, icon_path) +{ + projectStorageMock.setTypeIconPath(objectMetaInfo.id(), "/icon/path"); + + auto path = objectMetaInfo.iconPath(); + + ASSERT_THAT(path, Eq("/icon/path")); +} + +TEST_F(NodeMetaInfo, no_icon_path_for_default) +{ + QmlDesigner::NodeMetaInfo metaInfo; + + auto path = metaInfo.iconPath(); + + ASSERT_THAT(path, IsEmpty()); +} + +TEST_F(NodeMetaInfo, item_library_entries) +{ + projectStorageMock.setItemLibraryEntries(objectMetaInfo.id(), + {{objectMetaInfo.id(), + "Object", + "/icon/path", + "Basic", + "QtQuick", + "An object", + {{"x", "double", Sqlite::ValueView::create(1)}}}}); + + auto entries = objectMetaInfo.itemLibrariesEntries(); + + ASSERT_THAT(entries, + ElementsAre(IsItemLibraryEntry(objectMetaInfo.id(), + "Object", + "/icon/path", + "Basic", + "QtQuick", + "An object", + "", + ElementsAre(IsItemLibraryProperty("x", "double", 1)), + IsEmpty()))); +} + +TEST_F(NodeMetaInfo, no_item_library_entries_for_default) +{ + QmlDesigner::NodeMetaInfo metaInfo; + + auto entries = metaInfo.itemLibrariesEntries(); + + ASSERT_THAT(entries, IsEmpty()); +} + } // namespace diff --git a/tests/unit/tests/unittests/metainfo/propertymetainfo-test.cpp b/tests/unit/tests/unittests/metainfo/propertymetainfo-test.cpp index 923743799e3..25436264aee 100644 --- a/tests/unit/tests/unittests/metainfo/propertymetainfo-test.cpp +++ b/tests/unit/tests/unittests/metainfo/propertymetainfo-test.cpp @@ -179,7 +179,9 @@ TEST_F(PropertyMetaInfo, default_is_not_list) TEST_F(PropertyMetaInfo, is_enumeration) { - auto enumInfo = createNodeMetaInfo("QtQuick", "MyEnum", TypeTraits::IsEnum); + TypeTraits traits; + traits.isEnum = true; + auto enumInfo = createNodeMetaInfo("QtQuick", "MyEnum", traits); projectStorageMock.createProperty(nodeInfo.id(), "bar", {}, enumInfo.id()); auto propertyInfo = nodeInfo.property("bar"); @@ -271,7 +273,9 @@ TEST_F(PropertyMetaInfo, default_is_not_pointer) TEST_F(PropertyMetaInfo, cast_to_enumeration) { - auto propertyTypeInfo = createNodeMetaInfo("QtQuick", "MyEnum", TypeTraits::IsEnum); + TypeTraits traits; + traits.isEnum = true; + auto propertyTypeInfo = createNodeMetaInfo("QtQuick", "MyEnum", traits); projectStorageMock.createProperty(nodeInfo.id(), "bar", {}, propertyTypeInfo.id()); auto propertyInfo = nodeInfo.property("bar"); Enumeration enumeration{"MyEnum.Foo"}; @@ -297,7 +301,9 @@ TEST_F(PropertyMetaInfo, dont_to_cast_enumeration_if_property_type_is_not_enumer TEST_F(PropertyMetaInfo, dont_to_cast_enumeration_if_value_is_not_Enumeration) { - auto propertyTypeInfo = createNodeMetaInfo("QtQuick", "MyEnum", TypeTraits::IsEnum); + TypeTraits traits; + traits.isEnum = true; + auto propertyTypeInfo = createNodeMetaInfo("QtQuick", "MyEnum", traits); projectStorageMock.createProperty(nodeInfo.id(), "bar", {}, propertyTypeInfo.id()); auto propertyInfo = nodeInfo.property("bar"); auto value = QVariant::fromValue(QString{"enumeration"}); diff --git a/tests/unit/tests/unittests/model/model-test.cpp b/tests/unit/tests/unittests/model/model-test.cpp index 71f6462c7cc..949efb3ee0a 100644 --- a/tests/unit/tests/unittests/model/model-test.cpp +++ b/tests/unit/tests/unittests/model/model-test.cpp @@ -7,9 +7,11 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -32,6 +34,40 @@ MATCHER(IsSorted, std::string(negation ? "isn't sorted" : "is sorted")) return std::is_sorted(begin(arg), end(arg)); } +template +auto IsItemLibraryEntry(const QmlDesigner::NodeMetaInfo &metaInfo, + QStringView name, + QStringView iconPath, + QStringView category, + QStringView import, + QStringView toolTip, + QStringView templatePath, + PropertiesMatcher propertiesMatcher, + ExtraFilePathsMatcher extraFilePathsMatcher) +{ + using QmlDesigner::ItemLibraryEntry; + return AllOf(Property("metaInfo", &ItemLibraryEntry::metaInfo, metaInfo), + Property("name", &ItemLibraryEntry::name, name), + Property("libraryEntryIconPath", &ItemLibraryEntry::libraryEntryIconPath, iconPath), + Property("category", &ItemLibraryEntry::category, category), + Property("requiredImport", &ItemLibraryEntry::requiredImport, import), + Property("toolTip", &ItemLibraryEntry::toolTip, toolTip), + Property("qmlSource", &ItemLibraryEntry::qmlSource, templatePath), + Property("properties", &ItemLibraryEntry::properties, propertiesMatcher), + Property("extraFilePath", &ItemLibraryEntry::extraFilePaths, extraFilePathsMatcher)); +} + +MATCHER_P3(IsItemLibraryProperty, + name, + type, + value, + std::string(negation ? "isn't " : "is ") + + PrintToString(QmlDesigner::PropertyContainer(name, type, value))) +{ + const QmlDesigner::PropertyContainer &property = arg; + + return property.name() == name && property.type() == type && property.value() == value; +} class Model : public ::testing::Test { protected: @@ -912,16 +948,16 @@ TEST_F(Model, get_invalid_meta_info_by_module_for_wrong_module) ASSERT_THAT(metaInfo, IsFalse()); } -TEST_F(Model, add_refresh_callback_to_project_storage) +TEST_F(Model, add_project_storage_observer_to_project_storage) { - EXPECT_CALL(projectStorageMock, addRefreshCallback(_)); + EXPECT_CALL(projectStorageMock, addObserver(_)); QmlDesigner::Model model{{projectStorageMock, pathCacheMock}, "Item", -1, -1, nullptr, {}}; } -TEST_F(Model, remove_refresh_callback_from_project_storage) +TEST_F(Model, remove_project_storage_observer_from_project_storage) { - EXPECT_CALL(projectStorageMock, removeRefreshCallback(_)).Times(2); // there is a model in the fixture + EXPECT_CALL(projectStorageMock, removeObserver(_)).Times(2); // the fixture model is calling it too QmlDesigner::Model model{{projectStorageMock, pathCacheMock}, "Item", -1, -1, nullptr, {}}; } @@ -930,14 +966,54 @@ TEST_F(Model, refresh_callback_is_calling_abstract_view) { const QmlDesigner::TypeIds typeIds = {QmlDesigner::TypeId::create(3), QmlDesigner::TypeId::create(1)}; - std::function *callback = nullptr; - ON_CALL(projectStorageMock, addRefreshCallback(_)).WillByDefault([&](auto *c) { callback = c; }); + ProjectStorageObserverMock observerMock; + QmlDesigner::ProjectStorageObserver *observer = nullptr; + ON_CALL(projectStorageMock, addObserver(_)).WillByDefault([&](auto *o) { observer = o; }); + QmlDesigner::Model model{{projectStorageMock, pathCacheMock}, "Item", -1, -1, nullptr, {}}; model.attachView(&viewMock); EXPECT_CALL(viewMock, refreshMetaInfos(typeIds)); - (*callback)(typeIds); + observer->removedTypeIds(typeIds); +} + +TEST_F(Model, meta_infos_for_mdoule) +{ + projectStorageMock.createModule("Foo"); + auto module = model.module("Foo"); + auto typeId = projectStorageMock.createObject(module.id(), "Bar"); + ON_CALL(projectStorageMock, typeIds(module.id())) + .WillByDefault(Return(QVarLengthArray{typeId})); + + auto types = model.metaInfosForModule(module); + + ASSERT_THAT(types, ElementsAre(Eq(QmlDesigner::NodeMetaInfo{typeId, &projectStorageMock}))); +} + +TEST_F(Model, item_library_entries) +{ + using namespace Qt::StringLiterals; + QmlDesigner::Storage::Info::ItemLibraryEntries storageEntries{ + {itemTypeId, "Item", "/path/to/icon", "basic category", "QtQuick", "It's a item", "/path/to/template"}}; + storageEntries.front().properties.emplace_back("x", "double", Sqlite::ValueView::create(1)); + storageEntries.front().extraFilePaths.emplace_back("/extra/file/path"); + projectStorageMock.setItemLibraryEntries(pathCacheMock.sourceId, storageEntries); + QmlDesigner::NodeMetaInfo metaInfo{itemTypeId, &projectStorageMock}; + + auto entries = model.itemLibraryEntries(); + + ASSERT_THAT(entries, + ElementsAre( + IsItemLibraryEntry(metaInfo, + u"Item", + u"/path/to/icon", + u"basic category", + u"QtQuick", + u"It's a item", + u"/path/to/template", + ElementsAre(IsItemLibraryProperty("x", "double"_L1, QVariant{1})), + ElementsAre(u"/extra/file/path")))); } } // namespace diff --git a/tests/unit/tests/unittests/model/modelutils-test.cpp b/tests/unit/tests/unittests/model/modelutils-test.cpp index 8d69e69aba8..c7a70cfbdb3 100644 --- a/tests/unit/tests/unittests/model/modelutils-test.cpp +++ b/tests/unit/tests/unittests/model/modelutils-test.cpp @@ -31,11 +31,9 @@ protected: TEST_F(ModelUtils, component_file_path) { - auto typeId = projectStorageMock.createType(moduleId, - "Foo", - QmlDesigner::Storage::TypeTraits::IsFileComponent, - {}, - sourceId); + QmlDesigner::Storage::TypeTraits traits{QmlDesigner::Storage::TypeTraitsKind::Reference}; + traits.isFileComponent = true; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits, {}, sourceId); QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock}; auto path = QmlDesigner::ModelUtils::componentFilePath(pathCacheMock, metaInfo); @@ -64,11 +62,9 @@ TEST_F(ModelUtils, empty_component_file_path_for_invalid_meta_info) TEST_F(ModelUtils, component_file_path_for_node) { - auto typeId = projectStorageMock.createType(moduleId, - "Foo", - QmlDesigner::Storage::TypeTraits::IsFileComponent, - {}, - sourceId); + QmlDesigner::Storage::TypeTraits traits{QmlDesigner::Storage::TypeTraitsKind::Reference}; + traits.isFileComponent = true; + auto typeId = projectStorageMock.createType(moduleId, "Foo", traits, {}, sourceId); projectStorageMock.createImportedTypeNameId(pathCacheMock.sourceId, "Foo", typeId); auto node = model.createModelNode("Foo"); @@ -86,11 +82,9 @@ TEST_F(ModelUtils, component_file_path_for_invalid_node_is_empty) TEST_F(ModelUtils, component_file_path_for_node_without_metainfo_is_empty) { - projectStorageMock.createType(moduleId, - "Foo", - QmlDesigner::Storage::TypeTraits::IsFileComponent, - {}, - sourceId); + QmlDesigner::Storage::TypeTraits traits{QmlDesigner::Storage::TypeTraitsKind::Reference}; + traits.isFileComponent = true; + projectStorageMock.createType(moduleId, "Foo", traits, {}, sourceId); auto node = model.createModelNode("Foo"); auto path = QmlDesigner::ModelUtils::componentFilePath(node); diff --git a/tests/unit/tests/unittests/projectstorage/CMakeLists.txt b/tests/unit/tests/unittests/projectstorage/CMakeLists.txt index 5c3fd4011e2..a2374ae265f 100644 --- a/tests/unit/tests/unittests/projectstorage/CMakeLists.txt +++ b/tests/unit/tests/unittests/projectstorage/CMakeLists.txt @@ -11,6 +11,7 @@ extend_qtc_test(unittest sourcepathcache-test.cpp sourcepathview-test.cpp storagecache-test.cpp + typeannotationreader-test.cpp ) extend_qtc_test(unittest diff --git a/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp b/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp index f6ea7a015a7..4b3f0a18692 100644 --- a/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp +++ b/tests/unit/tests/unittests/projectstorage/projectstorage-test.cpp @@ -4,6 +4,8 @@ #include "../utils/googletest.h" #include +#include +#include #include #include @@ -16,18 +18,21 @@ namespace { +using QmlDesigner::Cache::Source; +using QmlDesigner::Cache::SourceContext; using QmlDesigner::FileStatus; using QmlDesigner::FileStatuses; +using QmlDesigner::FlagIs; using QmlDesigner::ModuleId; using QmlDesigner::PropertyDeclarationId; using QmlDesigner::SourceContextId; using QmlDesigner::SourceId; using QmlDesigner::SourceIds; -using QmlDesigner::TypeId; -using QmlDesigner::Cache::Source; -using QmlDesigner::Cache::SourceContext; -using QmlDesigner::Storage::TypeTraits; using QmlDesigner::Storage::Synchronization::SynchronizationPackage; +using QmlDesigner::Storage::Synchronization::TypeAnnotations; +using QmlDesigner::Storage::TypeTraits; +using QmlDesigner::Storage::TypeTraitsKind; +using QmlDesigner::TypeId; namespace Storage = QmlDesigner::Storage; @@ -264,6 +269,22 @@ MATCHER_P3(IsInfoType, class ProjectStorage : public testing::Test { protected: + static void SetUpTestSuite() + { + static_database = std::make_unique(":memory:", Sqlite::JournalMode::Memory); + + static_projectStorage = std::make_unique>( + *static_database, static_database->isInitialized()); + } + + static void TearDownTestSuite() + { + static_projectStorage.reset(); + static_database.reset(); + } + + ~ProjectStorage() { static_projectStorage->resetForTestsOnly(); } + template static auto toValues(Range &&range) { @@ -295,37 +316,25 @@ protected: package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId1); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId1); package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId2); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId1); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId1); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId2); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId1); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId1); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId2); package.updatedModuleDependencySourceIds.push_back(sourceId1); package.updatedModuleDependencySourceIds.push_back(sourceId2); importsSourceId1.emplace_back(qmlModuleId, Storage::Version{}, sourceId1); importsSourceId1.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId1); - moduleDependenciesSourceId1.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId1); - moduleDependenciesSourceId1.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId1); + moduleDependenciesSourceId1.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId1); + moduleDependenciesSourceId1.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId1); importsSourceId2.emplace_back(qmlModuleId, Storage::Version{}, sourceId2); - moduleDependenciesSourceId2.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId2); + moduleDependenciesSourceId2.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId2); package.types.push_back(Storage::Synchronization::Type{ "QQuickItem", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickItem"}}, @@ -369,14 +378,10 @@ protected: "QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{2}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "Obj", - Storage::Version{2}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{2}}, + Storage::Synchronization::ExportedType{qmlModuleId, "Obj", Storage::Version{2}}, Storage::Synchronization::ExportedType{qmlNativeModuleId, "QObject"}}}); package.updatedSourceIds = {sourceId1, sourceId2}; @@ -389,9 +394,7 @@ protected: SynchronizationPackage package; package.imports.emplace_back(QMLModuleId, Storage::Version{}, sourceId1); - package.moduleDependencies.emplace_back(QMLModuleId, - Storage::Version{}, - sourceId1); + package.moduleDependencies.emplace_back(QMLModuleId, Storage::Version{}, sourceId1); package.updatedModuleDependencySourceIds.push_back(sourceId1); importsSourceId1.emplace_back(QMLModuleId, Storage::Version{}, sourceId1); @@ -401,7 +404,7 @@ protected: Storage::Synchronization::Type{"bool", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLModuleId, "bool"}}}); @@ -409,7 +412,7 @@ protected: Storage::Synchronization::Type{"int", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLModuleId, "int"}}}); @@ -417,23 +420,23 @@ protected: Storage::Synchronization::Type{"uint", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLNativeModuleId, "uint"}}}); - package.types.push_back( - Storage::Synchronization::Type{"double", - Storage::Synchronization::ImportedType{}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Value, - sourceId1, - {Storage::Synchronization::ExportedType{QMLModuleId, - "double"}}}); + package.types.push_back(Storage::Synchronization::Type{ + "double", + Storage::Synchronization::ImportedType{}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Value, + sourceId1, + {Storage::Synchronization::ExportedType{QMLModuleId, "double"}, + Storage::Synchronization::ExportedType{QMLModuleId, "real"}}}); package.types.push_back( Storage::Synchronization::Type{"float", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLNativeModuleId, "float"}}}); @@ -441,7 +444,7 @@ protected: Storage::Synchronization::Type{"date", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLModuleId, "date"}}}); @@ -449,7 +452,7 @@ protected: Storage::Synchronization::Type{"string", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLModuleId, "string"}}}); @@ -457,7 +460,7 @@ protected: Storage::Synchronization::Type{"url", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLModuleId, "url"}}}); @@ -465,7 +468,7 @@ protected: Storage::Synchronization::Type{"var", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Value, + TypeTraitsKind::Value, sourceId1, {Storage::Synchronization::ExportedType{QMLModuleId, "var"}}}); @@ -481,35 +484,23 @@ protected: package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId3); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId3); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId3); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId3); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId3); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId3); package.updatedModuleDependencySourceIds.push_back(sourceId3); package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId4); package.imports.emplace_back(pathToModuleId, Storage::Version{}, sourceId4); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId4); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId4); package.updatedModuleDependencySourceIds.push_back(sourceId4); importsSourceId3.emplace_back(qmlModuleId, Storage::Version{}, sourceId3); importsSourceId3.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId3); - moduleDependenciesSourceId3.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId3); - moduleDependenciesSourceId3.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId3); + moduleDependenciesSourceId3.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId3); + moduleDependenciesSourceId3.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId3); importsSourceId4.emplace_back(qmlModuleId, Storage::Version{}, sourceId4); importsSourceId4.emplace_back(pathToModuleId, Storage::Version{}, sourceId4); - moduleDependenciesSourceId4.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId4); + moduleDependenciesSourceId4.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId4); package.types[1].propertyDeclarations.push_back( Storage::Synchronization::PropertyDeclaration{"objects", @@ -520,7 +511,7 @@ protected: "QAliasItem", Storage::Synchronization::ImportedType{"Item"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "AliasItem"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QAliasItem"}}}); @@ -540,7 +531,7 @@ protected: "QObject2", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId4, {Storage::Synchronization::ExportedType{pathToModuleId, "Object2"}, Storage::Synchronization::ExportedType{pathToModuleId, "Obj2"}}}); @@ -564,38 +555,26 @@ protected: package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId1); package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId2); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId1); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId1); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId2); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId1); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId1); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId2); package.updatedModuleDependencySourceIds.push_back(sourceId1); package.updatedModuleDependencySourceIds.push_back(sourceId2); importsSourceId1.emplace_back(qmlModuleId, Storage::Version{}, sourceId1); importsSourceId1.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId1); - moduleDependenciesSourceId1.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId1); - moduleDependenciesSourceId1.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId1); + moduleDependenciesSourceId1.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId1); + moduleDependenciesSourceId1.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId1); importsSourceId2.emplace_back(qmlModuleId, Storage::Version{}, sourceId2); - moduleDependenciesSourceId2.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId2); + moduleDependenciesSourceId2.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId2); package.types.push_back(Storage::Synchronization::Type{ "QQuickItem", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickItem"}}, @@ -612,57 +591,37 @@ protected: "QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{2}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "Obj", - Storage::Version{2}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{2}}, + Storage::Synchronization::ExportedType{qmlModuleId, "Obj", Storage::Version{2}}, Storage::Synchronization::ExportedType{qmlNativeModuleId, "QObject"}}}); package.updatedSourceIds = {sourceId1, sourceId2}; package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId3); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId3); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId3); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId3); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId3); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId3); package.updatedModuleDependencySourceIds.push_back(sourceId3); package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId4); package.imports.emplace_back(pathToModuleId, Storage::Version{}, sourceId4); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId4); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId4); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId4); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId4); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId4); package.updatedModuleDependencySourceIds.push_back(sourceId4); importsSourceId3.emplace_back(qmlModuleId, Storage::Version{}, sourceId3); importsSourceId3.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId3); - moduleDependenciesSourceId3.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId3); - moduleDependenciesSourceId3.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId3); + moduleDependenciesSourceId3.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId3); + moduleDependenciesSourceId3.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId3); importsSourceId4.emplace_back(qmlModuleId, Storage::Version{}, sourceId4); importsSourceId4.emplace_back(pathToModuleId, Storage::Version{}, sourceId4); importsSourceId4.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId4); - moduleDependenciesSourceId4.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId4); - moduleDependenciesSourceId4.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId4); + moduleDependenciesSourceId4.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId4); + moduleDependenciesSourceId4.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId4); package.types[1].propertyDeclarations.push_back( Storage::Synchronization::PropertyDeclaration{"objects", @@ -673,7 +632,7 @@ protected: "QAliasItem", Storage::Synchronization::ImportedType{"Item"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "AliasItem"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QAliasItem"}}}); @@ -688,7 +647,7 @@ protected: "QObject2", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId4, {Storage::Synchronization::ExportedType{pathToModuleId, "Object2"}, Storage::Synchronization::ExportedType{pathToModuleId, "Obj2"}}}); @@ -704,11 +663,9 @@ protected: "QChildren", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId5, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Children", - Storage::Version{2}}, + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Children", Storage::Version{2}}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QChildren"}}, {Storage::Synchronization::PropertyDeclaration{"items", Storage::Synchronization::ImportedType{ @@ -722,20 +679,12 @@ protected: package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId5); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId5); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId5); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId5); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId5); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId5); importsSourceId5.emplace_back(qmlModuleId, Storage::Version{}, sourceId5); importsSourceId5.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId5); - moduleDependenciesSourceId5.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId5); - moduleDependenciesSourceId5.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId5); + moduleDependenciesSourceId5.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId5); + moduleDependenciesSourceId5.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId5); package.updatedModuleDependencySourceIds.push_back(sourceId5); package.updatedSourceIds.push_back(sourceId5); @@ -743,11 +692,9 @@ protected: "QChildren2", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId6, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Children2", - Storage::Version{2}}, + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Children2", Storage::Version{2}}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QChildren2"}}, {Storage::Synchronization::PropertyDeclaration{"items", Storage::Synchronization::ImportedType{ @@ -762,12 +709,8 @@ protected: package.imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId6); package.imports.emplace_back(pathToModuleId, Storage::Version{}, sourceId6); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId6); - package.moduleDependencies.emplace_back(qmlNativeModuleId, - Storage::Version{}, - sourceId6); - package.moduleDependencies.emplace_back(qtQuickNativeModuleId, - Storage::Version{}, - sourceId6); + package.moduleDependencies.emplace_back(qmlNativeModuleId, Storage::Version{}, sourceId6); + package.moduleDependencies.emplace_back(qtQuickNativeModuleId, Storage::Version{}, sourceId6); package.updatedModuleDependencySourceIds.push_back(sourceId6); package.updatedSourceIds.push_back(sourceId6); @@ -796,7 +739,7 @@ protected: "QAliasItem2", Storage::Synchronization::ImportedType{"Object"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId5, {Storage::Synchronization::ExportedType{qtQuickModuleId, "AliasItem2"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QAliasItem2"}}}); @@ -827,57 +770,39 @@ protected: "QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{1}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "Obj", - Storage::Version{1, 2}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{1}}, + Storage::Synchronization::ExportedType{qmlModuleId, "Obj", Storage::Version{1, 2}}, Storage::Synchronization::ExportedType{qmlModuleId, "BuiltInObj"}, Storage::Synchronization::ExportedType{qmlNativeModuleId, "QObject"}}}); package.types.push_back(Storage::Synchronization::Type{ "QObject2", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{2, 0}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "Obj", - Storage::Version{2, 3}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{2, 0}}, + Storage::Synchronization::ExportedType{qmlModuleId, "Obj", Storage::Version{2, 3}}, Storage::Synchronization::ExportedType{qmlNativeModuleId, "QObject2"}}}); package.types.push_back(Storage::Synchronization::Type{ "QObject3", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{2, 11}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "Obj", - Storage::Version{2, 11}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{2, 11}}, + Storage::Synchronization::ExportedType{qmlModuleId, "Obj", Storage::Version{2, 11}}, Storage::Synchronization::ExportedType{qmlNativeModuleId, "QObject3"}}}); package.types.push_back(Storage::Synchronization::Type{ "QObject4", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{3, 4}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "Obj", - Storage::Version{3, 4}}, - Storage::Synchronization::ExportedType{qmlModuleId, - "BuiltInObj", - Storage::Version{3, 4}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{3, 4}}, + Storage::Synchronization::ExportedType{qmlModuleId, "Obj", Storage::Version{3, 4}}, + Storage::Synchronization::ExportedType{qmlModuleId, "BuiltInObj", Storage::Version{3, 4}}, Storage::Synchronization::ExportedType{qmlNativeModuleId, "QObject4"}}}); package.updatedSourceIds.push_back(sourceId1); @@ -897,11 +822,9 @@ protected: "QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{}}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{}}}, {Storage::Synchronization::PropertyDeclaration{"data", Storage::Synchronization::ImportedType{"Object"}, Storage::PropertyDeclarationTraits::IsList}, @@ -916,11 +839,9 @@ protected: "QObject2", Storage::Synchronization::ImportedType{"Object"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object2", - Storage::Version{}}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object2", Storage::Version{}}}, {Storage::Synchronization::PropertyDeclaration{ "data2", Storage::Synchronization::ImportedType{"Object3"}, @@ -936,11 +857,9 @@ protected: "QObject3", Storage::Synchronization::ImportedType{"Object2"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object3", - Storage::Version{}}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object3", Storage::Version{}}}, {Storage::Synchronization::PropertyDeclaration{"data3", Storage::Synchronization::ImportedType{ "Object2"}, @@ -960,6 +879,34 @@ protected: return package; } + auto createHeirPackage() + { + auto package = createPackageWithProperties(); + + package.types.push_back( + Storage::Synchronization::Type{"QObject4", + Storage::Synchronization::ImportedType{}, + Storage::Synchronization::ImportedType{"Object2"}, + TypeTraitsKind::Reference, + sourceId1, + {}, + {}, + {}, + {}}); + package.types.push_back( + Storage::Synchronization::Type{"QObject5", + Storage::Synchronization::ImportedType{}, + Storage::Synchronization::ImportedType{"Object2"}, + TypeTraitsKind::Reference, + sourceId1, + {}, + {}, + {}, + {}}); + + return package; + } + auto createModuleExportedImportSynchronizationPackage() { SynchronizationPackage package; @@ -970,11 +917,9 @@ protected: "QQuickItem", Storage::Synchronization::ImportedType{"Object"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{1, 0}}}}); + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{1, 0}}}}); package.updatedModuleIds.push_back(qmlModuleId); package.moduleExportedImports.emplace_back(qtQuickModuleId, @@ -985,11 +930,9 @@ protected: "QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{1, 0}}}}); + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{1, 0}}}}); package.imports.emplace_back(qtQuickModuleId, Storage::Version{1}, sourceId3); package.moduleExportedImports.emplace_back(qtQuick3DModuleId, @@ -997,26 +940,24 @@ protected: Storage::Version{}, Storage::Synchronization::IsAutoVersion::Yes); package.updatedModuleIds.push_back(qtQuick3DModuleId); - package.types.push_back(Storage::Synchronization::Type{ - "QQuickItem3d", - Storage::Synchronization::ImportedType{"Item"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId3, - {Storage::Synchronization::ExportedType{qtQuick3DModuleId, - "Item3D", - Storage::Version{1, 0}}}}); + package.types.push_back( + Storage::Synchronization::Type{"QQuickItem3d", + Storage::Synchronization::ImportedType{"Item"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId3, + {Storage::Synchronization::ExportedType{ + qtQuick3DModuleId, "Item3D", Storage::Version{1, 0}}}}); package.imports.emplace_back(qtQuick3DModuleId, Storage::Version{1}, sourceId4); - package.types.push_back(Storage::Synchronization::Type{ - "MyItem", - Storage::Synchronization::ImportedType{"Object"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId4, - {Storage::Synchronization::ExportedType{myModuleModuleId, - "MyItem", - Storage::Version{1, 0}}}}); + package.types.push_back( + Storage::Synchronization::Type{"MyItem", + Storage::Synchronization::ImportedType{"Object"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId4, + {Storage::Synchronization::ExportedType{ + myModuleModuleId, "MyItem", Storage::Version{1, 0}}}}); package.updatedSourceIds = {sourceId1, sourceId2, sourceId3, sourceId4}; @@ -1032,14 +973,14 @@ protected: "QQuickItem", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{1, 0}}}}); package.types.push_back( Storage::Synchronization::Type{"QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, {Storage::Synchronization::ExportedType{ qtQuickModuleId, "QtObject", Storage::Version{1, 0}}}}); @@ -1048,7 +989,7 @@ protected: Storage::Synchronization::Type{"QQuickItem3d", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{ qtQuickModuleId, "Item3D", Storage::Version{1, 0}}}}); @@ -1065,6 +1006,58 @@ protected: return package; } + auto createTypeAnnotions() const + { + TypeAnnotations annotations; + + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeContainer = FlagIs::True; + traits.visibleInLibrary = FlagIs::True; + + annotations.emplace_back(sourceId4, + "Object", + qmlModuleId, + "/path/to/icon.png", + traits, + R"xy({"canBeContainer": "true", "hints": "false"})xy", + R"xy([{"name":"Foo", + "iconPath":"/path/icon", + "category":"Basic Items", + "import":"QtQuick", + "toolTip":"Foo is a Item", + "templatePath":"/path/templates/item.qml", + "properties":[["x", "double", 32.1],["y", "double", 12.3]], + "extraFilePaths":["/path/templates/frame.png", "/path/templates/frame.frag"]}, + {"name":"Bar", + "iconPath":"/path/icon2", + "category":"Basic Items", + "import":"QtQuick", + "toolTip":"Bar is a Item", + "properties":[["color", "color", "#blue"]]}])xy"); + + annotations.emplace_back(sourceId5, + "Item", + qtQuickModuleId, + "/path/to/quick.png", + traits, + R"xy({"canBeContainer": "true", "forceClip": "false"})xy", + R"xy([{"name":"Item", + "iconPath":"/path/icon3", + "category":"Advanced Items", + "import":"QtQuick", + "toolTip":"Item is an Object", + "properties":[["x", "double", 1], ["y", "double", 2]]}])xy"); + + return annotations; + } + + static auto createUpdatedTypeAnnotionSourceIds(const TypeAnnotations &annotations) + { + return Utils::transform(annotations, [](const auto &annotation) { + return annotation.sourceId; + }); + } + template static FileStatuses convert(const Range &range) { @@ -1116,9 +1109,11 @@ protected: } protected: - Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; + inline static std::unique_ptr static_database; + Sqlite::Database &database = *static_database; //Sqlite::Database database{"/tmp/aaaaa.db", Sqlite::JournalMode::Wal}; - QmlDesigner::ProjectStorage storage{database, database.isInitialized()}; + inline static std::unique_ptr> static_projectStorage; + QmlDesigner::ProjectStorage &storage = *static_projectStorage; QmlDesigner::SourcePathCache> sourcePathCache{ storage}; QmlDesigner::SourcePathView path1{"/path1/to"}; @@ -1370,7 +1365,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1378,7 +1373,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1394,7 +1389,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_extension_chain) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1403,7 +1398,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_extension_chain) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1420,7 +1415,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_exported_prototype_ ASSERT_THAT( storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1429,7 +1424,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_exported_prototype_ "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, "QQuickItem")))))); @@ -1445,7 +1440,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_exported_extension_ ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1454,7 +1449,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_exported_extension_ "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1484,7 +1479,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_with_missing_module) "QObject2", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{ModuleId::create(22), "Object2"}, Storage::Synchronization::ExportedType{pathToModuleId, "Obj2"}}}); @@ -1501,7 +1496,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_reverse_order) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1509,7 +1504,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_new_types_reverse_order) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1520,23 +1515,26 @@ TEST_F(ProjectStorage, synchronize_types_overwrites_type_traits) { auto package{createSimpleSynchronizationPackage()}; storage.synchronize(package); - package.types[0].traits = TypeTraits::Value; - package.types[1].traits = TypeTraits::Value; + package.types[0].traits = TypeTraitsKind::Value; + package.types[1].traits = TypeTraitsKind::Value; storage.synchronize(SynchronizationPackage{package.imports, package.types, {sourceId1, sourceId2}}); - ASSERT_THAT( - storage.fetchTypes(), - UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Value), - Field(&Storage::Synchronization::Type::exportedTypes, - UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), - IsExportedType(qmlModuleId, "Obj"), - IsExportedType(qmlNativeModuleId, "QObject")))), - AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Value), - Field(&Storage::Synchronization::Type::exportedTypes, - UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), - IsExportedType(qtQuickNativeModuleId, "QQuickItem")))))); + ASSERT_THAT(storage.fetchTypes(), + UnorderedElementsAre( + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Value), + Field(&Storage::Synchronization::Type::exportedTypes, + UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), + IsExportedType(qmlModuleId, "Obj"), + IsExportedType(qmlNativeModuleId, "QObject")))), + AllOf(IsStorageType(sourceId1, + "QQuickItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Value), + Field(&Storage::Synchronization::Type::exportedTypes, + UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), + IsExportedType(qtQuickNativeModuleId, + "QQuickItem")))))); } TEST_F(ProjectStorage, synchronize_types_overwrites_sources) @@ -1559,7 +1557,7 @@ TEST_F(ProjectStorage, synchronize_types_overwrites_sources) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId4, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId4, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1567,7 +1565,7 @@ TEST_F(ProjectStorage, synchronize_types_overwrites_sources) AllOf(IsStorageType(sourceId3, "QQuickItem", fetchTypeId(sourceId4, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1583,7 +1581,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_prototype_chain) "QQuickObject", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickObject"}}}); @@ -1594,7 +1592,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_prototype_chain) ASSERT_THAT( storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1603,7 +1601,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_prototype_chain) "QQuickObject", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Object"), IsExportedType(qtQuickNativeModuleId, "QQuickObject")))), @@ -1611,7 +1609,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_prototype_chain) "QQuickItem", fetchTypeId(sourceId1, "QQuickObject"), TypeId{}, - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, "QQuickItem")))))); @@ -1627,7 +1625,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_extension_chain) "QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{"QObject"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickObject"}}}); @@ -1638,7 +1636,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_extension_chain) ASSERT_THAT( storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1647,7 +1645,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_extension_chain) "QQuickObject", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Object"), IsExportedType(qtQuickNativeModuleId, "QQuickObject")))), @@ -1655,7 +1653,7 @@ TEST_F(ProjectStorage, synchronize_types_insert_type_into_extension_chain) "QQuickItem", TypeId{}, fetchTypeId(sourceId1, "QQuickObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, "QQuickItem")))))); @@ -1670,7 +1668,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_prototype) "QQuickObject", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickObject"}}}); @@ -1680,7 +1678,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_prototype) ASSERT_THAT( storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1689,7 +1687,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_prototype) "QQuickObject", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Object"), IsExportedType(qtQuickNativeModuleId, "QQuickObject")))), @@ -1697,7 +1695,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_prototype) "QQuickItem", fetchTypeId(sourceId1, "QQuickObject"), TypeId{}, - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, "QQuickItem")))))); @@ -1713,7 +1711,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_extension) "QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{"QObject"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickObject"}}}); @@ -1723,7 +1721,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_extension) ASSERT_THAT( storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1732,7 +1730,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_extension) "QQuickObject", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Object"), IsExportedType(qtQuickNativeModuleId, "QQuickObject")))), @@ -1740,7 +1738,7 @@ TEST_F(ProjectStorage, synchronize_types_add_qualified_extension) "QQuickItem", TypeId{}, fetchTypeId(sourceId1, "QQuickObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, "QQuickItem")))))); @@ -1753,7 +1751,7 @@ TEST_F(ProjectStorage, synchronize_types_throws_for_missing_prototype) "QQuickItem", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickItem"}}}}; @@ -1768,7 +1766,7 @@ TEST_F(ProjectStorage, synchronize_types_throws_for_missing_extension) "QQuickItem", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{"QObject"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item"}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickItem"}}}}; @@ -1783,7 +1781,7 @@ TEST_F(ProjectStorage, synchronize_types_throws_for_invalid_module) Storage::Synchronization::Type{"QQuickItem", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{ModuleId{}, "Item"}}}}; @@ -1797,7 +1795,7 @@ TEST_F(ProjectStorage, type_with_invalid_source_id_throws) Storage::Synchronization::Type{"QQuickItem", Storage::Synchronization::ImportedType{""}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, SourceId{}, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item"}}}}; @@ -1815,7 +1813,7 @@ TEST_F(ProjectStorage, delete_type_if_source_id_is_synchronized) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1831,7 +1829,7 @@ TEST_F(ProjectStorage, dont_delete_type_if_source_id_is_not_synchronized) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1839,7 +1837,7 @@ TEST_F(ProjectStorage, dont_delete_type_if_source_id_is_not_synchronized) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1856,7 +1854,7 @@ TEST_F(ProjectStorage, update_exported_types_if_type_name_changes) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -1864,7 +1862,7 @@ TEST_F(ProjectStorage, update_exported_types_if_type_name_changes) AllOf(IsStorageType(sourceId1, "QQuickItem2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -1900,19 +1898,22 @@ TEST_F(ProjectStorage, synchronize_types_add_property_declarations) storage.synchronize(package); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("children", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId1, + "QQuickItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "children", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_add_property_declarations_with_missing_imports) @@ -1932,26 +1933,29 @@ TEST_F(ProjectStorage, synchronize_types_add_property_declaration_qualified_type Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{"QObject"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); storage.synchronize(package); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("data", - fetchTypeId(sourceId1, "QQuickObject"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("children", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId1, + "QQuickItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("data", + fetchTypeId(sourceId1, "QQuickObject"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "children", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_changes_property_declaration_type) @@ -1963,19 +1967,22 @@ TEST_F(ProjectStorage, synchronize_types_changes_property_declaration_type) storage.synchronize(SynchronizationPackage{importsSourceId1, {package.types[0]}, {sourceId1}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("data", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("children", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId1, + "QQuickItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("data", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "children", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_changes_declaration_traits) @@ -1989,7 +1996,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_declaration_traits) ASSERT_THAT( storage.fetchTypes(), Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), + IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("data", @@ -2014,7 +2021,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_declaration_traits_and_type) ASSERT_THAT( storage.fetchTypes(), Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), + IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("data", @@ -2038,7 +2045,7 @@ TEST_F(ProjectStorage, synchronize_types_removes_a_property_declaration) Contains(AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre(IsPropertyDeclaration( "data", @@ -2061,7 +2068,7 @@ TEST_F(ProjectStorage, synchronize_types_adds_a_property_declaration) ASSERT_THAT( storage.fetchTypes(), Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), + IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("object", @@ -2084,19 +2091,22 @@ TEST_F(ProjectStorage, synchronize_types_rename_a_property_declaration) storage.synchronize(SynchronizationPackage{importsSourceId1, {package.types[0]}, {sourceId1}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId1, + "QQuickItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, using_non_existing_property_type_throws) @@ -2154,7 +2164,7 @@ TEST_F(ProjectStorage, synchronize_types_add_function_declarations) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2173,7 +2183,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_return_typ AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2192,7 +2202,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_name) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2211,7 +2221,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_pop_parame AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2231,7 +2241,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_append_par AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2250,7 +2260,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_change_par AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2269,7 +2279,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_change_par AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2289,7 +2299,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_function_declaration_change_par AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2308,7 +2318,7 @@ TEST_F(ProjectStorage, synchronize_types_removes_function_declaration) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0])))))); } @@ -2327,7 +2337,7 @@ TEST_F(ProjectStorage, synchronize_types_add_function_declaration) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1]), @@ -2347,7 +2357,7 @@ TEST_F(ProjectStorage, synchronize_types_add_function_declarations_with_overload AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1]), @@ -2368,7 +2378,7 @@ TEST_F(ProjectStorage, synchronize_types_function_declarations_adding_overload) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1]), @@ -2390,7 +2400,7 @@ TEST_F(ProjectStorage, synchronize_types_function_declarations_removing_overload AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::functionDeclarations, UnorderedElementsAre(Eq(package.types[0].functionDeclarations[0]), Eq(package.types[0].functionDeclarations[1])))))); @@ -2407,7 +2417,7 @@ TEST_F(ProjectStorage, synchronize_types_add_signal_declarations) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2426,7 +2436,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_signal_declaration_name) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2445,7 +2455,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_signal_declaration_pop_paramete AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2465,7 +2475,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_signal_declaration_append_param AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2484,7 +2494,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_signal_declaration_change_param AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2503,7 +2513,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_signal_declaration_change_param AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2522,7 +2532,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_signal_declaration_change_param AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2541,7 +2551,7 @@ TEST_F(ProjectStorage, synchronize_types_removes_signal_declaration) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0])))))); } @@ -2560,7 +2570,7 @@ TEST_F(ProjectStorage, synchronize_types_add_signal_declaration) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1]), @@ -2580,7 +2590,7 @@ TEST_F(ProjectStorage, synchronize_types_add_signal_declarations_with_overloads) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1]), @@ -2601,7 +2611,7 @@ TEST_F(ProjectStorage, synchronize_types_signal_declarations_adding_overload) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1]), @@ -2623,7 +2633,7 @@ TEST_F(ProjectStorage, synchronize_types_signal_declarations_removing_overload) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::signalDeclarations, UnorderedElementsAre(Eq(package.types[0].signalDeclarations[0]), Eq(package.types[0].signalDeclarations[1])))))); @@ -2640,7 +2650,7 @@ TEST_F(ProjectStorage, synchronize_types_add_enumeration_declarations) IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); @@ -2659,7 +2669,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_name) IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); @@ -2678,7 +2688,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_pop_enu IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); @@ -2698,13 +2708,14 @@ TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_append_ IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_change_enumerator_declaration_name) +TEST_F(ProjectStorage, + synchronize_types_changes_enumeration_declaration_change_enumerator_declaration_name) { auto package{createSimpleSynchronizationPackage()}; storage.synchronize(package); @@ -2717,13 +2728,14 @@ TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_change_ IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_change_enumerator_declaration_value) +TEST_F(ProjectStorage, + synchronize_types_changes_enumeration_declaration_change_enumerator_declaration_value) { auto package{createSimpleSynchronizationPackage()}; storage.synchronize(package); @@ -2736,7 +2748,7 @@ TEST_F(ProjectStorage, synchronize_types_changes_enumeration_declaration_change_ IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); @@ -2757,7 +2769,7 @@ TEST_F(ProjectStorage, IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); @@ -2777,7 +2789,7 @@ TEST_F(ProjectStorage, IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1])))))); @@ -2795,7 +2807,7 @@ TEST_F(ProjectStorage, synchronize_types_removes_enumeration_declaration) Contains(AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre( Eq(package.types[0].enumerationDeclarations[0])))))); @@ -2815,7 +2827,7 @@ TEST_F(ProjectStorage, synchronize_types_add_enumeration_declaration) IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::enumerationDeclarations, UnorderedElementsAre(Eq(package.types[0].enumerationDeclarations[0]), Eq(package.types[0].enumerationDeclarations[1]), @@ -2895,7 +2907,7 @@ TEST_F(ProjectStorage, synchronize_types_add_alias_declarations) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -2922,7 +2934,7 @@ TEST_F(ProjectStorage, synchronize_types_add_alias_declarations_again) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -2950,7 +2962,7 @@ TEST_F(ProjectStorage, synchronize_types_remove_alias_declarations) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -2975,6 +2987,7 @@ TEST_F(ProjectStorage, synchronize_types_add_alias_declarations_throws_for_wrong {sourceId4}}), QmlDesigner::TypeNameDoesNotExists); } + TEST_F(ProjectStorage, synchronize_types_add_alias_declarations_throws_for_wrong_property_name) { auto package{createSynchronizationPackageWithAliases()}; @@ -3003,7 +3016,7 @@ TEST_F(ProjectStorage, synchronize_types_change_alias_declarations_type_name) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3028,21 +3041,24 @@ TEST_F(ProjectStorage, synchronize_types_change_alias_declarations_property_name ASSERT_THAT( storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, synchronize_types_change_alias_declarations_to_property_declaration) @@ -3059,21 +3075,24 @@ TEST_F(ProjectStorage, synchronize_types_change_alias_declarations_to_property_d ASSERT_THAT( storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, synchronize_types_change_property_declarations_to_alias_declaration) @@ -3094,7 +3113,7 @@ TEST_F(ProjectStorage, synchronize_types_change_property_declarations_to_alias_d IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3120,21 +3139,24 @@ TEST_F(ProjectStorage, synchronize_types_change_alias_target_property_declaratio ASSERT_THAT( storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("objects", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, synchronize_types_change_alias_target_property_declaration_type_name) @@ -3152,7 +3174,7 @@ TEST_F(ProjectStorage, synchronize_types_change_alias_target_property_declaratio IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3194,7 +3216,7 @@ TEST_F(ProjectStorage, synchronize_types_remove_property_declaration_and_alias) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3236,7 +3258,7 @@ TEST_F(ProjectStorage, synchronize_types_remove_type_and_alias_property_declarat IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3261,21 +3283,24 @@ TEST_F(ProjectStorage, update_alias_property_if_property_is_overloaded) ASSERT_THAT( storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, alias_property_is_overloaded) @@ -3290,21 +3315,24 @@ TEST_F(ProjectStorage, alias_property_is_overloaded) ASSERT_THAT( storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, update_alias_property_if_overloaded_property_is_removed) @@ -3324,7 +3352,7 @@ TEST_F(ProjectStorage, update_alias_property_if_overloaded_property_is_removed) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3356,7 +3384,7 @@ TEST_F(ProjectStorage, relink_alias_property) IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3397,7 +3425,7 @@ TEST_F(ProjectStorage, "QObject2", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId5, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object2"}, Storage::Synchronization::ExportedType{qtQuickModuleId, "Obj2"}}}); @@ -3410,7 +3438,7 @@ TEST_F(ProjectStorage, IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -3435,22 +3463,24 @@ TEST_F(ProjectStorage, relink_alias_property_react_to_type_name_change) storage.synchronize(SynchronizationPackage{importsSourceId1, {package.types[0]}, {sourceId1}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem2"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains(AllOf( + IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem2"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly), + IsPropertyDeclaration("objects", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration("data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, do_not_relink_alias_property_for_deleted_type) @@ -3470,7 +3500,7 @@ TEST_F(ProjectStorage, do_not_relink_alias_property_for_deleted_type) Not(Contains(IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference)))); + TypeTraitsKind::Reference)))); } TEST_F(ProjectStorage, do_not_relink_alias_property_for_deleted_type_and_property_type) @@ -3516,7 +3546,7 @@ TEST_F(ProjectStorage, do_not_relink_alias_property_for_deleted_type_and_propert Not(Contains(IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference)))); + TypeTraitsKind::Reference)))); } TEST_F(ProjectStorage, do_not_relink_property_type_does_not_exists) @@ -3557,7 +3587,7 @@ TEST_F(ProjectStorage, change_prototype_type_name) "QQuickItem", fetchTypeId(sourceId2, "QObject3"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_extension_type_name) @@ -3574,7 +3604,7 @@ TEST_F(ProjectStorage, change_extension_type_name) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject3"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_prototype_type_module_id) @@ -3590,7 +3620,7 @@ TEST_F(ProjectStorage, change_prototype_type_module_id) "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_extension_type_module_id) @@ -3607,7 +3637,7 @@ TEST_F(ProjectStorage, change_extension_type_module_id) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_qualified_prototype_type_module_id_throws) @@ -3656,7 +3686,7 @@ TEST_F(ProjectStorage, change_qualified_prototype_type_module_id) "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_qualified_extension_type_module_id) @@ -3679,7 +3709,7 @@ TEST_F(ProjectStorage, change_qualified_extension_type_module_id) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_prototype_type_name_and_module_id) @@ -3702,7 +3732,7 @@ TEST_F(ProjectStorage, change_prototype_type_name_and_module_id) "QQuickItem", fetchTypeId(sourceId2, "QObject3"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_extension_type_name_and_module_id) @@ -3726,7 +3756,7 @@ TEST_F(ProjectStorage, change_extension_type_name_and_module_id) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject3"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, change_prototype_type_name_throws_for_wrong_native_prototupe_type_name) @@ -3766,7 +3796,7 @@ TEST_F(ProjectStorage, throw_for_prototype_chain_cycles) "QObject2", Storage::Synchronization::ImportedType{"Item"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{pathToModuleId, "Object2"}, Storage::Synchronization::ExportedType{pathToModuleId, "Obj2"}}}); @@ -3791,7 +3821,7 @@ TEST_F(ProjectStorage, throw_for_extension_chain_cycles) "QObject2", Storage::Synchronization::ImportedType{"Item"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{pathToModuleId, "Object2"}, Storage::Synchronization::ExportedType{pathToModuleId, "Obj2"}}}); @@ -3861,7 +3891,7 @@ TEST_F(ProjectStorage, recursive_aliases) Contains(AllOf(IsStorageType(sourceId5, "QAliasItem2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, ElementsAre(IsPropertyDeclaration( "objects", @@ -3883,7 +3913,7 @@ TEST_F(ProjectStorage, recursive_aliases_change_property_type) Contains(AllOf(IsStorageType(sourceId5, "QAliasItem2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, ElementsAre(IsPropertyDeclaration( "objects", @@ -3906,7 +3936,7 @@ TEST_F(ProjectStorage, update_aliases_after_injecting_property) Contains(AllOf(IsStorageType(sourceId5, "QAliasItem2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, ElementsAre(IsPropertyDeclaration( "objects", @@ -3931,7 +3961,7 @@ TEST_F(ProjectStorage, update_aliases_after_change_alias_to_property) AllOf(Contains(AllOf(IsStorageType(sourceId5, "QAliasItem2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, ElementsAre(IsPropertyDeclaration( "objects", @@ -3942,7 +3972,7 @@ TEST_F(ProjectStorage, update_aliases_after_change_alias_to_property) Contains(AllOf(IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, ElementsAre(IsPropertyDeclaration( "objects", @@ -3969,7 +3999,7 @@ TEST_F(ProjectStorage, update_aliases_after_change_property_to_alias) Contains(AllOf(IsStorageType(sourceId5, "QAliasItem2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, ElementsAre(IsPropertyDeclaration( "objects", @@ -4013,7 +4043,7 @@ TEST_F(ProjectStorage, qualified_prototype) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4027,7 +4057,7 @@ TEST_F(ProjectStorage, qualified_prototype) "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_extension) @@ -4040,7 +4070,7 @@ TEST_F(ProjectStorage, qualified_extension) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4054,7 +4084,7 @@ TEST_F(ProjectStorage, qualified_extension) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_prototype_upper_down_the_module_chain_throws) @@ -4085,7 +4115,7 @@ TEST_F(ProjectStorage, qualified_prototype_upper_in_the_module_chain) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4099,7 +4129,7 @@ TEST_F(ProjectStorage, qualified_prototype_upper_in_the_module_chain) "QQuickItem", fetchTypeId(sourceId3, "QQuickObject"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_extension_upper_in_the_module_chain) @@ -4112,7 +4142,7 @@ TEST_F(ProjectStorage, qualified_extension_upper_in_the_module_chain) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4126,7 +4156,7 @@ TEST_F(ProjectStorage, qualified_extension_upper_in_the_module_chain) "QQuickItem", TypeId{}, fetchTypeId(sourceId3, "QQuickObject"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_prototype_with_wrong_version_throws) @@ -4138,7 +4168,7 @@ TEST_F(ProjectStorage, qualified_prototype_with_wrong_version_throws) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4158,7 +4188,7 @@ TEST_F(ProjectStorage, qualified_extension_with_wrong_version_throws) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4178,7 +4208,7 @@ TEST_F(ProjectStorage, qualified_prototype_with_version) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4192,7 +4222,7 @@ TEST_F(ProjectStorage, qualified_prototype_with_version) "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_extension_with_version) @@ -4206,7 +4236,7 @@ TEST_F(ProjectStorage, qualified_extension_with_version) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4220,7 +4250,7 @@ TEST_F(ProjectStorage, qualified_extension_with_version) "QQuickItem", TypeId{}, fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_prototype_with_version_in_the_proto_type_chain) @@ -4234,11 +4264,9 @@ TEST_F(ProjectStorage, qualified_prototype_with_version_in_the_proto_type_chain) "QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Object", - Storage::Version{2}}}}); + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object", Storage::Version{2}}}}); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId3); package.updatedSourceIds.push_back(sourceId3); @@ -4249,7 +4277,7 @@ TEST_F(ProjectStorage, qualified_prototype_with_version_in_the_proto_type_chain) "QQuickItem", fetchTypeId(sourceId3, "QQuickObject"), TypeId{}, - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_extension_with_version_in_the_proto_type_chain) @@ -4264,11 +4292,9 @@ TEST_F(ProjectStorage, qualified_extension_with_version_in_the_proto_type_chain) "QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Object", - Storage::Version{2}}}}); + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object", Storage::Version{2}}}}); package.imports.emplace_back(qtQuickModuleId, Storage::Version{}, sourceId3); package.updatedSourceIds.push_back(sourceId3); @@ -4279,7 +4305,7 @@ TEST_F(ProjectStorage, qualified_extension_with_version_in_the_proto_type_chain) "QQuickItem", TypeId{}, fetchTypeId(sourceId3, "QQuickObject"), - TypeTraits::Reference))); + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, qualified_prototype_with_version_down_the_proto_type_chain_throws) @@ -4310,7 +4336,7 @@ TEST_F(ProjectStorage, qualified_property_declaration_type_name) Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4345,7 +4371,7 @@ TEST_F(ProjectStorage, qualified_property_declaration_type_name_in_the_module_ch Storage::Synchronization::Type{"QQuickObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId3, {Storage::Synchronization::ExportedType{qtQuickModuleId, "Object"}}}); @@ -4405,14 +4431,16 @@ TEST_F(ProjectStorage, change_property_type_module_id_with_qualified_type) storage.synchronize(package); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - Contains(IsPropertyDeclaration("data", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains(AllOf(IsStorageType(sourceId1, + "QQuickItem", + fetchTypeId(sourceId2, "QObject"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + Contains(IsPropertyDeclaration( + "data", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList)))))); } TEST_F(ProjectStorage, add_file_statuses) @@ -4504,7 +4532,7 @@ TEST_F(ProjectStorage, synchronize_types_without_type_name) Contains(AllOf(IsStorageType(sourceId4, "QObject2", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Object2"), IsExportedType("Obj2")))))); @@ -4514,22 +4542,23 @@ TEST_F(ProjectStorage, fetch_by_major_version_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Object"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Object"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{1}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_by_major_version_for_qualified_imported_type) @@ -4541,39 +4570,40 @@ TEST_F(ProjectStorage, fetch_by_major_version_for_qualified_imported_type) "Item", Storage::Synchronization::QualifiedImportedType{"Object", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_by_major_version_and_minor_version_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{1, 2}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_by_major_version_and_minor_version_for_qualified_imported_type) @@ -4585,17 +4615,17 @@ TEST_F(ProjectStorage, fetch_by_major_version_and_minor_version_for_qualified_im "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, @@ -4603,15 +4633,14 @@ TEST_F(ProjectStorage, { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Object"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Object"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{1, 1}, sourceId2}; ASSERT_THROW(storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}), @@ -4628,11 +4657,9 @@ TEST_F(ProjectStorage, "Item", Storage::Synchronization::QualifiedImportedType{"Object", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; ASSERT_THROW(storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}), QmlDesigner::TypeNameDoesNotExists); @@ -4642,15 +4669,14 @@ TEST_F(ProjectStorage, fetch_low_minor_version_for_imported_type_throws) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{1, 1}, sourceId2}; ASSERT_THROW(storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}), @@ -4666,11 +4692,9 @@ TEST_F(ProjectStorage, fetch_low_minor_version_for_qualified_imported_type_throw "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; ASSERT_THROW(storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}), QmlDesigner::TypeNameDoesNotExists); @@ -4680,22 +4704,23 @@ TEST_F(ProjectStorage, fetch_higher_minor_version_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{1, 3}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_higher_minor_version_for_qualified_imported_type) @@ -4707,32 +4732,31 @@ TEST_F(ProjectStorage, fetch_higher_minor_version_for_qualified_imported_type) "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_different_major_version_for_imported_type_throws) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{3, 1}, sourceId2}; ASSERT_THROW(storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}), @@ -4748,11 +4772,9 @@ TEST_F(ProjectStorage, fetch_different_major_version_for_qualified_imported_type "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; ASSERT_THROW(storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}), QmlDesigner::TypeNameDoesNotExists); @@ -4762,22 +4784,23 @@ TEST_F(ProjectStorage, fetch_other_type_by_different_version_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{2, 3}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject2"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject2"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_other_type_by_different_version_for_qualified_imported_type) @@ -4789,39 +4812,40 @@ TEST_F(ProjectStorage, fetch_other_type_by_different_version_for_qualified_impor "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject2"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject2"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_highest_version_for_import_without_version_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject4"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject4"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_highest_version_for_import_without_version_for_qualified_imported_type) @@ -4833,39 +4857,40 @@ TEST_F(ProjectStorage, fetch_highest_version_for_import_without_version_for_qual "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject4"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject4"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_highest_version_for_import_with_major_version_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"Obj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"Obj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{2}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject3"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject3"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_highest_version_for_import_with_major_version_for_qualified_imported_type) @@ -4877,39 +4902,40 @@ TEST_F(ProjectStorage, fetch_highest_version_for_import_with_major_version_for_q "Item", Storage::Synchronization::QualifiedImportedType{"Obj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject3"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject3"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_exported_type_without_version_first_for_imported_type) { auto package{createSynchronizationPackageWithVersions()}; storage.synchronize(package); - Storage::Synchronization::Type type{ - "Item", - Storage::Synchronization::ImportedType{"BuiltInObj"}, - Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, - sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + Storage::Synchronization::Type type{"Item", + Storage::Synchronization::ImportedType{"BuiltInObj"}, + Storage::Synchronization::ImportedType{}, + TypeTraitsKind::Reference, + sourceId2, + {Storage::Synchronization::ExportedType{qtQuickModuleId, + "Item", + Storage::Version{}}}}; Storage::Import import{qmlModuleId, Storage::Version{}, sourceId2}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, fetch_exported_type_without_version_first_for_qualified_imported_type) @@ -4921,17 +4947,17 @@ TEST_F(ProjectStorage, fetch_exported_type_without_version_first_for_qualified_i "Item", Storage::Synchronization::QualifiedImportedType{"BuiltInObj", import}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId2, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{}}}}; + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{}}}}; storage.synchronize(SynchronizationPackage{{import}, {type}, {sourceId2}}); ASSERT_THAT(storage.fetchTypes(), - Contains(IsStorageType( - sourceId2, "Item", fetchTypeId(sourceId1, "QObject"), TypeTraits::Reference))); + Contains(IsStorageType(sourceId2, + "Item", + fetchTypeId(sourceId1, "QObject"), + TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, ensure_that_properties_for_removed_types_are_not_anymore_relinked) @@ -4940,11 +4966,9 @@ TEST_F(ProjectStorage, ensure_that_properties_for_removed_types_are_not_anymore_ "QObject", Storage::Synchronization::ImportedType{""}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qmlModuleId, - "Object", - Storage::Version{}}}, + {Storage::Synchronization::ExportedType{qmlModuleId, "Object", Storage::Version{}}}, {Storage::Synchronization::PropertyDeclaration{"data", Storage::Synchronization::ImportedType{ "Object"}, @@ -4980,11 +5004,9 @@ TEST_F(ProjectStorage, minimal_updates) "QQuickItem", {}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId1, - {Storage::Synchronization::ExportedType{qtQuickModuleId, - "Item", - Storage::Version{2, 0}}, + {Storage::Synchronization::ExportedType{qtQuickModuleId, "Item", Storage::Version{2, 0}}, Storage::Synchronization::ExportedType{qtQuickNativeModuleId, "QQuickItem"}}, {}, {}, @@ -4997,7 +5019,7 @@ TEST_F(ProjectStorage, minimal_updates) ASSERT_THAT( storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -5005,7 +5027,7 @@ TEST_F(ProjectStorage, minimal_updates) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item", 2, 0), IsExportedType(qtQuickNativeModuleId, "QQuickItem"))), @@ -5286,7 +5308,7 @@ TEST_F(ProjectStorage, exclude_exported_types) ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -5294,7 +5316,7 @@ TEST_F(ProjectStorage, exclude_exported_types) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -5312,22 +5334,22 @@ TEST_F(ProjectStorage, module_exported_import) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item")))), - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object")))), AllOf(IsStorageType(sourceId3, "QQuickItem3d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick3DModuleId, "Item3D")))), AllOf(IsStorageType(sourceId4, "MyItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(myModuleModuleId, "MyItem")))))); } @@ -5360,22 +5382,22 @@ TEST_F(ProjectStorage, module_exported_import_with_different_versions) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item")))), - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object")))), AllOf(IsStorageType(sourceId3, "QQuickItem3d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick3DModuleId, "Item3D")))), AllOf(IsStorageType(sourceId4, "MyItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(myModuleModuleId, "MyItem")))))); } @@ -5397,27 +5419,28 @@ TEST_F(ProjectStorage, module_exported_import_with_indirect_different_versions) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item")))), - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object")))), AllOf(IsStorageType(sourceId3, "QQuickItem3d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick3DModuleId, "Item3D")))), AllOf(IsStorageType(sourceId4, "MyItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(myModuleModuleId, "MyItem")))))); } -TEST_F(ProjectStorage, module_exported_import_prevent_collision_if_module_is_indirectly_reexported_multiple_times) +TEST_F(ProjectStorage, + module_exported_import_prevent_collision_if_module_is_indirectly_reexported_multiple_times) { ModuleId qtQuick4DModuleId{storage.moduleId("QtQuick4D")}; auto package{createModuleExportedImportSynchronizationPackage()}; @@ -5435,11 +5458,9 @@ TEST_F(ProjectStorage, module_exported_import_prevent_collision_if_module_is_ind "QQuickItem4d", Storage::Synchronization::ImportedType{"Item"}, Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, sourceId5, - {Storage::Synchronization::ExportedType{qtQuick4DModuleId, - "Item4D", - Storage::Version{1, 0}}}}); + {Storage::Synchronization::ExportedType{qtQuick4DModuleId, "Item4D", Storage::Version{1, 0}}}}); package.imports.emplace_back(qtQuick4DModuleId, Storage::Version{1}, sourceId4); storage.synchronize(std::move(package)); @@ -5449,28 +5470,28 @@ TEST_F(ProjectStorage, module_exported_import_prevent_collision_if_module_is_ind AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item")))), - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object")))), AllOf(IsStorageType(sourceId3, "QQuickItem3d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick3DModuleId, "Item3D")))), AllOf(IsStorageType(sourceId5, "QQuickItem4d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick4DModuleId, "Item4D")))), AllOf(IsStorageType(sourceId4, "MyItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(myModuleModuleId, "MyItem")))))); } @@ -5481,20 +5502,16 @@ TEST_F(ProjectStorage, distinguish_between_import_kinds) ModuleId qml11ModuleId{storage.moduleId("Qml11")}; auto package{createSimpleSynchronizationPackage()}; package.moduleDependencies.emplace_back(qmlModuleId, Storage::Version{}, sourceId1); - package.moduleDependencies.emplace_back(qml1ModuleId, - Storage::Version{1}, - sourceId1); + package.moduleDependencies.emplace_back(qml1ModuleId, Storage::Version{1}, sourceId1); package.imports.emplace_back(qml1ModuleId, Storage::Version{}, sourceId1); - package.moduleDependencies.emplace_back(qml11ModuleId, - Storage::Version{1, 1}, - sourceId1); + package.moduleDependencies.emplace_back(qml11ModuleId, Storage::Version{1, 1}, sourceId1); package.imports.emplace_back(qml11ModuleId, Storage::Version{1, 1}, sourceId1); storage.synchronize(std::move(package)); ASSERT_THAT(storage.fetchTypes(), UnorderedElementsAre( - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object"), IsExportedType(qmlModuleId, "Obj"), @@ -5502,7 +5519,7 @@ TEST_F(ProjectStorage, distinguish_between_import_kinds) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item"), IsExportedType(qtQuickNativeModuleId, @@ -5512,9 +5529,7 @@ TEST_F(ProjectStorage, distinguish_between_import_kinds) TEST_F(ProjectStorage, module_exported_import_distinguish_between_dependency_and_import_re_exports) { auto package{createModuleExportedImportSynchronizationPackage()}; - package.moduleDependencies.emplace_back(qtQuick3DModuleId, - Storage::Version{1}, - sourceId4); + package.moduleDependencies.emplace_back(qtQuick3DModuleId, Storage::Version{1}, sourceId4); storage.synchronize(std::move(package)); @@ -5523,22 +5538,22 @@ TEST_F(ProjectStorage, module_exported_import_distinguish_between_dependency_and AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item")))), - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object")))), AllOf(IsStorageType(sourceId3, "QQuickItem3d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick3DModuleId, "Item3D")))), AllOf(IsStorageType(sourceId4, "MyItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(myModuleModuleId, "MyItem")))))); } @@ -5556,22 +5571,22 @@ TEST_F(ProjectStorage, module_exported_import_with_qualified_imported_type) AllOf(IsStorageType(sourceId1, "QQuickItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuickModuleId, "Item")))), - AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraits::Reference), + AllOf(IsStorageType(sourceId2, "QObject", TypeId{}, TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qmlModuleId, "Object")))), AllOf(IsStorageType(sourceId3, "QQuickItem3d", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQuick3DModuleId, "Item3D")))), AllOf(IsStorageType(sourceId4, "MyItem", fetchTypeId(sourceId2, "QObject"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(myModuleModuleId, "MyItem")))))); } @@ -5582,19 +5597,22 @@ TEST_F(ProjectStorage, synchronize_types_add_indirect_alias_declarations) storage.synchronize(package); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_add_indirect_alias_declarations_again) @@ -5604,19 +5622,22 @@ TEST_F(ProjectStorage, synchronize_types_add_indirect_alias_declarations_again) storage.synchronize(package); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_remove_indirect_alias_declaration) @@ -5631,7 +5652,7 @@ TEST_F(ProjectStorage, synchronize_types_remove_indirect_alias_declaration) Contains(AllOf(IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre(IsPropertyDeclaration( "items", @@ -5668,7 +5689,8 @@ TEST_F(ProjectStorage, synchronize_types_add_indirect_alias_declarations_throws_ QmlDesigner::PropertyNameDoesNotExists); } -TEST_F(ProjectStorage, synchronize_types_add_indirect_alias_declarations_throws_for_wrong_property_name_tail) +TEST_F(ProjectStorage, + synchronize_types_add_indirect_alias_declarations_throws_for_wrong_property_name_tail) { auto package{createSynchronizationPackageWithIndirectAliases()}; storage.synchronize(package); @@ -5693,19 +5715,22 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declaration_type_ storage.synchronize(SynchronizationPackage{ importsSourceId3, {package.types[2]}, {sourceId3}, moduleDependenciesSourceId3, {sourceId3}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId4, "QObject2"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId4, "QObject2"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declaration_tails_type_name) @@ -5719,19 +5744,22 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declaration_tails storage.synchronize(SynchronizationPackage{ importsSourceId5, {package.types[4]}, {sourceId5}, moduleDependenciesSourceId5, {sourceId5}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId4, "QObject2"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId4, "QObject2"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declarations_property_name) @@ -5743,19 +5771,22 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declarations_prop storage.synchronize(SynchronizationPackage{ importsSourceId3, {package.types[2]}, {sourceId3}, moduleDependenciesSourceId3, {sourceId3}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId4, "QObject2"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId4, "QObject2"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declarations_property_name_tail) @@ -5772,7 +5803,7 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declarations_prop IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -5796,19 +5827,22 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_declarations_to_p storage.synchronize(SynchronizationPackage{ importsSourceId3, {package.types[2]}, {sourceId3}, moduleDependenciesSourceId3, {sourceId3}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_change_property_declarations_to_indirect_alias_declaration) @@ -5830,19 +5864,22 @@ TEST_F(ProjectStorage, synchronize_types_change_property_declarations_to_indirec storage.synchronize(SynchronizationPackage{ importsSourceId3, {package.types[2]}, {sourceId3}, moduleDependenciesSourceId3, {sourceId3}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId2, "QObject"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId2, "QObject"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_target_property_declaration_traits) @@ -5858,7 +5895,10 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_target_property_d ASSERT_THAT( storage.fetchTypes(), Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), + IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre( IsPropertyDeclaration("items", @@ -5881,19 +5921,22 @@ TEST_F(ProjectStorage, synchronize_types_change_indirect_alias_target_property_d storage.synchronize(SynchronizationPackage{ importsSourceId5, {package.types[4]}, {sourceId5}, moduleDependenciesSourceId5, {sourceId5}}); - ASSERT_THAT( - storage.fetchTypes(), - Contains(AllOf( - IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), TypeTraits::Reference), - Field(&Storage::Synchronization::Type::propertyDeclarations, - UnorderedElementsAre( - IsPropertyDeclaration("items", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList), - IsPropertyDeclaration("objects", - fetchTypeId(sourceId1, "QQuickItem"), - Storage::PropertyDeclarationTraits::IsList - | Storage::PropertyDeclarationTraits::IsReadOnly)))))); + ASSERT_THAT(storage.fetchTypes(), + Contains( + AllOf(IsStorageType(sourceId3, + "QAliasItem", + fetchTypeId(sourceId1, "QQuickItem"), + TypeTraitsKind::Reference), + Field(&Storage::Synchronization::Type::propertyDeclarations, + UnorderedElementsAre( + IsPropertyDeclaration("items", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList), + IsPropertyDeclaration( + "objects", + fetchTypeId(sourceId1, "QQuickItem"), + Storage::PropertyDeclarationTraits::IsList + | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } TEST_F(ProjectStorage, synchronize_types_remove_property_declaration_with_an_indirect_alias_throws) @@ -5910,7 +5953,8 @@ TEST_F(ProjectStorage, synchronize_types_remove_property_declaration_with_an_ind Sqlite::ConstraintPreventsModification); } -TEST_F(ProjectStorage, DISABLED_synchronize_types_remove_stem_property_declaration_with_an_indirect_alias_throws) +TEST_F(ProjectStorage, + DISABLED_synchronize_types_remove_stem_property_declaration_with_an_indirect_alias_throws) { auto package{createSynchronizationPackageWithIndirectAliases()}; storage.synchronize(package); @@ -5941,7 +5985,7 @@ TEST_F(ProjectStorage, synchronize_types_remove_property_declaration_and_indirec Contains(AllOf(IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, UnorderedElementsAre(IsPropertyDeclaration( "items", @@ -5967,7 +6011,7 @@ TEST_F(ProjectStorage, synchronize_types_remove_property_declaration_and_indirec AllOf(IsStorageType(sourceId3, "QAliasItem", fetchTypeId(sourceId1, "QQuickItem"), - TypeTraits::Reference), + TypeTraitsKind::Reference), Field(&Storage::Synchronization::Type::propertyDeclarations, IsEmpty())))); } @@ -6644,7 +6688,7 @@ TEST_F(ProjectStorage, get_type) auto type = storage.type(typeId); - ASSERT_THAT(type, Optional(IsInfoType(defaultPropertyId, sourceId1, TypeTraits::Reference))); + ASSERT_THAT(type, Optional(IsInfoType(defaultPropertyId, sourceId1, TypeTraitsKind::Reference))); } TEST_F(ProjectStorage, dont_get_type_for_invalid_id) @@ -7016,16 +7060,14 @@ TEST_F(ProjectStorage, storage.synchronize(package); auto importId = storage.importId(Storage::Import{qmlModuleId, Storage::Version{}, sourceId1}); auto expectedImportedTypeNameId = storage.importedTypeNameId(importId, "Item"); - auto importId2 = storage.importId( - Storage::Import{qtQuickModuleId, Storage::Version{}, sourceId1}); + auto importId2 = storage.importId(Storage::Import{qtQuickModuleId, Storage::Version{}, sourceId1}); auto importedTypeNameId = storage.importedTypeNameId(importId2, "Item"); ASSERT_THAT(importedTypeNameId, Not(expectedImportedTypeNameId)); } -TEST_F(ProjectStorage, - get_imported_type_name_id_for_import_id_returns_different_id_for_different_name) +TEST_F(ProjectStorage, get_imported_type_name_id_for_import_id_returns_different_id_for_different_name) { auto package{createSimpleSynchronizationPackage()}; storage.synchronize(package); @@ -7205,16 +7247,440 @@ TEST_F(ProjectStorage, synchronize_property_editor_with_non_existing_type_name) ASSERT_THAT(storage.propertyEditorPathId(fetchTypeId(sourceId4, "Item4D")), IsFalse()); } -TEST_F(ProjectStorage, call_refresh_callback_after_synchronization) +TEST_F(ProjectStorage, call_remove_type_ids_in_observer_after_synchronization) { auto package{createSimpleSynchronizationPackage()}; - MockFunction callbackMock; - auto callback = callbackMock.AsStdFunction(); - storage.addRefreshCallback(&callback); + ProjectStorageObserverMock observerMock; + storage.addObserver(&observerMock); + storage.synchronize(package); + package.types.clear(); - EXPECT_CALL(callbackMock, Call(_)); + EXPECT_CALL(observerMock, removedTypeIds(_)); storage.synchronize(package); } +TEST_F(ProjectStorage, synchronize_type_annotation_type_traits) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeContainer = FlagIs::True; + traits.visibleInLibrary = FlagIs::True; + + storage.synchronize(package); + + ASSERT_THAT(storage.type(fetchTypeId(sourceId2, "QObject"))->traits, traits); +} + +TEST_F(ProjectStorage, synchronize_updates_type_annotation_type_traits) +{ + auto package{createSimpleSynchronizationPackage()}; + storage.synchronize(package); + SynchronizationPackage annotationPackage; + annotationPackage.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeContainer = FlagIs::True; + traits.visibleInLibrary = FlagIs::True; + + storage.synchronize(annotationPackage); + + ASSERT_THAT(storage.type(fetchTypeId(sourceId2, "QObject"))->traits, traits); +} + +TEST_F(ProjectStorage, synchronize_clears_annotation_type_traits_if_annotation_was_removed) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + package.typeAnnotations[0].traits.isStackedContainer = FlagIs::True; + TypeTraits traits{TypeTraitsKind::Reference}; + traits.canBeContainer = FlagIs::True; + traits.visibleInLibrary = FlagIs::True; + traits.isStackedContainer = FlagIs::True; + + storage.synchronize(package); + + ASSERT_THAT(storage.type(fetchTypeId(sourceId2, "QObject"))->traits, traits); +} + +TEST_F(ProjectStorage, synchronize_updatesannotation_type_traits) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + TypeTraits traits{TypeTraitsKind::Value}; + package.types[1].traits.kind = TypeTraitsKind::Value; + package.typeAnnotations.clear(); + + storage.synchronize(package); + + ASSERT_THAT(storage.type(fetchTypeId(sourceId2, "QObject"))->traits, traits); +} + +TEST_F(ProjectStorage, synchronize_type_annotation_type_icon_path) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + + storage.synchronize(package); + + ASSERT_THAT(storage.typeIconPath(fetchTypeId(sourceId2, "QObject")), Eq("/path/to/icon.png")); +} + +TEST_F(ProjectStorage, synchronize_removes_type_annotation_type_icon_path) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + package.typeAnnotations.clear(); + + storage.synchronize(package); + + ASSERT_THAT(storage.typeIconPath(fetchTypeId(sourceId2, "QObject")), IsEmpty()); +} + +TEST_F(ProjectStorage, synchronize_updates_type_annotation_type_icon_path) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + package.typeAnnotations[0].iconPath = "/path/to/icon2.png"; + + storage.synchronize(package); + + ASSERT_THAT(storage.typeIconPath(fetchTypeId(sourceId2, "QObject")), Eq("/path/to/icon2.png")); +} + +TEST_F(ProjectStorage, return_empty_path_if_no_type_icon_exists) +{ + auto package{createSimpleSynchronizationPackage()}; + storage.synchronize(package); + + auto iconPath = storage.typeIconPath(fetchTypeId(sourceId2, "QObject")); + + ASSERT_THAT(iconPath, IsEmpty()); +} + +TEST_F(ProjectStorage, return_empty_path_if_that_type_does_not_exists) +{ + auto iconPath = storage.typeIconPath(fetchTypeId(sourceId2, "QObject")); + + ASSERT_THAT(iconPath, IsEmpty()); +} + +TEST_F(ProjectStorage, synchronize_type_hints) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + + storage.synchronize(package); + + ASSERT_THAT(storage.typeHints(fetchTypeId(sourceId1, "QQuickItem")), + UnorderedElementsAre(IsTypeHint("canBeContainer", "true"), + IsTypeHint("forceClip", "false"))); +} + +TEST_F(ProjectStorage, synchronize_removes_type_hints) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + package.typeAnnotations.clear(); + + storage.synchronize(package); + + ASSERT_THAT(storage.typeHints(fetchTypeId(sourceId2, "QObject")), IsEmpty()); +} + +TEST_F(ProjectStorage, return_empty_type_hints_if_no_type_hints_exists) +{ + auto package{createSimpleSynchronizationPackage()}; + storage.synchronize(package); + + auto typeHints = storage.typeHints(fetchTypeId(sourceId2, "QObject")); + + ASSERT_THAT(typeHints, IsEmpty()); +} + +TEST_F(ProjectStorage, return_empty_type_hints_if_type_does_not_exists) +{ + auto typeHints = storage.typeHints(fetchTypeId(sourceId2, "QObject")); + + ASSERT_THAT(typeHints, IsEmpty()); +} + +TEST_F(ProjectStorage, synchronize_item_library_entries) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + + storage.synchronize(package); + + ASSERT_THAT( + storage.allItemLibraryEntries(), + UnorderedElementsAre( + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Foo", + "/path/icon", + "Basic Items", + "QtQuick", + "Foo is a Item", + "/path/templates/item.qml", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 32.1), + IsItemLibraryProperty("y", "double", 12.3)), + UnorderedElementsAre("/path/templates/frame.png", + "/path/templates/frame.frag")), + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Bar", + "/path/icon2", + "Basic Items", + "QtQuick", + "Bar is a Item", + "", + UnorderedElementsAre(IsItemLibraryProperty("color", "color", "#blue")), + IsEmpty()), + IsItemLibraryEntry(fetchTypeId(sourceId1, "QQuickItem"), + "Item", + "/path/icon3", + "Advanced Items", + "QtQuick", + "Item is an Object", + "", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 1), + IsItemLibraryProperty("y", "double", 2)), + IsEmpty()))); +} + +TEST_F(ProjectStorage, synchronize_removes_item_library_entries) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + package.typeAnnotations.clear(); + + storage.synchronize(package); + + ASSERT_THAT(storage.allItemLibraryEntries(), IsEmpty()); +} + +TEST_F(ProjectStorage, synchronize_udpates_item_library_entries) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + package.typeAnnotations[0].itemLibraryJson + = R"xy([{"name":"Foo","iconPath":"/path/icon","category":"Basic Items", "import":"QtQuick","toolTip":"Foo is a Item", "properties":[["x", "double", 32.1], ["y", "double", 12.3]]}])xy"; + + storage.synchronize(package); + + ASSERT_THAT(storage.itemLibraryEntries(fetchTypeId(sourceId2, "QObject")), + ElementsAre( + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Foo", + "/path/icon", + "Basic Items", + "QtQuick", + "Foo is a Item", + "", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 32.1), + IsItemLibraryProperty("y", "double", 12.3)), + IsEmpty()))); +} + +TEST_F(ProjectStorage, get_all_item_library_entries) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + + auto entries = storage.allItemLibraryEntries(); + + ASSERT_THAT( + entries, + UnorderedElementsAre( + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Foo", + "/path/icon", + "Basic Items", + "QtQuick", + "Foo is a Item", + "/path/templates/item.qml", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 32.1), + IsItemLibraryProperty("y", "double", 12.3)), + UnorderedElementsAre("/path/templates/frame.png", + "/path/templates/frame.frag")), + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Bar", + "/path/icon2", + "Basic Items", + "QtQuick", + "Bar is a Item", + "", + UnorderedElementsAre(IsItemLibraryProperty("color", "color", "#blue")), + IsEmpty()), + IsItemLibraryEntry(fetchTypeId(sourceId1, "QQuickItem"), + "Item", + "/path/icon3", + "Advanced Items", + "QtQuick", + "Item is an Object", + "", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 1), + IsItemLibraryProperty("y", "double", 2)), + IsEmpty()))); +} + +TEST_F(ProjectStorage, get_item_library_entries_by_type_id) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + auto typeId = fetchTypeId(sourceId2, "QObject"); + + auto entries = storage.itemLibraryEntries(typeId); + + ASSERT_THAT( + entries, + UnorderedElementsAre( + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Foo", + "/path/icon", + "Basic Items", + "QtQuick", + "Foo is a Item", + "/path/templates/item.qml", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 32.1), + IsItemLibraryProperty("y", "double", 12.3)), + UnorderedElementsAre("/path/templates/frame.png", + "/path/templates/frame.frag")), + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Bar", + "/path/icon2", + "Basic Items", + "QtQuick", + "Bar is a Item", + "", + UnorderedElementsAre(IsItemLibraryProperty("color", "color", "#blue")), + IsEmpty()))); +} + +TEST_F(ProjectStorage, get_no_item_library_entries_if_type_id_is_invalid) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + + auto entries = storage.itemLibraryEntries(TypeId()); + + ASSERT_THAT(entries, IsEmpty()); +} + +TEST_F(ProjectStorage, get_item_library_entries_by_source_id) +{ + auto package{createSimpleSynchronizationPackage()}; + package.typeAnnotations = createTypeAnnotions(); + package.updatedTypeAnnotationSourceIds = createUpdatedTypeAnnotionSourceIds( + package.typeAnnotations); + storage.synchronize(package); + + auto entries = storage.itemLibraryEntries(sourceId2); + + ASSERT_THAT( + entries, + UnorderedElementsAre( + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Foo", + "/path/icon", + "Basic Items", + "QtQuick", + "Foo is a Item", + "/path/templates/item.qml", + UnorderedElementsAre(IsItemLibraryProperty("x", "double", 32.1), + IsItemLibraryProperty("y", "double", 12.3)), + UnorderedElementsAre("/path/templates/frame.png", + "/path/templates/frame.frag")), + IsItemLibraryEntry(fetchTypeId(sourceId2, "QObject"), + "Bar", + "/path/icon2", + "Basic Items", + "QtQuick", + "Bar is a Item", + "", + UnorderedElementsAre(IsItemLibraryProperty("color", "color", "#blue")), + IsEmpty()))); +} + +TEST_F(ProjectStorage, return_type_ids_for_module_id) +{ + auto package{createBuiltinSynchronizationPackage()}; + storage.synchronize(package); + + auto typeIds = storage.typeIds(QMLModuleId); + + ASSERT_THAT(typeIds, + UnorderedElementsAre(fetchTypeId(sourceId1, "bool"), + fetchTypeId(sourceId1, "int"), + fetchTypeId(sourceId1, "double"), + fetchTypeId(sourceId1, "date"), + fetchTypeId(sourceId1, "string"), + fetchTypeId(sourceId1, "url"), + fetchTypeId(sourceId1, "var"))); +} + +TEST_F(ProjectStorage, get_hair_ids) +{ + auto package{createHeirPackage()}; + storage.synchronize(package); + auto typeId = fetchTypeId(sourceId1, "QObject"); + + auto heirIds = storage.heirIds(typeId); + + ASSERT_THAT(heirIds, + UnorderedElementsAre(fetchTypeId(sourceId1, "QObject2"), + fetchTypeId(sourceId1, "QObject3"), + fetchTypeId(sourceId1, "QObject4"), + fetchTypeId(sourceId1, "QObject5"))); +} + +TEST_F(ProjectStorage, get_no_hair_ids_for_invalid_type_id) +{ + auto package{createHeirPackage()}; + storage.synchronize(package); + auto typeId = TypeId{}; + + auto heirIds = storage.heirIds(typeId); + + ASSERT_THAT(heirIds, IsEmpty()); +} } // namespace diff --git a/tests/unit/tests/unittests/projectstorage/projectstoragepathwatcher-test.cpp b/tests/unit/tests/unittests/projectstorage/projectstoragepathwatcher-test.cpp index 9fc9c30551b..d6ed96d0cfc 100644 --- a/tests/unit/tests/unittests/projectstorage/projectstoragepathwatcher-test.cpp +++ b/tests/unit/tests/unittests/projectstorage/projectstoragepathwatcher-test.cpp @@ -39,6 +39,22 @@ using QmlDesigner::WatcherEntry; class ProjectStoragePathWatcher : public testing::Test { protected: + static void SetUpTestSuite() + { + static_database = std::make_unique(":memory:", Sqlite::JournalMode::Memory); + + static_projectStorage = std::make_unique>( + *static_database, static_database->isInitialized()); + } + + static void TearDownTestSuite() + { + static_projectStorage.reset(); + static_database.reset(); + } + + ~ProjectStoragePathWatcher() { static_projectStorage->resetForTestsOnly(); } + ProjectStoragePathWatcher() { ON_CALL(mockFileSystem, fileStatus(_)).WillByDefault([](auto sourceId) { @@ -52,6 +68,7 @@ protected: ON_CALL(mockFileSystem, directoryEntries(Eq(sourceContextPath3))) .WillByDefault(Return(SourceIds{sourceIds[4]})); } + static WatcherEntries sorted(WatcherEntries &&entries) { std::stable_sort(entries.begin(), entries.end()); @@ -62,8 +79,10 @@ protected: protected: NiceMock notifier; NiceMock mockFileSystem; - Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; - QmlDesigner::ProjectStorage storage{database, database.isInitialized()}; + inline static std::unique_ptr static_database; + Sqlite::Database &database = *static_database; + inline static std::unique_ptr> static_projectStorage; + QmlDesigner::ProjectStorage &storage = *static_projectStorage; SourcePathCache pathCache{storage}; Watcher watcher{pathCache, mockFileSystem, ¬ifier}; NiceMock &mockQFileSytemWatcher = watcher.fileSystemWatcher(); diff --git a/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp b/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp index c167e3eb8b5..d9578d2f1b6 100644 --- a/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp +++ b/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp @@ -31,6 +31,7 @@ using QmlDesigner::Storage::Synchronization::ModuleExportedImport; using QmlDesigner::Storage::Synchronization::ProjectData; using QmlDesigner::Storage::Synchronization::SynchronizationPackage; using QmlDesigner::Storage::TypeTraits; +using QmlDesigner::Storage::TypeTraitsKind; using QmlDesigner::Storage::Version; MATCHER_P5(IsStorageType, @@ -136,6 +137,20 @@ auto IsPropertyEditorQmlPath(const ModuleIdMatcher &moduleIdMatcher, class ProjectStorageUpdater : public testing::Test { public: + static void SetUpTestSuite() + { + static_database = std::make_unique(":memory:", Sqlite::JournalMode::Memory); + + static_projectStorage = std::make_unique>( + *static_database, static_database->isInitialized()); + } + + static void TearDownTestSuite() + { + static_projectStorage.reset(); + static_database.reset(); + } + ProjectStorageUpdater() { setFilesChanged({qmltypesPathSourceId, @@ -207,6 +222,8 @@ public: }); } + ~ProjectStorageUpdater() { static_projectStorage->resetForTestsOnly(); } + void setFilesDontChanged(const QmlDesigner::SourceIds &sourceIds) { for (auto sourceId : sourceIds) { @@ -287,8 +304,10 @@ protected: NiceMock qmlTypesParserMock; NiceMock qmlDocumentParserMock; QmlDesigner::FileStatusCache fileStatusCache{fileSystemMock}; - Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; - QmlDesigner::ProjectStorage storage{database, database.isInitialized()}; + inline static std::unique_ptr static_database; + Sqlite::Database &database = *static_database; + inline static std::unique_ptr> static_projectStorage; + QmlDesigner::ProjectStorage &storage = *static_projectStorage; QmlDesigner::SourcePathCache> sourcePathCache{ storage}; NiceMock patchWatcherMock; @@ -323,14 +342,14 @@ protected: "QObject", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesPathSourceId, {Storage::Synchronization::ExportedType{exampleModuleId, "Object"}, Storage::Synchronization::ExportedType{exampleModuleId, "Obj"}}}; Storage::Synchronization::Type itemType{"QItem", Storage::Synchronization::ImportedType{}, Storage::Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypes2PathSourceId, {Storage::Synchronization::ExportedType{exampleModuleId, "Item"}}}; @@ -580,7 +599,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -588,7 +607,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -596,7 +615,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents) IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -655,7 +674,7 @@ TEST_F(ProjectStorageUpdater, synchronize_add_only_qml_document_in_directory) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -664,7 +683,7 @@ TEST_F(ProjectStorageUpdater, synchronize_add_only_qml_document_in_directory) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -715,7 +734,7 @@ TEST_F(ProjectStorageUpdater, synchronize_removes_qml_document) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -724,7 +743,7 @@ TEST_F(ProjectStorageUpdater, synchronize_removes_qml_document) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -776,7 +795,7 @@ TEST_F(ProjectStorageUpdater, synchronize_removes_qml_document_in_qmldir_only) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -784,7 +803,7 @@ TEST_F(ProjectStorageUpdater, synchronize_removes_qml_document_in_qmldir_only) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -833,7 +852,7 @@ TEST_F(ProjectStorageUpdater, synchronize_add_qml_document_to_qmldir) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -841,7 +860,7 @@ TEST_F(ProjectStorageUpdater, synchronize_add_qml_document_to_qmldir) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -889,7 +908,7 @@ TEST_F(ProjectStorageUpdater, synchronize_remove_qml_document_from_qmldir) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -897,7 +916,7 @@ TEST_F(ProjectStorageUpdater, synchronize_remove_qml_document_from_qmldir) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -941,7 +960,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_dont_update_if_up_to_dat UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -949,7 +968,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_dont_update_if_up_to_dat IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -957,7 +976,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_dont_update_if_up_to_dat IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -1014,13 +1033,13 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_not_changed) Eq(itemType), AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -1063,7 +1082,7 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_not_changed_and_some Eq(objectType), AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -1118,7 +1137,7 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_changed_and_some_rem UnorderedElementsAre(AllOf( IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -1230,7 +1249,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_with_different_version_b UnorderedElementsAre(AllOf( IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -1272,7 +1291,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_with_different_type_name UnorderedElementsAre(AllOf( IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -1820,21 +1839,21 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -1930,7 +1949,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir_add_qml_d UnorderedElementsAre(AllOf( IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2019,7 +2038,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2027,7 +2046,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2035,7 +2054,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories) IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2162,7 +2181,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_qmldir) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2170,7 +2189,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_qmldir) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2178,7 +2197,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_qmldir) IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2276,7 +2295,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_add_only_qml_document_in_directory UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2285,7 +2304,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_add_only_qml_document_in_directory IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2336,7 +2355,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removes_qml_document) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2345,7 +2364,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removes_qml_document) IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2397,7 +2416,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removes_qml_document_in_qmldir_onl UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2405,7 +2424,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removes_qml_document_in_qmldir_onl IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2454,7 +2473,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_add_qml_document_to_qm UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2462,7 +2481,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_add_qml_document_to_qm IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2510,7 +2529,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_remove_qml_document_fr UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2518,7 +2537,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_remove_qml_document_fr IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2562,7 +2581,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_dont_update_qml_docume UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2570,7 +2589,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_dont_update_qml_docume IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2578,7 +2597,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_dont_update_qml_docume IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2632,7 +2651,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldirs_dont_update_qml_documents_ UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2640,7 +2659,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldirs_dont_update_qml_documents_ IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2648,7 +2667,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldirs_dont_update_qml_documents_ IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Minimal), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2705,13 +2724,13 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directory_but_not_qmldir) Eq(itemType), AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -2745,13 +2764,13 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qml_documents) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -2779,7 +2798,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removed_qml_documents) UnorderedElementsAre(AllOf( IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -2944,7 +2963,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_but_not_included_q UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2952,7 +2971,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_but_not_included_q IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -2960,7 +2979,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_but_not_included_q IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3018,7 +3037,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qml_do UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3026,7 +3045,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qml_do IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3034,7 +3053,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qml_do IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3111,7 +3130,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qmltyp Eq(itemType), AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3119,7 +3138,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qmltyp IsExportedType(pathModuleId, "First", -1, -1)))), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3127,7 +3146,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qmltyp IsExportedType(pathModuleId, "First2", -1, -1)))), AllOf(IsStorageType("Second.qml", Storage::Synchronization::ImportedType{"Object3"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId3, Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes, @@ -3224,13 +3243,13 @@ TEST_F(ProjectStorageUpdater, input_is_reused_next_call_if_an_error_happens) Eq(itemType), AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -3277,23 +3296,22 @@ TEST_F(ProjectStorageUpdater, input_is_reused_next_call_if_an_error_happens_and_ synchronize(AllOf( Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1, import2, import4, import5)), - Field( - &SynchronizationPackage::types, - UnorderedElementsAre( - Eq(objectType), - Eq(itemType), - AllOf(IsStorageType("First.qml", - Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, - qmlDocumentSourceId1, - Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), - Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), - AllOf(IsStorageType("First2.qml", - Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, - qmlDocumentSourceId2, - Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), - Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), + Field(&SynchronizationPackage::types, + UnorderedElementsAre( + Eq(objectType), + Eq(itemType), + AllOf(IsStorageType("First.qml", + Storage::Synchronization::ImportedType{"Object"}, + TypeTraitsKind::Reference, + qmlDocumentSourceId1, + Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), + Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), + AllOf(IsStorageType("First2.qml", + Storage::Synchronization::ImportedType{"Object2"}, + TypeTraitsKind::Reference, + qmlDocumentSourceId2, + Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), + Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), Field(&SynchronizationPackage::updatedSourceIds, UnorderedElementsAre(qmlDocumentSourceId1, qmlDocumentSourceId2, @@ -3346,13 +3364,13 @@ TEST_F(ProjectStorageUpdater, input_is_reused_next_call_if_an_error_happens_and_ Eq(itemType), AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), @@ -3401,13 +3419,13 @@ TEST_F(ProjectStorageUpdater, input_is_cleared_after_successful_update) UnorderedElementsAre( AllOf(IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())), AllOf(IsStorageType("First2.qml", Storage::Synchronization::ImportedType{"Object2"}, - TypeTraits::Reference, + TypeTraitsKind::Reference, qmlDocumentSourceId2, Storage::Synchronization::ChangeLevel::ExcludeExportedTypes), Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))), diff --git a/tests/unit/tests/unittests/projectstorage/qmltypesparser-test.cpp b/tests/unit/tests/unittests/projectstorage/qmltypesparser-test.cpp index ba4b4865b86..78f8f41d6c4 100644 --- a/tests/unit/tests/unittests/projectstorage/qmltypesparser-test.cpp +++ b/tests/unit/tests/unittests/projectstorage/qmltypesparser-test.cpp @@ -58,6 +58,15 @@ MATCHER_P(HasFlag, flag, std::string(negation ? "hasn't " : "has ") + PrintToStr return bool(arg & flag); } +MATCHER_P(UsesCustomParser, + value, + std::string(negation ? "don't used custom parser " : "uses custom parser")) +{ + const Storage::TypeTraits &traits = arg; + + return traits.usesCustomParser == value; +} + template auto IsTypeTrait(const Matcher &matcher) { @@ -215,12 +224,12 @@ TEST_F(QmlTypesParser, types) UnorderedElementsAre(IsType("QObject", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesFileSourceId), IsType("QQmlComponent", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesFileSourceId))); } @@ -238,12 +247,12 @@ TEST_F(QmlTypesParser, prototype) UnorderedElementsAre(IsType("QObject", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesFileSourceId), IsType("QQmlComponent", Synchronization::ImportedType{"QObject"}, Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesFileSourceId))); } @@ -261,12 +270,12 @@ TEST_F(QmlTypesParser, extension) UnorderedElementsAre(IsType("QObject", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesFileSourceId), IsType("QQmlComponent", Synchronization::ImportedType{}, Synchronization::ImportedType{"QObject"}, - Storage::TypeTraits::Reference, + Storage::TypeTraitsKind::Reference, qmltypesFileSourceId))); } @@ -588,6 +597,8 @@ TEST_F(QmlTypesParser, enumeration_is_exported_as_type) }})"}; parser.parse(source, imports, types, projectData); + QmlDesigner::Storage::TypeTraits traits{QmlDesigner::Storage::TypeTraitsKind::Value}; + traits.isEnum = true; ASSERT_THAT( types, @@ -595,7 +606,7 @@ TEST_F(QmlTypesParser, enumeration_is_exported_as_type) AllOf(IsType("QObject::NamedColorSpace", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Value | Storage::TypeTraits::IsEnum, + traits, qmltypesFileSourceId), Field(&Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQmlNativeModuleId, @@ -604,7 +615,7 @@ TEST_F(QmlTypesParser, enumeration_is_exported_as_type) AllOf(IsType("QObject::VerticalLayoutDirection", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Value | Storage::TypeTraits::IsEnum, + traits, qmltypesFileSourceId), Field(&Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQmlNativeModuleId, @@ -632,13 +643,15 @@ TEST_F(QmlTypesParser, enumeration_is_exported_as_type_with_alias) }})"}; parser.parse(source, imports, types, projectData); + QmlDesigner::Storage::TypeTraits traits{QmlDesigner::Storage::TypeTraitsKind::Value}; + traits.isEnum = true; ASSERT_THAT(types, UnorderedElementsAre( AllOf(IsType("QObject::NamedColorSpaces", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Value | Storage::TypeTraits::IsEnum, + traits, qmltypesFileSourceId), Field(&Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQmlNativeModuleId, @@ -678,13 +691,15 @@ TEST_F(QmlTypesParser, enumeration_is_exported_as_type_with_alias_too) }})"}; parser.parse(source, imports, types, projectData); + QmlDesigner::Storage::TypeTraits traits{QmlDesigner::Storage::TypeTraitsKind::Value}; + traits.isEnum = true; ASSERT_THAT(types, UnorderedElementsAre( AllOf(IsType("QObject::NamedColorSpaces", Synchronization::ImportedType{}, Synchronization::ImportedType{}, - Storage::TypeTraits::Value | Storage::TypeTraits::IsEnum, + traits, qmltypesFileSourceId), Field(&Synchronization::Type::exportedTypes, UnorderedElementsAre(IsExportedType(qtQmlNativeModuleId, @@ -760,7 +775,7 @@ TEST_F(QmlTypesParser, access_type_is_reference) parser.parse(source, imports, types, projectData); - ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraits::Reference))); + ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraitsKind::Reference))); } TEST_F(QmlTypesParser, access_type_is_value) @@ -772,7 +787,7 @@ TEST_F(QmlTypesParser, access_type_is_value) parser.parse(source, imports, types, projectData); - ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraits::Value))); + ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraitsKind::Value))); } TEST_F(QmlTypesParser, access_type_is_sequence) @@ -784,7 +799,7 @@ TEST_F(QmlTypesParser, access_type_is_sequence) parser.parse(source, imports, types, projectData); - ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraits::Sequence))); + ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraitsKind::Sequence))); } TEST_F(QmlTypesParser, access_type_is_none) @@ -796,7 +811,7 @@ TEST_F(QmlTypesParser, access_type_is_none) parser.parse(source, imports, types, projectData); - ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraits::None))); + ASSERT_THAT(types, ElementsAre(IsTypeTrait(Storage::TypeTraitsKind::None))); } TEST_F(QmlTypesParser, uses_custom_parser) @@ -808,7 +823,7 @@ TEST_F(QmlTypesParser, uses_custom_parser) parser.parse(source, imports, types, projectData); - ASSERT_THAT(types, ElementsAre(IsTypeTrait(HasFlag(Storage::TypeTraits::UsesCustomParser)))); + ASSERT_THAT(types, ElementsAre(IsTypeTrait(UsesCustomParser(true)))); } TEST_F(QmlTypesParser, uses_no_custom_parser) @@ -820,7 +835,7 @@ TEST_F(QmlTypesParser, uses_no_custom_parser) parser.parse(source, imports, types, projectData); - ASSERT_THAT(types, ElementsAre(IsTypeTrait(Not(HasFlag(Storage::TypeTraits::UsesCustomParser))))); + ASSERT_THAT(types, ElementsAre(IsTypeTrait(UsesCustomParser(false)))); } } // namespace diff --git a/tests/unit/tests/unittests/projectstorage/typeannotationreader-test.cpp b/tests/unit/tests/unittests/projectstorage/typeannotationreader-test.cpp new file mode 100644 index 00000000000..ed5c1a0778b --- /dev/null +++ b/tests/unit/tests/unittests/projectstorage/typeannotationreader-test.cpp @@ -0,0 +1,758 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "../utils/googletest.h" + +#include + +#include +#include +#include + +namespace { + +template +auto IsTypeAnnotation(QmlDesigner::SourceId sourceId, + Utils::SmallStringView typeName, + QmlDesigner::ModuleId moduleId, + Utils::SmallStringView iconPath, + QmlDesigner::Storage::TypeTraits traits, + HintsJsonMatcher hintsJsonMatcher, + ItemLibraryJsonMatcher itemLibraryJsonMatcher) +{ + using QmlDesigner::Storage::Synchronization::TypeAnnotation; + return AllOf(Field("sourceId", &TypeAnnotation::sourceId, sourceId), + Field("typeName", &TypeAnnotation::typeName, typeName), + Field("moduleId", &TypeAnnotation::moduleId, moduleId), + Field("iconPath", &TypeAnnotation::iconPath, iconPath), + Field("traits", &TypeAnnotation::traits, traits), + Field("hintsJson", &TypeAnnotation::hintsJson, hintsJsonMatcher), + Field("itemLibraryJson", &TypeAnnotation::itemLibraryJson, itemLibraryJsonMatcher)); +} + +class TypeAnnotationReader : public testing::Test +{ +protected: + static void SetUpTestSuite() + { + static_database = std::make_unique(":memory:", Sqlite::JournalMode::Memory); + + static_projectStorage = std::make_unique>( + *static_database, static_database->isInitialized()); + } + + static void TearDownTestSuite() + { + static_projectStorage.reset(); + static_database.reset(); + } + + auto moduleId(Utils::SmallStringView name) const { return storage.moduleId(name); } + +protected: + inline static std::unique_ptr static_database; + Sqlite::Database &database = *static_database; + inline static std::unique_ptr> static_projectStorage; + QmlDesigner::ProjectStorage &storage = *static_projectStorage; + QmlDesigner::Storage::TypeAnnotationReader reader{storage}; + QmlDesigner::SourceId sourceId = QmlDesigner::SourceId::create(33); +}; + +TEST_F(TypeAnnotationReader, parse_type) +{ + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + } + Type { + name: "QtQuick.Item" + icon: "images/item-icon16.png" + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + UnorderedElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()), + IsTypeAnnotation(sourceId, + "Item", + moduleId("QtQuick"), + "/path/images/item-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_canBeContainer) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + canBeContainer: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.canBeContainer = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_forceClip) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + forceClip: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.forceClip = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_doesLayoutChildren) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + doesLayoutChildren: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.doesLayoutChildren = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_canBeDroppedInFormEditor) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + canBeDroppedInFormEditor: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.canBeDroppedInFormEditor = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_canBeDroppedInNavigator) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + canBeDroppedInNavigator: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.canBeDroppedInNavigator = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_canBeDroppedInView3D) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + canBeDroppedInView3D: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.canBeDroppedInView3D = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_isMovable) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + isMovable: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.isMovable = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_isResizable) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + isResizable: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.isResizable = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_hasFormEditorItem) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + hasFormEditorItem: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.hasFormEditorItem = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_isStackedContainer) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + isStackedContainer: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.isStackedContainer = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_takesOverRenderingOfChildren) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + takesOverRenderingOfChildren: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.takesOverRenderingOfChildren = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_visibleInNavigator) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + visibleInNavigator: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.visibleInNavigator = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_true_visibleInLibrary) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + visibleInLibrary: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + traits.visibleInLibrary = FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_false) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + isMovable: false + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_complex_expression) +{ + using QmlDesigner::FlagIs; + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + Hints { + isMovable: true || false + visibleNonDefaultProperties: "layer.effect" + } + } + + Type { + name: "QtQuick.Item" + icon: "images/item-icon16.png" + + Hints { + canBeContainer: true + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits frameTraits; + frameTraits.isMovable = QmlDesigner::FlagIs::Set; + QmlDesigner::Storage::TypeTraits itemTraits; + itemTraits.canBeContainer = QmlDesigner::FlagIs::True; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + UnorderedElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + frameTraits, + StrippedStringEq(R"xy({"isMovable":"true || false", + "visibleNonDefaultProperties":"layer.effect"})xy"), + IsEmpty()), + IsTypeAnnotation(sourceId, + "Item", + moduleId("QtQuick"), + "/path/images/item-icon16.png", + itemTraits, + IsEmpty(), + IsEmpty()))); +} + +TEST_F(TypeAnnotationReader, parse_item_library_entry) +{ + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + ItemLibraryEntry { + name: "Frame" + category: "Qt Quick - Controls 2" + libraryIcon: "images/frame-icon.png" + requiredImport: "QtQuick.Controls" + toolTip: qsTr("An untitled container for a group of controls.") + } + + ItemLibraryEntry { + name: "Large Frame" + category: "Qt Quick - Controls 2" + libraryIcon: "images/frame-icon.png" + requiredImport: "QtQuick.Controls" + toolTip: qsTr("An large container for a group of controls.") + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + StrippedStringEq(R"xy([ + {"category":"Qt Quick - Controls 2", + "iconPath":"images/frame-icon.png", + "import":"QtQuick.Controls", + "name":"Frame", + "toolTip":"qsTr(\"An untitled container for a group of controls.\")"}, + {"category":"Qt Quick - Controls 2", + "iconPath":"images/frame-icon.png", + "import":"QtQuick.Controls", + "name":"Large Frame", + "toolTip":"qsTr(\"An large container for a group of controls.\")"}] + )xy")))); +} + +TEST_F(TypeAnnotationReader, parse_item_library_entry_with_properties) +{ + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + icon: "images/frame-icon16.png" + + ItemLibraryEntry { + name: "Frame" + category: "Qt Quick - Controls 2" + libraryIcon: "images/frame-icon.png" + requiredImport: "QtQuick.Controls" + toolTip: qsTr("An untitled container for a group of controls.") + + Property { name: "width"; type: "int"; value: 200 } + Property { name: "height"; type: "int"; value: 100 } + } + + ItemLibraryEntry { + name: "Large Frame" + category: "Qt Quick - Controls 2" + libraryIcon: "images/frame-icon.png" + requiredImport: "QtQuick.Controls" + toolTip: qsTr("An large container for a group of controls.") + + Property { name: "width"; type: "int"; value: 2000 } + Property { name: "height"; type: "int"; value: 1000 } + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + "/path/images/frame-icon16.png", + traits, + IsEmpty(), + StrippedStringEq(R"xy([ + {"category":"Qt Quick - Controls 2", + "iconPath":"images/frame-icon.png", + "import":"QtQuick.Controls", + "name":"Frame", + "properties":[["width","int",200.0],["height","int",100.0]], + "toolTip":"qsTr(\"An untitled container for a group of controls.\")"}, + {"category":"Qt Quick - Controls 2", + "iconPath":"images/frame-icon.png", + "import":"QtQuick.Controls", + "name":"Large Frame", + "properties":[["width","int",2000.0],["height","int",1000.0]], + "toolTip":"qsTr(\"An large container for a group of controls.\")"}] + )xy")))); +} + +TEST_F(TypeAnnotationReader, parse_item_library_entry_template_path) +{ + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + + ItemLibraryEntry { + name: "Frame" + + QmlSource{ source: "templates/frame.qml" } + } + } + Type { + name: "QtQuick.Item" + + ItemLibraryEntry { + name: "Item" + + QmlSource{ source: "templates/item.qml" } + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + {}, + traits, + IsEmpty(), + StrippedStringEq(R"xy([ + {"name":"Frame", + "templatePath":"/path/templates/frame.qml"}] + )xy")), + IsTypeAnnotation(sourceId, + "Item", + moduleId("QtQuick"), + {}, + traits, + IsEmpty(), + StrippedStringEq(R"xy([ + {"name":"Item", + "templatePath":"/path/templates/item.qml"}] + )xy")))); +} + +TEST_F(TypeAnnotationReader, parse_item_library_entry_extra_file_paths) +{ + auto content = QString{R"xy( + MetaInfo { + Type { + name: "QtQuick.Controls.Frame" + + ItemLibraryEntry { + name: "Frame" + + ExtraFile{ source: "templates/frame.png" } + ExtraFile{ source: "templates/frame.frag" } + } + } + Type { + name: "QtQuick.Item" + + ItemLibraryEntry { + name: "Item" + + ExtraFile{ source: "templates/item.png" } + } + } + })xy"}; + QmlDesigner::Storage::TypeTraits traits; + + auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId); + + ASSERT_THAT(annotations, + ElementsAre(IsTypeAnnotation(sourceId, + "Frame", + moduleId("QtQuick.Controls"), + {}, + traits, + IsEmpty(), + StrippedStringEq(R"xy([ + {"extraFilePaths":["/path/templates/frame.png", "/path/templates/frame.frag"], + "name":"Frame"}] + )xy")), + IsTypeAnnotation(sourceId, + "Item", + moduleId("QtQuick"), + {}, + traits, + IsEmpty(), + StrippedStringEq(R"xy([ + {"extraFilePaths":["/path/templates/item.png"], + "name":"Item"}] + )xy")))); +} + +} // namespace