QmlDesigner: Cleanup code for reuse

Task-number: QDS-9479
Change-Id: If8c66444e7b85255aa2f66519ab74572d3800979
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2023-03-20 18:53:18 +01:00
parent 77720c1122
commit 492c2f89c4
2 changed files with 8 additions and 22 deletions

View File

@@ -342,7 +342,6 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
package, package,
notUpdatedFileStatusSourceIds, notUpdatedFileStatusSourceIds,
notUpdatedSourceIds, notUpdatedSourceIds,
directoryPath,
watchedQmlSourceIds, watchedQmlSourceIds,
watchedQmltypesSourceIds); watchedQmltypesSourceIds);
break; break;
@@ -408,7 +407,6 @@ void ProjectStorageUpdater::parseProjectDatas(const Storage::Synchronization::Pr
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
SourceIds &notUpdatedSourceIds, SourceIds &notUpdatedSourceIds,
Utils::SmallStringView directoryPath,
SourceIds &watchedQmlSourceIds, SourceIds &watchedQmlSourceIds,
SourceIds &watchedQmltypesSourceIds) SourceIds &watchedQmltypesSourceIds)
{ {
@@ -428,13 +426,7 @@ void ProjectStorageUpdater::parseProjectDatas(const Storage::Synchronization::Pr
case Storage::Synchronization::FileType::QmlDocument: { case Storage::Synchronization::FileType::QmlDocument: {
watchedQmlSourceIds.push_back(projectData.sourceId); watchedQmlSourceIds.push_back(projectData.sourceId);
SourcePath qmlDocumentPath = m_pathCache.sourcePath(projectData.sourceId); parseQmlComponent(projectData.sourceId, package, notUpdatedFileStatusSourceIds);
parseQmlComponent(qmlDocumentPath.name(),
qmlDocumentPath,
directoryPath,
projectData.sourceId,
package,
notUpdatedFileStatusSourceIds);
} }
}; };
} }
@@ -530,10 +522,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
package.types.push_back(std::move(type)); package.types.push_back(std::move(type));
} }
void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView fileName, void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId,
Utils::SmallStringView filePath,
Utils::SmallStringView directoryPath,
SourceId sourceId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds) SourceIds &notUpdatedFileStatusSourceIds)
{ {
@@ -546,12 +535,12 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView fileName,
package.updatedSourceIds.push_back(sourceId); package.updatedSourceIds.push_back(sourceId);
SourcePath sourcePath{filePath}; SourcePath sourcePath = m_pathCache.sourcePath(sourceId);
const auto content = m_fileSystem.contentAsQString(QString{filePath}); const auto content = m_fileSystem.contentAsQString(QString{sourcePath});
auto type = m_qmlDocumentParser.parse(content, package.imports, sourceId, directoryPath); auto type = m_qmlDocumentParser.parse(content, package.imports, sourceId, sourcePath.directory());
type.typeName = fileName; type.typeName = sourcePath.name();
type.traits = Storage::TypeTraits::Reference; type.traits = Storage::TypeTraits::Reference;
type.sourceId = sourceId; type.sourceId = sourceId;
type.changeLevel = Storage::Synchronization::ChangeLevel::ExcludeExportedTypes; type.changeLevel = Storage::Synchronization::ChangeLevel::ExcludeExportedTypes;

View File

@@ -9,6 +9,7 @@
#include "projectstoragepathwatchernotifierinterface.h" #include "projectstoragepathwatchernotifierinterface.h"
#include "projectstoragepathwatchertypes.h" #include "projectstoragepathwatchertypes.h"
#include "projectstoragetypes.h" #include "projectstoragetypes.h"
#include "sourcepath.h"
#include <qmljs/parser/qmldirparser_p.h> #include <qmljs/parser/qmldirparser_p.h>
@@ -124,7 +125,6 @@ private:
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds, SourceIds &notUpdatedFileStatusSourceIds,
SourceIds &notUpdatedSourceIds, SourceIds &notUpdatedSourceIds,
Utils::SmallStringView directoryPath,
SourceIds &watchedQmlSourceIds, SourceIds &watchedQmlSourceIds,
SourceIds &watchedQmltypesSourceIds); SourceIds &watchedQmltypesSourceIds);
FileState parseTypeInfo(const Storage::Synchronization::ProjectData &projectData, FileState parseTypeInfo(const Storage::Synchronization::ProjectData &projectData,
@@ -149,10 +149,7 @@ private:
SourceIds &notUpdatedSourceIds, SourceIds &notUpdatedSourceIds,
SourceIds &watchedQmlSourceIds, SourceIds &watchedQmlSourceIds,
FileState qmldirState); FileState qmldirState);
void parseQmlComponent(Utils::SmallStringView fileName, void parseQmlComponent(SourceId sourceId,
Utils::SmallStringView filePath,
Utils::SmallStringView directoryPath,
SourceId sourceId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceIds &notUpdatedFileStatusSourceIds); SourceIds &notUpdatedFileStatusSourceIds);