QmlDesigner: Use directory source id for project data

There are qml directories without a qmldir. To identify them we use the
directory source id instead of the qmldir source id.

Task-number: QDS-9345
Change-Id: I4ed4596a21576e6bbd18c5117753669ef8a68a28
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Marco Bubke
2023-03-02 13:33:46 +01:00
parent 583bb87c6a
commit f0fde39b0b
3 changed files with 156 additions and 136 deletions

View File

@@ -289,7 +289,8 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
QmlDirParser parser; QmlDirParser parser;
parser.parse(m_fileSystem.contentAsQString(QString{qmldirSourcePath})); parser.parse(m_fileSystem.contentAsQString(QString{qmldirSourcePath}));
package.updatedSourceIds.push_back(qmlDirSourceId); if (qmldirState == FileState::Changed)
package.updatedSourceIds.push_back(qmlDirSourceId);
Utils::PathString moduleName{parser.typeNamespace()}; Utils::PathString moduleName{parser.typeNamespace()};
ModuleId moduleId = m_projectStorage.moduleId(moduleName); ModuleId moduleId = m_projectStorage.moduleId(moduleName);
@@ -305,7 +306,7 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
m_projectStorage); m_projectStorage);
package.updatedModuleIds.push_back(moduleId); package.updatedModuleIds.push_back(moduleId);
const auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(qmlDirSourceId); const auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
addSourceIds(package.updatedSourceIds, qmlProjectDatas); addSourceIds(package.updatedSourceIds, qmlProjectDatas);
addSourceIds(package.updatedFileStatusSourceIds, qmlProjectDatas); addSourceIds(package.updatedFileStatusSourceIds, qmlProjectDatas);
@@ -315,7 +316,7 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
parseTypeInfos(qmlTypes, parseTypeInfos(qmlTypes,
filterMultipleEntries(parser.dependencies()), filterMultipleEntries(parser.dependencies()),
imports, imports,
qmlDirSourceId, directorySourceId,
directoryPath, directoryPath,
cppModuleId, cppModuleId,
package, package,
@@ -325,16 +326,16 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
} }
parseQmlComponents( parseQmlComponents(
createComponents(parser.components(), moduleId, pathModuleId, m_fileSystem, directory), createComponents(parser.components(), moduleId, pathModuleId, m_fileSystem, directory),
qmlDirSourceId, directorySourceId,
directoryId, directoryId,
package, package,
notUpdatedFileStatusSourceIds, notUpdatedFileStatusSourceIds,
watchedQmlSourceIds); watchedQmlSourceIds);
package.updatedProjectSourceIds.push_back(qmlDirSourceId); package.updatedProjectSourceIds.push_back(directorySourceId);
break; break;
} }
case FileState::NotChanged: { case FileState::NotChanged: {
parseProjectDatas(m_projectStorage.fetchProjectDatas(qmlDirSourceId), parseProjectDatas(m_projectStorage.fetchProjectDatas(directorySourceId),
package, package,
notUpdatedFileStatusSourceIds, notUpdatedFileStatusSourceIds,
notUpdatedSourceIds, notUpdatedSourceIds,
@@ -343,7 +344,7 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
} }
case FileState::NotExists: { case FileState::NotExists: {
package.updatedSourceIds.push_back(qmlDirSourceId); package.updatedSourceIds.push_back(qmlDirSourceId);
auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(qmlDirSourceId); auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
for (const Storage::Synchronization::ProjectData &projectData : qmlProjectDatas) { for (const Storage::Synchronization::ProjectData &projectData : qmlProjectDatas) {
package.updatedSourceIds.push_back(projectData.sourceId); package.updatedSourceIds.push_back(projectData.sourceId);
} }
@@ -362,7 +363,7 @@ void ProjectStorageUpdater::pathsChanged(const SourceIds &) {}
void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos, void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
const QList<QmlDirParser::Import> &qmldirDependencies, const QList<QmlDirParser::Import> &qmldirDependencies,
const QList<QmlDirParser::Import> &qmldirImports, const QList<QmlDirParser::Import> &qmldirImports,
SourceId qmldirSourceId, SourceId directorySourceId,
Utils::SmallStringView directoryPath, Utils::SmallStringView directoryPath,
ModuleId moduleId, ModuleId moduleId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
@@ -384,7 +385,7 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
package.updatedModuleDependencySourceIds.push_back(sourceId); package.updatedModuleDependencySourceIds.push_back(sourceId);
auto projectData = package.projectDatas.emplace_back( auto projectData = package.projectDatas.emplace_back(
qmldirSourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes); directorySourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes);
parseTypeInfo(projectData, parseTypeInfo(projectData,
qmltypesPath, qmltypesPath,
@@ -459,7 +460,7 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Projec
void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFilePath, void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFilePath,
Utils::SmallStringView directoryPath, Utils::SmallStringView directoryPath,
Storage::Synchronization::ExportedTypes exportedTypes, Storage::Synchronization::ExportedTypes exportedTypes,
SourceId qmldirSourceId, SourceId directorySourceId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
SourceIds &watchedQmlSourceIds) SourceIds &watchedQmlSourceIds)
@@ -490,7 +491,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
break; break;
} }
package.projectDatas.emplace_back(qmldirSourceId, package.projectDatas.emplace_back(directorySourceId,
sourceId, sourceId,
ModuleId{}, ModuleId{},
Storage::Synchronization::FileType::QmlDocument); Storage::Synchronization::FileType::QmlDocument);
@@ -571,7 +572,7 @@ Storage::Synchronization::ExportedTypes createExportedTypes(ProjectStorageUpdate
} // namespace } // namespace
void ProjectStorageUpdater::parseQmlComponents(Components components, void ProjectStorageUpdater::parseQmlComponents(Components components,
SourceId qmldirSourceId, SourceId directorySourceId,
SourceContextId directoryId, SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
@@ -589,7 +590,7 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
parseQmlComponent(fileName, parseQmlComponent(fileName,
directoryPath, directoryPath,
createExportedTypes(componentsWithSameFileName), createExportedTypes(componentsWithSameFileName),
qmldirSourceId, directorySourceId,
package, package,
notUpdatedFileStatusSourceIds, notUpdatedFileStatusSourceIds,
watchedQmlSourceIds); watchedQmlSourceIds);

View File

@@ -113,7 +113,7 @@ private:
void parseTypeInfos(const QStringList &typeInfos, void parseTypeInfos(const QStringList &typeInfos,
const QList<QmlDirParser::Import> &qmldirDependencies, const QList<QmlDirParser::Import> &qmldirDependencies,
const QList<QmlDirParser::Import> &qmldirImports, const QList<QmlDirParser::Import> &qmldirImports,
SourceId qmldirSourceId, SourceId directorySourceId,
Utils::SmallStringView directoryPath, Utils::SmallStringView directoryPath,
ModuleId moduleId, ModuleId moduleId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
@@ -131,7 +131,7 @@ private:
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
SourceIds &notUpdatedSourceIds); SourceIds &notUpdatedSourceIds);
void parseQmlComponents(Components components, void parseQmlComponents(Components components,
SourceId qmldirSourceId, SourceId directorySourceId,
SourceContextId directoryId, SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
@@ -139,7 +139,7 @@ private:
void parseQmlComponent(Utils::SmallStringView fileName, void parseQmlComponent(Utils::SmallStringView fileName,
Utils::SmallStringView directory, Utils::SmallStringView directory,
Storage::Synchronization::ExportedTypes exportedTypes, Storage::Synchronization::ExportedTypes exportedTypes,
SourceId qmldirSourceId, SourceId directorySourceId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
SourceIds &watchedQmlSourceIds); SourceIds &watchedQmlSourceIds);

View File

@@ -349,9 +349,9 @@ TEST_F(ProjectStorageUpdater, GetContentForQmlDirPathsIfFileStatusIsDifferent)
TEST_F(ProjectStorageUpdater, RequestFileStatusFromFileSystem) TEST_F(ProjectStorageUpdater, RequestFileStatusFromFileSystem)
{ {
EXPECT_CALL(fileSystemMock, fileStatus(Ne(qmlDirPathSourceId))).Times(AnyNumber()); EXPECT_CALL(fileSystemMock, fileStatus(Ne(directoryPathSourceId))).Times(AnyNumber());
EXPECT_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId))); EXPECT_CALL(fileSystemMock, fileStatus(Eq(directoryPathSourceId)));
updater.update(directories, {}); updater.update(directories, {});
} }
@@ -447,12 +447,12 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes)
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421),
IsFileStatus(qmltypesPathSourceId, 21, 421))), IsFileStatus(qmltypesPathSourceId, 21, 421))),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId, UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmltypesPathSourceId, qmltypesPathSourceId,
exampleCppNativeModuleId, exampleCppNativeModuleId,
FileType::QmlTypes))), FileType::QmlTypes))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId))))); UnorderedElementsAre(directoryPathSourceId)))));
updater.update(directories, {}); updater.update(directories, {});
} }
@@ -599,15 +599,20 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
IsFileStatus(qmlDocumentSourceId2, 22, 13), IsFileStatus(qmlDocumentSourceId2, 22, 13),
IsFileStatus(qmlDocumentSourceId3, 22, 14))), IsFileStatus(qmlDocumentSourceId3, 22, 14))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre( UnorderedElementsAre(IsProjectData(directoryPathSourceId,
IsProjectData(qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument), qmlDocumentSourceId1,
IsProjectData(qmlDirPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument), ModuleId{},
IsProjectData(qmlDirPathSourceId, FileType::QmlDocument),
qmlDocumentSourceId3, IsProjectData(directoryPathSourceId,
ModuleId{}, qmlDocumentSourceId2,
FileType::QmlDocument)))))); ModuleId{},
FileType::QmlDocument),
IsProjectData(directoryPathSourceId,
qmlDocumentSourceId3,
ModuleId{},
FileType::QmlDocument))))));
updater.update(directories, {}); updater.update(directories, {});
} }
@@ -621,6 +626,10 @@ TEST_F(ProjectStorageUpdater, SynchronizeAddOnlyQmlDocumentInDirectory)
.WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2}));
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml", "First2.qml"})); .WillByDefault(Return(QStringList{"First.qml", "First2.qml"}));
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId)))
.WillByDefault(Return(FileStatus{qmlDirPathSourceId, 21, 421}));
ON_CALL(projectStorageMock, fetchFileStatus(Eq(directoryPathSourceId)))
.WillByDefault(Return(FileStatus{directoryPathSourceId, 21, 421}));
EXPECT_CALL(projectStorageMock, EXPECT_CALL(projectStorageMock,
synchronize(AllOf( synchronize(AllOf(
@@ -643,24 +652,25 @@ TEST_F(ProjectStorageUpdater, SynchronizeAddOnlyQmlDocumentInDirectory)
Storage::Synchronization::ChangeLevel::Full), Storage::Synchronization::ChangeLevel::Full),
Field(&Storage::Synchronization::Type::exportedTypes, Field(&Storage::Synchronization::Type::exportedTypes,
UnorderedElementsAre( UnorderedElementsAre(
IsExportedType(pathModuleId, "First2", -1, -1))))))/*, IsExportedType(pathModuleId, "First2", -1, -1)))))),
Field(&SynchronizationPackage::updatedSourceIds, Field(&SynchronizationPackage::updatedSourceIds,
UnorderedElementsAre(qmlDocumentSourceId1, qmlDocumentSourceId2)), UnorderedElementsAre(qmlDocumentSourceId1, qmlDocumentSourceId2)),
Field(&SynchronizationPackage::updatedFileStatusSourceIds, Field(&SynchronizationPackage::updatedFileStatusSourceIds,
UnorderedElementsAre(qmlDocumentSourceId2)), UnorderedElementsAre(directoryPathSourceId, qmlDocumentSourceId2)),
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDocumentSourceId2, 22, 13))), UnorderedElementsAre(IsFileStatus(qmlDocumentSourceId2, 22, 13),
IsFileStatus(directoryPathSourceId, 2, 421))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId, UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDocumentSourceId1, qmlDocumentSourceId1,
ModuleId{}, ModuleId{},
FileType::QmlDocument), FileType::QmlDocument),
IsProjectData(qmlDirPathSourceId, IsProjectData(directoryPathSourceId,
qmlDocumentSourceId2, qmlDocumentSourceId2,
ModuleId{}, ModuleId{},
FileType::QmlDocument)))*/))); FileType::QmlDocument))))));
updater.update(directories, {}); updater.update(directories, {});
} }
@@ -680,11 +690,11 @@ TEST_F(ProjectStorageUpdater, SynchronizeRemovesQmlDocument)
.WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2}));
ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId3))) ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId3)))
.WillByDefault(Return(FileStatus{qmlDocumentSourceId3, -1, -1})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId3, -1, -1}));
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId3, ModuleId{}, FileType::QmlDocument}})); {directoryPathSourceId, qmlDocumentSourceId3, ModuleId{}, FileType::QmlDocument}}));
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml", "First2.qml"})); .WillByDefault(Return(QStringList{"First.qml", "First2.qml"}));
@@ -721,13 +731,13 @@ TEST_F(ProjectStorageUpdater, SynchronizeRemovesQmlDocument)
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId, UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDocumentSourceId1, qmlDocumentSourceId1,
ModuleId{}, ModuleId{},
FileType::QmlDocument), FileType::QmlDocument),
IsProjectData(qmlDirPathSourceId, IsProjectData(directoryPathSourceId,
qmlDocumentSourceId2, qmlDocumentSourceId2,
ModuleId{}, ModuleId{},
FileType::QmlDocument)))))); FileType::QmlDocument))))));
@@ -747,10 +757,10 @@ TEST_F(ProjectStorageUpdater, SynchronizeRemovesQmlDocumentInQmldirOnly)
.WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2}));
ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId2))) ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId2)))
.WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2}));
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}})); {directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}));
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml", "First2.qml"})); .WillByDefault(Return(QStringList{"First.qml", "First2.qml"}));
@@ -782,13 +792,13 @@ TEST_F(ProjectStorageUpdater, SynchronizeRemovesQmlDocumentInQmldirOnly)
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId, UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDocumentSourceId1, qmlDocumentSourceId1,
ModuleId{}, ModuleId{},
FileType::QmlDocument), FileType::QmlDocument),
IsProjectData(qmlDirPathSourceId, IsProjectData(directoryPathSourceId,
qmlDocumentSourceId2, qmlDocumentSourceId2,
ModuleId{}, ModuleId{},
FileType::QmlDocument)))))); FileType::QmlDocument))))));
@@ -809,10 +819,10 @@ TEST_F(ProjectStorageUpdater, SynchronizeAddQmlDocumentToQmldir)
.WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2}));
ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId2))) ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId2)))
.WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2}));
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}})); {directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}));
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml", "First2.qml"})); .WillByDefault(Return(QStringList{"First.qml", "First2.qml"}));
@@ -846,13 +856,13 @@ TEST_F(ProjectStorageUpdater, SynchronizeAddQmlDocumentToQmldir)
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId, UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDocumentSourceId1, qmlDocumentSourceId1,
ModuleId{}, ModuleId{},
FileType::QmlDocument), FileType::QmlDocument),
IsProjectData(qmlDirPathSourceId, IsProjectData(directoryPathSourceId,
qmlDocumentSourceId2, qmlDocumentSourceId2,
ModuleId{}, ModuleId{},
FileType::QmlDocument)))))); FileType::QmlDocument))))));
@@ -872,10 +882,10 @@ TEST_F(ProjectStorageUpdater, SynchronizeAddQmlDocumentToDirectory)
.WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId1, 22, 2}));
ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId2))) ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId2)))
.WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2})); .WillByDefault(Return(FileStatus{qmlDocumentSourceId2, 22, 2}));
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}})); {directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}));
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml", "First2.qml"})); .WillByDefault(Return(QStringList{"First.qml", "First2.qml"}));
@@ -907,13 +917,13 @@ TEST_F(ProjectStorageUpdater, SynchronizeAddQmlDocumentToDirectory)
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 422))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId, UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDocumentSourceId1, qmlDocumentSourceId1,
ModuleId{}, ModuleId{},
FileType::QmlDocument), FileType::QmlDocument),
IsProjectData(qmlDirPathSourceId, IsProjectData(directoryPathSourceId,
qmlDocumentSourceId2, qmlDocumentSourceId2,
ModuleId{}, ModuleId{},
FileType::QmlDocument)))))); FileType::QmlDocument))))));
@@ -974,15 +984,20 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsDontUpdateIfUpToDate)
Field(&SynchronizationPackage::updatedFileStatusSourceIds, Field(&SynchronizationPackage::updatedFileStatusSourceIds,
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2)), UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2)),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre( UnorderedElementsAre(IsProjectData(directoryPathSourceId,
IsProjectData(qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument), qmlDocumentSourceId1,
IsProjectData(qmlDirPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument), ModuleId{},
IsProjectData(qmlDirPathSourceId, FileType::QmlDocument),
qmlDocumentSourceId3, IsProjectData(directoryPathSourceId,
ModuleId{}, qmlDocumentSourceId2,
FileType::QmlDocument)))))); ModuleId{},
FileType::QmlDocument),
IsProjectData(directoryPathSourceId,
qmlDocumentSourceId3,
ModuleId{},
FileType::QmlDocument))))));
updater.update(directories, {}); updater.update(directories, {});
} }
@@ -1002,10 +1017,10 @@ TEST_F(ProjectStorageUpdater, UpdateQmldirDocuments)
TEST_F(ProjectStorageUpdater, AddSourceIdForForInvalidDirectoryFileStatus) TEST_F(ProjectStorageUpdater, AddSourceIdForForInvalidDirectoryFileStatus)
{ {
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes},
{qmlDirPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}})); {directoryPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}));
ON_CALL(fileSystemMock, fileStatus(Eq(directoryPathSourceId))).WillByDefault(Return(FileStatus{})); ON_CALL(fileSystemMock, fileStatus(Eq(directoryPathSourceId))).WillByDefault(Return(FileStatus{}));
ON_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId))).WillByDefault(Return(FileStatus{})); ON_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId))).WillByDefault(Return(FileStatus{}));
@@ -1024,12 +1039,12 @@ TEST_F(ProjectStorageUpdater, AddSourceIdForForInvalidDirectoryFileStatus)
TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged) TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged)
{ {
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes},
{qmlDirPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes},
{qmlDirPathSourceId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}})); {directoryPathSourceId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}));
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId)))
.WillByDefault(Return(FileStatus{qmlDirPathSourceId, 21, 421})); .WillByDefault(Return(FileStatus{qmlDirPathSourceId, 21, 421}));
@@ -1076,12 +1091,12 @@ TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged)
TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChangedAndSomeUpdatedFiles) TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChangedAndSomeUpdatedFiles)
{ {
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
.WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{ .WillByDefault(Return(QmlDesigner::Storage::Synchronization::ProjectDatas{
{qmlDirPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes},
{qmlDirPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes},
{qmlDirPathSourceId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathSourceId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument},
{qmlDirPathSourceId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}})); {directoryPathSourceId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}));
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId))) ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId)))
.WillByDefault(Return(FileStatus{qmlDirPathSourceId, 21, 421})); .WillByDefault(Return(FileStatus{qmlDirPathSourceId, 21, 421}));
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmltypes2PathSourceId))) ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmltypes2PathSourceId)))
@@ -1191,34 +1206,36 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithDifferentVersionButSame
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml"})); .WillByDefault(Return(QStringList{"First.qml"}));
EXPECT_CALL( EXPECT_CALL(projectStorageMock,
projectStorageMock, synchronize(
synchronize(AllOf( AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)), Field(&SynchronizationPackage::types,
Field(&SynchronizationPackage::types, UnorderedElementsAre(AllOf(
UnorderedElementsAre(AllOf( IsStorageType("First.qml",
IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"},
Storage::Synchronization::ImportedType{"Object"}, TypeTraits::Reference,
TypeTraits::Reference, qmlDocumentSourceId1,
qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full),
Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes,
Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0), IsExportedType(exampleModuleId, "FirstType", 1, 0),
IsExportedType(exampleModuleId, "FirstType", 1, 1), IsExportedType(exampleModuleId, "FirstType", 1, 1),
IsExportedType(exampleModuleId, "FirstType", 6, 0), IsExportedType(exampleModuleId, "FirstType", 6, 0),
IsExportedType(pathModuleId, "First", -1, -1)))))), IsExportedType(pathModuleId, "First", -1, -1)))))),
Field(&SynchronizationPackage::updatedSourceIds, Field(&SynchronizationPackage::updatedSourceIds,
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)), UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
Field(&SynchronizationPackage::updatedFileStatusSourceIds, Field(&SynchronizationPackage::updatedFileStatusSourceIds,
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)), UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421),
IsFileStatus(qmlDocumentSourceId1, 22, 12))), IsFileStatus(qmlDocumentSourceId1, 22, 12))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData( UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument)))))); qmlDocumentSourceId1,
ModuleId{},
FileType::QmlDocument))))));
updater.update(directories, {}); updater.update(directories, {});
} }
@@ -1232,33 +1249,35 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithDifferentTypeNameButSam
ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path")))) ON_CALL(fileSystemMock, qmlFileNames(Eq(QString("/path"))))
.WillByDefault(Return(QStringList{"First.qml"})); .WillByDefault(Return(QStringList{"First.qml"}));
EXPECT_CALL( EXPECT_CALL(projectStorageMock,
projectStorageMock, synchronize(
synchronize(AllOf( AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)), Field(&SynchronizationPackage::types,
Field(&SynchronizationPackage::types, UnorderedElementsAre(AllOf(
UnorderedElementsAre(AllOf( IsStorageType("First.qml",
IsStorageType("First.qml", Storage::Synchronization::ImportedType{"Object"},
Storage::Synchronization::ImportedType{"Object"}, TypeTraits::Reference,
TypeTraits::Reference, qmlDocumentSourceId1,
qmlDocumentSourceId1, Storage::Synchronization::ChangeLevel::Full),
Storage::Synchronization::ChangeLevel::Full), Field(&Storage::Synchronization::Type::exportedTypes,
Field(&Storage::Synchronization::Type::exportedTypes, UnorderedElementsAre(
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0), IsExportedType(exampleModuleId, "FirstType", 1, 0),
IsExportedType(exampleModuleId, "FirstType2", 1, 0), IsExportedType(exampleModuleId, "FirstType2", 1, 0),
IsExportedType(pathModuleId, "First", -1, -1)))))), IsExportedType(pathModuleId, "First", -1, -1)))))),
Field(&SynchronizationPackage::updatedSourceIds, Field(&SynchronizationPackage::updatedSourceIds,
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)), UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
Field(&SynchronizationPackage::updatedFileStatusSourceIds, Field(&SynchronizationPackage::updatedFileStatusSourceIds,
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)), UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
Field(&SynchronizationPackage::fileStatuses, Field(&SynchronizationPackage::fileStatuses,
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421), UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421),
IsFileStatus(qmlDocumentSourceId1, 22, 12))), IsFileStatus(qmlDocumentSourceId1, 22, 12))),
Field(&SynchronizationPackage::updatedProjectSourceIds, Field(&SynchronizationPackage::updatedProjectSourceIds,
UnorderedElementsAre(qmlDirPathSourceId)), UnorderedElementsAre(directoryPathSourceId)),
Field(&SynchronizationPackage::projectDatas, Field(&SynchronizationPackage::projectDatas,
UnorderedElementsAre(IsProjectData( UnorderedElementsAre(IsProjectData(directoryPathSourceId,
qmlDirPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument)))))); qmlDocumentSourceId1,
ModuleId{},
FileType::QmlDocument))))));
updater.update(directories, {}); updater.update(directories, {});
} }