forked from qt-creator/qt-creator
QmlDesigner: Fix property editor lookup
Task-number: QDS-11951 Change-Id: I22563aca2aacf515d2a2e66d87e39c418ea3b7d4 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -517,8 +517,12 @@ void ProjectStorageUpdater::updatePropertyEditorPaths(
|
||||
|
||||
auto state = fileState(directorySourceId, package, notUpdatedSourceIds);
|
||||
|
||||
if (state == FileState::Changed)
|
||||
updatePropertyEditorPath(pathInfo.filePath(), package, directorySourceId);
|
||||
if (state == FileState::Changed) {
|
||||
updatePropertyEditorPath(pathInfo.filePath(),
|
||||
package,
|
||||
directorySourceId,
|
||||
propertyEditorResourcesPath.size() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,7 +659,8 @@ void ProjectStorageUpdater::updateTypeAnnotation(const QString &directoryPath,
|
||||
void ProjectStorageUpdater::updatePropertyEditorPath(
|
||||
const QString &directoryPath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceId directorySourceId)
|
||||
SourceId directorySourceId,
|
||||
long long pathOffset)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"update property editor path"_t,
|
||||
category(),
|
||||
@@ -668,27 +673,29 @@ void ProjectStorageUpdater::updatePropertyEditorPath(
|
||||
auto dir = QDir{directoryPath};
|
||||
const auto fileInfos = dir.entryInfoList({"*Pane.qml", "*Specifics.qml"}, QDir::Files);
|
||||
for (const auto &fileInfo : fileInfos)
|
||||
updatePropertyEditorFilePath(fileInfo.filePath(), package, directorySourceId);
|
||||
updatePropertyEditorFilePath(fileInfo.filePath(), package, directorySourceId, pathOffset);
|
||||
}
|
||||
|
||||
void ProjectStorageUpdater::updatePropertyEditorFilePath(
|
||||
const QString &path,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceId directorySourceId)
|
||||
SourceId directorySourceId,
|
||||
long long pathOffset)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"update property editor file path"_t,
|
||||
category(),
|
||||
keyValue("directory path", path),
|
||||
keyValue("directory source id", directorySourceId)};
|
||||
|
||||
QRegularExpression regex{R"xo(.+\/(\w+)\/(\w+)(Specifics|Pane).qml)xo"};
|
||||
auto match = regex.match(path);
|
||||
QRegularExpression regex{R"xo((.+)\/(\w+)(Specifics|Pane).qml)xo"};
|
||||
auto match = regex.match(QStringView{path}.mid(pathOffset));
|
||||
QString oldModuleName;
|
||||
ModuleId moduleId;
|
||||
if (match.hasMatch()) {
|
||||
auto moduleName = match.capturedView(1);
|
||||
auto moduleName = match.capturedView(1).toString();
|
||||
moduleName.replace('/', '.');
|
||||
if (oldModuleName != moduleName) {
|
||||
oldModuleName = moduleName.toString();
|
||||
oldModuleName = moduleName;
|
||||
moduleId = m_projectStorage.moduleId(Utils::SmallString{moduleName});
|
||||
}
|
||||
Storage::TypeNameString typeName{match.capturedView(2)};
|
||||
|
@@ -177,10 +177,12 @@ private:
|
||||
Storage::Synchronization::SynchronizationPackage &package);
|
||||
void updatePropertyEditorPath(const QString &path,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceId directorySourceId);
|
||||
SourceId directorySourceId,
|
||||
long long pathOffset);
|
||||
void updatePropertyEditorFilePath(const QString &filePath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceId directorySourceId);
|
||||
SourceId directorySourceId,
|
||||
long long pathOffset);
|
||||
void parseTypeInfos(const QStringList &typeInfos,
|
||||
const QList<QmlDirParser::Import> &qmldirDependencies,
|
||||
const QList<QmlDirParser::Import> &qmldirImports,
|
||||
|
@@ -3533,19 +3533,26 @@ TEST_F(ProjectStorageUpdater, update_property_editor_specifics)
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(_)).WillByDefault([](SourceId sourceId) {
|
||||
return FileStatus{sourceId, 1, 21};
|
||||
});
|
||||
auto sourceId = sourcePathCache.sourceId(
|
||||
auto textSourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/TextSpecifics.qml"});
|
||||
auto directoryId = sourcePathCache.sourceId(
|
||||
auto qtQuickDirectoryId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/."});
|
||||
setFilesChanged({directoryId});
|
||||
auto buttonSourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls/ButtonSpecifics.qml"});
|
||||
auto controlsDirectoryId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls/."});
|
||||
setFilesChanged({qtQuickDirectoryId, controlsDirectoryId});
|
||||
auto qtQuickModuleId = storage.moduleId("QtQuick");
|
||||
auto controlsModuleId = storage.moduleId("QtQuick.Controls");
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::propertyEditorQmlPaths,
|
||||
Contains(IsPropertyEditorQmlPath(qtQuickModuleId, "Text", sourceId))),
|
||||
synchronize(AllOf(
|
||||
Field(&SynchronizationPackage::propertyEditorQmlPaths,
|
||||
IsSupersetOf(
|
||||
{IsPropertyEditorQmlPath(qtQuickModuleId, "Text", textSourceId),
|
||||
IsPropertyEditorQmlPath(controlsModuleId, "Button", buttonSourceId)})),
|
||||
Field(&SynchronizationPackage::updatedPropertyEditorQmlPathSourceIds,
|
||||
ElementsAre(directoryId)))));
|
||||
ElementsAre(qtQuickDirectoryId, controlsDirectoryId)))));
|
||||
|
||||
updater.update({}, {}, propertyEditorQmlPath, {});
|
||||
}
|
||||
|
Reference in New Issue
Block a user