forked from qt-creator/qt-creator
QmlDesigner: Concat source ids into one struct
SourceIdsData is reducing the parameter count and later shares the initialization the watcher notifier. Task-number: QDS-9479 Change-Id: I30fca678a857821a376906071d6c219c4dd2e4b7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -60,11 +60,11 @@ ProjectStorageUpdater::Components createComponents(
|
|||||||
ModuleId moduleId,
|
ModuleId moduleId,
|
||||||
ModuleId pathModuleId,
|
ModuleId pathModuleId,
|
||||||
FileSystemInterface &fileSystem,
|
FileSystemInterface &fileSystem,
|
||||||
const QString &directory)
|
const Utils::PathString &directory)
|
||||||
{
|
{
|
||||||
ProjectStorageUpdater::Components components;
|
ProjectStorageUpdater::Components components;
|
||||||
|
|
||||||
auto qmlFileNames = fileSystem.qmlFileNames(directory);
|
auto qmlFileNames = fileSystem.qmlFileNames(QString{directory});
|
||||||
|
|
||||||
components.reserve(static_cast<std::size_t>(qmlDirParserComponents.size() + qmlFileNames.size()));
|
components.reserve(static_cast<std::size_t>(qmlDirParserComponents.size() + qmlFileNames.size()));
|
||||||
|
|
||||||
@@ -166,53 +166,34 @@ void ProjectStorageUpdater::update(QStringList directories,
|
|||||||
ProjectPartId projectPartId)
|
ProjectPartId projectPartId)
|
||||||
{
|
{
|
||||||
Storage::Synchronization::SynchronizationPackage package;
|
Storage::Synchronization::SynchronizationPackage package;
|
||||||
|
SourceIdsData sourceIdsData{static_cast<std::size_t>(directories.size())};
|
||||||
SourceIds notUpdatedFileStatusSourceIds;
|
|
||||||
SourceIds notUpdatedSourceIds;
|
|
||||||
std::vector<IdPaths> idPaths;
|
std::vector<IdPaths> idPaths;
|
||||||
idPaths.reserve(2);
|
idPaths.reserve(4);
|
||||||
SourceIds watchedDirectorySourceIds;
|
|
||||||
watchedDirectorySourceIds.reserve(directories.size());
|
|
||||||
SourceIds watchedQmldirSourceIds;
|
|
||||||
watchedQmldirSourceIds.reserve(directories.size());
|
|
||||||
SourceIds watchedQmlSourceIds;
|
|
||||||
watchedQmldirSourceIds.reserve(directories.size() * 100);
|
|
||||||
SourceIds watchedQmltypesSourceIds;
|
|
||||||
watchedQmltypesSourceIds.reserve(directories.size());
|
|
||||||
|
|
||||||
updateDirectories(directories,
|
updateDirectories(directories, package, sourceIdsData);
|
||||||
package,
|
updateQmlTypes(qmlTypesPaths, package, sourceIdsData);
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds,
|
|
||||||
watchedDirectorySourceIds,
|
|
||||||
watchedQmldirSourceIds,
|
|
||||||
watchedQmlSourceIds,
|
|
||||||
watchedQmltypesSourceIds);
|
|
||||||
updateQmlTypes(qmlTypesPaths,
|
|
||||||
package,
|
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds,
|
|
||||||
watchedQmltypesSourceIds);
|
|
||||||
|
|
||||||
package.updatedSourceIds = filterNotUpdatedSourceIds(std::move(package.updatedSourceIds),
|
package.updatedSourceIds = filterNotUpdatedSourceIds(std::move(package.updatedSourceIds),
|
||||||
std::move(notUpdatedSourceIds));
|
std::move(sourceIdsData.notUpdatedSourceIds));
|
||||||
package.updatedFileStatusSourceIds = filterNotUpdatedSourceIds(
|
package.updatedFileStatusSourceIds = filterNotUpdatedSourceIds(
|
||||||
std::move(package.updatedFileStatusSourceIds), std::move(notUpdatedFileStatusSourceIds));
|
std::move(package.updatedFileStatusSourceIds),
|
||||||
|
std::move(sourceIdsData.notUpdatedFileStatusSourceIds));
|
||||||
|
|
||||||
m_projectStorage.synchronize(std::move(package));
|
m_projectStorage.synchronize(std::move(package));
|
||||||
|
|
||||||
idPaths.push_back({projectPartId, SourceType::Directory, std::move(watchedDirectorySourceIds)});
|
idPaths.push_back(
|
||||||
idPaths.push_back({projectPartId, SourceType::QmlDir, std::move(watchedQmldirSourceIds)});
|
{projectPartId, SourceType::Directory, std::move(sourceIdsData.watchedDirectorySourceIds)});
|
||||||
idPaths.push_back({projectPartId, SourceType::Qml, std::move(watchedQmlSourceIds)});
|
idPaths.push_back(
|
||||||
idPaths.push_back({projectPartId, SourceType::QmlTypes, std::move(watchedQmltypesSourceIds)});
|
{projectPartId, SourceType::QmlDir, std::move(sourceIdsData.watchedQmldirSourceIds)});
|
||||||
|
idPaths.push_back({projectPartId, SourceType::Qml, std::move(sourceIdsData.watchedQmlSourceIds)});
|
||||||
|
idPaths.push_back(
|
||||||
|
{projectPartId, SourceType::QmlTypes, std::move(sourceIdsData.watchedQmltypesSourceIds)});
|
||||||
m_pathWatcher.updateIdPaths(idPaths);
|
m_pathWatcher.updateIdPaths(idPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
|
void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdsData)
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmltypesSourceIds)
|
|
||||||
{
|
{
|
||||||
if (qmlTypesPaths.empty())
|
if (qmlTypesPaths.empty())
|
||||||
return;
|
return;
|
||||||
@@ -221,7 +202,7 @@ void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
|
|||||||
|
|
||||||
for (const QString &qmlTypesPath : qmlTypesPaths) {
|
for (const QString &qmlTypesPath : qmlTypesPaths) {
|
||||||
SourceId sourceId = m_pathCache.sourceId(SourcePath{qmlTypesPath});
|
SourceId sourceId = m_pathCache.sourceId(SourcePath{qmlTypesPath});
|
||||||
watchedQmltypesSourceIds.push_back(sourceId);
|
sourceIdsData.watchedQmltypesSourceIds.push_back(sourceId);
|
||||||
|
|
||||||
Storage::Synchronization::ProjectData projectData{sourceId,
|
Storage::Synchronization::ProjectData projectData{sourceId,
|
||||||
sourceId,
|
sourceId,
|
||||||
@@ -231,8 +212,7 @@ void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
|
|||||||
FileState state = parseTypeInfo(projectData,
|
FileState state = parseTypeInfo(projectData,
|
||||||
Utils::PathString{qmlTypesPath},
|
Utils::PathString{qmlTypesPath},
|
||||||
package,
|
package,
|
||||||
notUpdatedFileStatusSourceIds,
|
sourceIdsData);
|
||||||
notUpdatedSourceIds);
|
|
||||||
|
|
||||||
if (state == FileState::Changed)
|
if (state == FileState::Changed)
|
||||||
package.projectDatas.push_back(std::move(projectData));
|
package.projectDatas.push_back(std::move(projectData));
|
||||||
@@ -255,116 +235,99 @@ ProjectStorageUpdater::FileState combineState(FileStates... fileStates)
|
|||||||
|
|
||||||
void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
|
void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdsData)
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedDirectorySourceIds,
|
|
||||||
SourceIds &watchedQmldirSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
SourceIds &watchedQmltypesSourceIds)
|
|
||||||
{
|
{
|
||||||
|
for (const QString &directory : directories)
|
||||||
|
updateDirectory({directory}, package, sourceIdsData);
|
||||||
|
}
|
||||||
|
|
||||||
for (const QString &directory : directories) {
|
void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPath,
|
||||||
Utils::PathString directoryPath = directory;
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourcePath qmldirSourcePath{directory + "/qmldir"};
|
SourceIdsData &sourceIdsData)
|
||||||
auto [directoryId, qmlDirSourceId] = m_pathCache.sourceContextAndSourceId(qmldirSourcePath);
|
{
|
||||||
|
SourcePath qmldirSourcePath{directoryPath + "/qmldir"};
|
||||||
|
auto [directoryId, qmlDirSourceId] = m_pathCache.sourceContextAndSourceId(qmldirSourcePath);
|
||||||
|
|
||||||
SourcePath directorySourcePath{directory + "/."};
|
SourcePath directorySourcePath{directoryPath + "/."};
|
||||||
auto directorySourceId = m_pathCache.sourceId(directorySourcePath);
|
auto directorySourceId = m_pathCache.sourceId(directorySourcePath);
|
||||||
auto directoryState = fileState(directorySourceId,
|
auto directoryState = fileState(directorySourceId, package, sourceIdsData);
|
||||||
package.fileStatuses,
|
if (directoryState != FileState::NotExists)
|
||||||
package.updatedFileStatusSourceIds,
|
sourceIdsData.watchedDirectorySourceIds.push_back(directorySourceId);
|
||||||
notUpdatedFileStatusSourceIds);
|
|
||||||
if (directoryState != FileState::NotExists)
|
|
||||||
watchedDirectorySourceIds.push_back(directorySourceId);
|
|
||||||
|
|
||||||
auto qmldirState = fileState(qmlDirSourceId,
|
auto qmldirState = fileState(qmlDirSourceId, package, sourceIdsData);
|
||||||
package.fileStatuses,
|
if (qmldirState != FileState::NotExists)
|
||||||
package.updatedFileStatusSourceIds,
|
sourceIdsData.watchedQmldirSourceIds.push_back(qmlDirSourceId);
|
||||||
notUpdatedFileStatusSourceIds);
|
|
||||||
|
switch (combineState(directoryState, qmldirState)) {
|
||||||
|
case FileState::Changed: {
|
||||||
|
QmlDirParser parser;
|
||||||
if (qmldirState != FileState::NotExists)
|
if (qmldirState != FileState::NotExists)
|
||||||
watchedQmldirSourceIds.push_back(qmlDirSourceId);
|
parser.parse(m_fileSystem.contentAsQString(QString{qmldirSourcePath}));
|
||||||
|
|
||||||
switch (combineState(directoryState, qmldirState)) {
|
if (qmldirState != FileState::NotChanged)
|
||||||
case FileState::Changed: {
|
|
||||||
QmlDirParser parser;
|
|
||||||
if (qmldirState != FileState::NotExists)
|
|
||||||
parser.parse(m_fileSystem.contentAsQString(QString{qmldirSourcePath}));
|
|
||||||
|
|
||||||
if (qmldirState != FileState::NotChanged)
|
|
||||||
package.updatedSourceIds.push_back(qmlDirSourceId);
|
|
||||||
|
|
||||||
Utils::PathString moduleName{parser.typeNamespace()};
|
|
||||||
ModuleId moduleId = m_projectStorage.moduleId(moduleName);
|
|
||||||
ModuleId cppModuleId = m_projectStorage.moduleId(moduleName + "-cppnative");
|
|
||||||
ModuleId pathModuleId = m_projectStorage.moduleId(directoryPath);
|
|
||||||
|
|
||||||
auto imports = filterMultipleEntries(parser.imports());
|
|
||||||
|
|
||||||
addModuleExportedImports(package.moduleExportedImports,
|
|
||||||
moduleId,
|
|
||||||
cppModuleId,
|
|
||||||
imports,
|
|
||||||
m_projectStorage);
|
|
||||||
package.updatedModuleIds.push_back(moduleId);
|
|
||||||
|
|
||||||
const auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
|
|
||||||
addSourceIds(package.updatedSourceIds, qmlProjectDatas);
|
|
||||||
addSourceIds(package.updatedFileStatusSourceIds, qmlProjectDatas);
|
|
||||||
|
|
||||||
auto qmlTypes = filterMultipleEntries(parser.typeInfos());
|
|
||||||
|
|
||||||
if (!qmlTypes.isEmpty()) {
|
|
||||||
parseTypeInfos(qmlTypes,
|
|
||||||
filterMultipleEntries(parser.dependencies()),
|
|
||||||
imports,
|
|
||||||
directorySourceId,
|
|
||||||
directoryPath,
|
|
||||||
cppModuleId,
|
|
||||||
package,
|
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds,
|
|
||||||
watchedQmltypesSourceIds);
|
|
||||||
}
|
|
||||||
parseQmlComponents(
|
|
||||||
createComponents(parser.components(), moduleId, pathModuleId, m_fileSystem, directory),
|
|
||||||
directorySourceId,
|
|
||||||
directoryId,
|
|
||||||
package,
|
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds,
|
|
||||||
watchedQmlSourceIds,
|
|
||||||
qmldirState);
|
|
||||||
package.updatedProjectSourceIds.push_back(directorySourceId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FileState::NotChanged: {
|
|
||||||
parseProjectDatas(m_projectStorage.fetchProjectDatas(directorySourceId),
|
|
||||||
package,
|
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds,
|
|
||||||
watchedQmlSourceIds,
|
|
||||||
watchedQmltypesSourceIds);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FileState::NotExists: {
|
|
||||||
package.updatedFileStatusSourceIds.push_back(directorySourceId);
|
|
||||||
package.updatedFileStatusSourceIds.push_back(qmlDirSourceId);
|
|
||||||
package.updatedProjectSourceIds.push_back(directorySourceId);
|
|
||||||
package.updatedSourceIds.push_back(qmlDirSourceId);
|
package.updatedSourceIds.push_back(qmlDirSourceId);
|
||||||
auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
|
|
||||||
for (const Storage::Synchronization::ProjectData &projectData : qmlProjectDatas) {
|
|
||||||
package.updatedSourceIds.push_back(projectData.sourceId);
|
|
||||||
package.updatedFileStatusSourceIds.push_back(projectData.sourceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
Utils::PathString moduleName{parser.typeNamespace()};
|
||||||
|
ModuleId moduleId = m_projectStorage.moduleId(moduleName);
|
||||||
|
ModuleId cppModuleId = m_projectStorage.moduleId(moduleName + "-cppnative");
|
||||||
|
ModuleId pathModuleId = m_projectStorage.moduleId(directoryPath);
|
||||||
|
|
||||||
|
auto imports = filterMultipleEntries(parser.imports());
|
||||||
|
|
||||||
|
addModuleExportedImports(package.moduleExportedImports,
|
||||||
|
moduleId,
|
||||||
|
cppModuleId,
|
||||||
|
imports,
|
||||||
|
m_projectStorage);
|
||||||
|
package.updatedModuleIds.push_back(moduleId);
|
||||||
|
|
||||||
|
const auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
|
||||||
|
addSourceIds(package.updatedSourceIds, qmlProjectDatas);
|
||||||
|
addSourceIds(package.updatedFileStatusSourceIds, qmlProjectDatas);
|
||||||
|
|
||||||
|
auto qmlTypes = filterMultipleEntries(parser.typeInfos());
|
||||||
|
|
||||||
|
if (!qmlTypes.isEmpty()) {
|
||||||
|
parseTypeInfos(qmlTypes,
|
||||||
|
filterMultipleEntries(parser.dependencies()),
|
||||||
|
imports,
|
||||||
|
directorySourceId,
|
||||||
|
directoryPath,
|
||||||
|
cppModuleId,
|
||||||
|
package,
|
||||||
|
sourceIdsData);
|
||||||
}
|
}
|
||||||
|
parseQmlComponents(
|
||||||
|
createComponents(parser.components(), moduleId, pathModuleId, m_fileSystem, directoryPath),
|
||||||
|
directorySourceId,
|
||||||
|
directoryId,
|
||||||
|
package,
|
||||||
|
sourceIdsData,
|
||||||
|
qmldirState);
|
||||||
|
package.updatedProjectSourceIds.push_back(directorySourceId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FileState::NotChanged: {
|
||||||
|
parseProjectDatas(m_projectStorage.fetchProjectDatas(directorySourceId), package, sourceIdsData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FileState::NotExists: {
|
||||||
|
package.updatedFileStatusSourceIds.push_back(directorySourceId);
|
||||||
|
package.updatedFileStatusSourceIds.push_back(qmlDirSourceId);
|
||||||
|
package.updatedProjectSourceIds.push_back(directorySourceId);
|
||||||
|
package.updatedSourceIds.push_back(qmlDirSourceId);
|
||||||
|
auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
|
||||||
|
for (const Storage::Synchronization::ProjectData &projectData : qmlProjectDatas) {
|
||||||
|
package.updatedSourceIds.push_back(projectData.sourceId);
|
||||||
|
package.updatedFileStatusSourceIds.push_back(projectData.sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectStorageUpdater::pathsWithIdsChanged([[maybe_unused]] const std::vector<IdPaths> &idPaths)
|
void ProjectStorageUpdater::pathsWithIdsChanged([[maybe_unused]] const std::vector<IdPaths> &) {}
|
||||||
{}
|
|
||||||
|
|
||||||
void ProjectStorageUpdater::pathsChanged(const SourceIds &) {}
|
void ProjectStorageUpdater::pathsChanged(const SourceIds &) {}
|
||||||
|
|
||||||
@@ -375,16 +338,14 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
|
|||||||
Utils::SmallStringView directoryPath,
|
Utils::SmallStringView directoryPath,
|
||||||
ModuleId moduleId,
|
ModuleId moduleId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData)
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds)
|
|
||||||
{
|
{
|
||||||
for (const QString &typeInfo : typeInfos) {
|
for (const QString &typeInfo : typeInfos) {
|
||||||
Utils::PathString qmltypesPath = Utils::PathString::join(
|
Utils::PathString qmltypesPath = Utils::PathString::join(
|
||||||
{directoryPath, "/", Utils::SmallString{typeInfo}});
|
{directoryPath, "/", Utils::SmallString{typeInfo}});
|
||||||
SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmltypesPath});
|
SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmltypesPath});
|
||||||
|
|
||||||
watchedQmlSourceIds.push_back(sourceId);
|
sourceIdData.watchedQmltypesSourceIds.push_back(sourceId);
|
||||||
|
|
||||||
addDependencies(package.moduleDependencies,
|
addDependencies(package.moduleDependencies,
|
||||||
sourceId,
|
sourceId,
|
||||||
@@ -395,38 +356,27 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
|
|||||||
auto projectData = package.projectDatas.emplace_back(
|
auto projectData = package.projectDatas.emplace_back(
|
||||||
directorySourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes);
|
directorySourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes);
|
||||||
|
|
||||||
parseTypeInfo(projectData,
|
parseTypeInfo(projectData, qmltypesPath, package, sourceIdData);
|
||||||
qmltypesPath,
|
|
||||||
package,
|
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectStorageUpdater::parseProjectDatas(const Storage::Synchronization::ProjectDatas &projectDatas,
|
void ProjectStorageUpdater::parseProjectDatas(const Storage::Synchronization::ProjectDatas &projectDatas,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData)
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
SourceIds &watchedQmltypesSourceIds)
|
|
||||||
{
|
{
|
||||||
for (const Storage::Synchronization::ProjectData &projectData : projectDatas) {
|
for (const Storage::Synchronization::ProjectData &projectData : projectDatas) {
|
||||||
switch (projectData.fileType) {
|
switch (projectData.fileType) {
|
||||||
case Storage::Synchronization::FileType::QmlTypes: {
|
case Storage::Synchronization::FileType::QmlTypes: {
|
||||||
watchedQmltypesSourceIds.push_back(projectData.sourceId);
|
sourceIdData.watchedQmltypesSourceIds.push_back(projectData.sourceId);
|
||||||
|
|
||||||
auto qmltypesPath = m_pathCache.sourcePath(projectData.sourceId);
|
auto qmltypesPath = m_pathCache.sourcePath(projectData.sourceId);
|
||||||
parseTypeInfo(projectData,
|
parseTypeInfo(projectData, qmltypesPath, package, sourceIdData);
|
||||||
qmltypesPath,
|
|
||||||
package,
|
|
||||||
notUpdatedFileStatusSourceIds,
|
|
||||||
notUpdatedSourceIds);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Storage::Synchronization::FileType::QmlDocument: {
|
case Storage::Synchronization::FileType::QmlDocument: {
|
||||||
watchedQmlSourceIds.push_back(projectData.sourceId);
|
sourceIdData.watchedQmlSourceIds.push_back(projectData.sourceId);
|
||||||
|
|
||||||
parseQmlComponent(projectData.sourceId, package, notUpdatedFileStatusSourceIds);
|
parseQmlComponent(projectData.sourceId, package, sourceIdData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -435,13 +385,9 @@ void ProjectStorageUpdater::parseProjectDatas(const Storage::Synchronization::Pr
|
|||||||
auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::ProjectData &projectData,
|
auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::ProjectData &projectData,
|
||||||
Utils::SmallStringView qmltypesPath,
|
Utils::SmallStringView qmltypesPath,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData) -> FileState
|
||||||
SourceIds ¬UpdatedSourceIds) -> FileState
|
|
||||||
{
|
{
|
||||||
auto state = fileState(projectData.sourceId,
|
auto state = fileState(projectData.sourceId, package, sourceIdData);
|
||||||
package.fileStatuses,
|
|
||||||
package.updatedFileStatusSourceIds,
|
|
||||||
notUpdatedFileStatusSourceIds);
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case FileState::Changed: {
|
case FileState::Changed: {
|
||||||
package.updatedSourceIds.push_back(projectData.sourceId);
|
package.updatedSourceIds.push_back(projectData.sourceId);
|
||||||
@@ -451,7 +397,7 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Projec
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileState::NotChanged: {
|
case FileState::NotChanged: {
|
||||||
notUpdatedSourceIds.push_back(projectData.sourceId);
|
sourceIdData.notUpdatedSourceIds.push_back(projectData.sourceId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileState::NotExists:
|
case FileState::NotExists:
|
||||||
@@ -467,9 +413,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
|
|||||||
Storage::Synchronization::ExportedTypes exportedTypes,
|
Storage::Synchronization::ExportedTypes exportedTypes,
|
||||||
SourceId directorySourceId,
|
SourceId directorySourceId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData,
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
FileState qmldirState)
|
FileState qmldirState)
|
||||||
{
|
{
|
||||||
if (std::find(relativeFilePath.begin(), relativeFilePath.end(), '+') != relativeFilePath.end())
|
if (std::find(relativeFilePath.begin(), relativeFilePath.end(), '+') != relativeFilePath.end())
|
||||||
@@ -479,17 +423,14 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
|
|||||||
SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmlFilePath});
|
SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmlFilePath});
|
||||||
|
|
||||||
Storage::Synchronization::Type type;
|
Storage::Synchronization::Type type;
|
||||||
auto state = fileState(sourceId,
|
auto state = fileState(sourceId, package, sourceIdData);
|
||||||
package.fileStatuses,
|
|
||||||
package.updatedFileStatusSourceIds,
|
|
||||||
notUpdatedFileStatusSourceIds);
|
|
||||||
|
|
||||||
watchedQmlSourceIds.push_back(sourceId);
|
sourceIdData.watchedQmlSourceIds.push_back(sourceId);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case FileState::NotChanged:
|
case FileState::NotChanged:
|
||||||
if (qmldirState == FileState::NotExists) {
|
if (qmldirState == FileState::NotExists) {
|
||||||
notUpdatedSourceIds.emplace_back(sourceId);
|
sourceIdData.notUpdatedSourceIds.emplace_back(sourceId);
|
||||||
package.projectDatas.emplace_back(directorySourceId,
|
package.projectDatas.emplace_back(directorySourceId,
|
||||||
sourceId,
|
sourceId,
|
||||||
ModuleId{},
|
ModuleId{},
|
||||||
@@ -524,12 +465,9 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
|
|||||||
|
|
||||||
void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId,
|
void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds)
|
SourceIdsData &sourceIdData)
|
||||||
{
|
{
|
||||||
auto state = fileState(sourceId,
|
auto state = fileState(sourceId, package, sourceIdData);
|
||||||
package.fileStatuses,
|
|
||||||
package.updatedFileStatusSourceIds,
|
|
||||||
notUpdatedFileStatusSourceIds);
|
|
||||||
if (state != FileState::Changed)
|
if (state != FileState::Changed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -588,9 +526,7 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
|
|||||||
SourceId directorySourceId,
|
SourceId directorySourceId,
|
||||||
SourceContextId directoryId,
|
SourceContextId directoryId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdsData,
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
FileState qmldirState)
|
FileState qmldirState)
|
||||||
{
|
{
|
||||||
std::sort(components.begin(), components.end(), [](auto &&first, auto &&second) {
|
std::sort(components.begin(), components.end(), [](auto &&first, auto &&second) {
|
||||||
@@ -607,36 +543,34 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
|
|||||||
createExportedTypes(componentsWithSameFileName),
|
createExportedTypes(componentsWithSameFileName),
|
||||||
directorySourceId,
|
directorySourceId,
|
||||||
package,
|
package,
|
||||||
notUpdatedFileStatusSourceIds,
|
sourceIdsData,
|
||||||
notUpdatedSourceIds,
|
|
||||||
watchedQmlSourceIds,
|
|
||||||
qmldirState);
|
qmldirState);
|
||||||
};
|
};
|
||||||
|
|
||||||
rangeForTheSameFileName(components, callback);
|
rangeForTheSameFileName(components, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(SourceId sourceId,
|
ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(
|
||||||
FileStatuses &fileStatuses,
|
SourceId sourceId,
|
||||||
SourceIds &updatedSourceIds,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedSourceIds) const
|
SourceIdsData &sourceIdData) const
|
||||||
{
|
{
|
||||||
auto currentFileStatus = m_fileStatusCache.find(sourceId);
|
auto currentFileStatus = m_fileStatusCache.find(sourceId);
|
||||||
|
|
||||||
if (!currentFileStatus.isValid()) {
|
if (!currentFileStatus.isValid()) {
|
||||||
updatedSourceIds.push_back(sourceId);
|
package.updatedFileStatusSourceIds.push_back(sourceId);
|
||||||
return FileState::NotExists;
|
return FileState::NotExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto projectStorageFileStatus = m_projectStorage.fetchFileStatus(sourceId);
|
auto projectStorageFileStatus = m_projectStorage.fetchFileStatus(sourceId);
|
||||||
|
|
||||||
if (!projectStorageFileStatus.isValid() || projectStorageFileStatus != currentFileStatus) {
|
if (!projectStorageFileStatus.isValid() || projectStorageFileStatus != currentFileStatus) {
|
||||||
fileStatuses.push_back(currentFileStatus);
|
package.fileStatuses.push_back(currentFileStatus);
|
||||||
updatedSourceIds.push_back(sourceId);
|
package.updatedFileStatusSourceIds.push_back(sourceId);
|
||||||
return FileState::Changed;
|
return FileState::Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
notUpdatedSourceIds.push_back(sourceId);
|
sourceIdData.notUpdatedFileStatusSourceIds.push_back(sourceId);
|
||||||
return FileState::NotChanged;
|
return FileState::NotChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,19 +97,37 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct SourceIdsData
|
||||||
|
{
|
||||||
|
SourceIdsData(std::size_t reserve)
|
||||||
|
{
|
||||||
|
notUpdatedFileStatusSourceIds.reserve(reserve * 30);
|
||||||
|
notUpdatedSourceIds.reserve(reserve * 30);
|
||||||
|
watchedDirectorySourceIds.reserve(reserve);
|
||||||
|
watchedQmldirSourceIds.reserve(reserve);
|
||||||
|
watchedQmlSourceIds.reserve(reserve * 30);
|
||||||
|
watchedQmltypesSourceIds.reserve(reserve * 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceIds notUpdatedFileStatusSourceIds;
|
||||||
|
SourceIds notUpdatedSourceIds;
|
||||||
|
SourceIds watchedDirectorySourceIds;
|
||||||
|
SourceIds watchedQmldirSourceIds;
|
||||||
|
SourceIds watchedQmlSourceIds;
|
||||||
|
SourceIds watchedQmltypesSourceIds;
|
||||||
|
};
|
||||||
|
|
||||||
void updateQmlTypes(const QStringList &qmlTypesPaths,
|
void updateQmlTypes(const QStringList &qmlTypesPaths,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData);
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmltypesSourceIds);
|
|
||||||
void updateDirectories(const QStringList &directories,
|
void updateDirectories(const QStringList &directories,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData);
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedDirectorySourceIds,
|
void updateDirectory(const Utils::PathString &directory,
|
||||||
SourceIds &watchedQmldirSourceIds,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds &watchedQmlSourceIds,
|
SourceIdsData &sourceIdData);
|
||||||
SourceIds &watchedQmltypesSourceIds);
|
|
||||||
|
|
||||||
void parseTypeInfos(const QStringList &typeInfos,
|
void parseTypeInfos(const QStringList &typeInfos,
|
||||||
const QList<QmlDirParser::Import> &qmldirDependencies,
|
const QList<QmlDirParser::Import> &qmldirDependencies,
|
||||||
@@ -118,45 +136,34 @@ private:
|
|||||||
Utils::SmallStringView directoryPath,
|
Utils::SmallStringView directoryPath,
|
||||||
ModuleId moduleId,
|
ModuleId moduleId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData);
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds);
|
|
||||||
void parseProjectDatas(const Storage::Synchronization::ProjectDatas &projectDatas,
|
void parseProjectDatas(const Storage::Synchronization::ProjectDatas &projectDatas,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData);
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
SourceIds &watchedQmltypesSourceIds);
|
|
||||||
FileState parseTypeInfo(const Storage::Synchronization::ProjectData &projectData,
|
FileState parseTypeInfo(const Storage::Synchronization::ProjectData &projectData,
|
||||||
Utils::SmallStringView qmltypesPath,
|
Utils::SmallStringView qmltypesPath,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData);
|
||||||
SourceIds ¬UpdatedSourceIds);
|
|
||||||
void parseQmlComponents(Components components,
|
void parseQmlComponents(Components components,
|
||||||
SourceId directorySourceId,
|
SourceId directorySourceId,
|
||||||
SourceContextId directoryId,
|
SourceContextId directoryId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData,
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
FileState qmldirState);
|
FileState qmldirState);
|
||||||
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 directorySourceId,
|
SourceId directorySourceId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds,
|
SourceIdsData &sourceIdData,
|
||||||
SourceIds ¬UpdatedSourceIds,
|
|
||||||
SourceIds &watchedQmlSourceIds,
|
|
||||||
FileState qmldirState);
|
FileState qmldirState);
|
||||||
void parseQmlComponent(SourceId sourceId,
|
void parseQmlComponent(SourceId sourceId,
|
||||||
Storage::Synchronization::SynchronizationPackage &package,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds ¬UpdatedFileStatusSourceIds);
|
SourceIdsData &sourceIdData);
|
||||||
|
|
||||||
FileState fileState(SourceId sourceId,
|
FileState fileState(SourceId sourceId,
|
||||||
FileStatuses &fileStatuses,
|
Storage::Synchronization::SynchronizationPackage &package,
|
||||||
SourceIds &updatedSourceIds,
|
SourceIdsData &sourceIdData) const;
|
||||||
SourceIds ¬UpdatedSourceIds) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileSystemInterface &m_fileSystem;
|
FileSystemInterface &m_fileSystem;
|
||||||
|
Reference in New Issue
Block a user