Skip to content

Commit

Permalink
QmlDesigner: Remove '.' workaround in project storage
Browse files Browse the repository at this point in the history
The '.' file paths were always a workaround. Since some time the context
id is now
part of the source id. So a source ids can be generated from source
context id
without a file name.

Task-number: QDS-14672
Change-Id: Ia278b9d06030ca8ea6e150d0c7ffd762979d5d62
  • Loading branch information
marbub committed Feb 6, 2025
1 parent 15c33de commit ad3d653
Show file tree
Hide file tree
Showing 16 changed files with 1,009 additions and 1,022 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ long long FileSystem::lastModified(SourceId sourceId) const

FileStatus FileSystem::fileStatus(SourceId sourceId) const
{
QFileInfo fileInfo(QString(m_sourcePathCache.sourcePath(sourceId)));
auto path = sourceId.mainId() ? m_sourcePathCache.sourcePath(sourceId)
: m_sourcePathCache.sourceContextPath(sourceId.contextId());
QFileInfo fileInfo(QString{path});

fileInfo.refresh();

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class QMLDESIGNERCORE_EXPORT ProjectStorage final : public ProjectStorageInterfa

Storage::Info::TypeHints typeHints(TypeId typeId) const override;

SmallSourceIds<4> typeAnnotationSourceIds(SourceId directoryId) const override;
SmallSourceIds<4> typeAnnotationSourceIds(SourceContextId directoryId) const override;

SmallSourceIds<64> typeAnnotationDirectorySourceIds() const override;
SmallSourceContextIds<64> typeAnnotationDirectoryIds() const override;

Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const override;

Expand Down Expand Up @@ -222,11 +222,11 @@ class QMLDESIGNERCORE_EXPORT ProjectStorage final : public ProjectStorageInterfa

std::optional<Storage::Synchronization::DirectoryInfo> fetchDirectoryInfo(SourceId sourceId) const override;

Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceId directorySourceId) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceContextId directoryId) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(
SourceId directorySourceId, Storage::Synchronization::FileType fileType) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(const SourceIds &directorySourceIds) const;
SmallSourceIds<32> fetchSubdirectorySourceIds(SourceId directorySourceId) const override;
SourceContextId directoryId, Storage::Synchronization::FileType fileType) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(const SourceContextIds &directoryIds) const;
SmallSourceContextIds<32> fetchSubdirectoryIds(SourceContextId directoryId) const override;

void setPropertyEditorPathId(TypeId typeId, SourceId pathId);

Expand Down Expand Up @@ -568,7 +568,7 @@ class QMLDESIGNERCORE_EXPORT ProjectStorage final : public ProjectStorageInterfa
const SourceIds &updatedSourceIds);

void synchronizeDirectoryInfos(Storage::Synchronization::DirectoryInfos &directoryInfos,
const SourceIds &updatedDirectoryInfoSourceIds);
const SourceContextIds &updatedDirectoryInfoDirectoryIds);

void synchronizeFileStatuses(FileStatuses &fileStatuses, const SourceIds &updatedSourceIds);

Expand Down Expand Up @@ -781,7 +781,7 @@ class QMLDESIGNERCORE_EXPORT ProjectStorage final : public ProjectStorageInterfa
class PropertyEditorQmlPathView
{
public:
PropertyEditorQmlPathView(TypeId typeId, SourceId pathId, SourceId directoryId)
PropertyEditorQmlPathView(TypeId typeId, SourceId pathId, SourceContextId directoryId)
: typeId{typeId}
, pathId{pathId}
, directoryId{directoryId}
Expand All @@ -803,14 +803,14 @@ class QMLDESIGNERCORE_EXPORT ProjectStorage final : public ProjectStorageInterfa
public:
TypeId typeId;
SourceId pathId;
SourceId directoryId;
SourceContextId directoryId;
};

void synchronizePropertyEditorPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceIds updatedPropertyEditorQmlPathsSourceIds);
SourceContextIds updatedPropertyEditorQmlPathsSourceContextIds);

void synchronizePropertyEditorQmlPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceIds updatedPropertyEditorQmlPathsSourceIds);
SourceContextIds updatedPropertyEditorQmlPathsSourceIds);

void synchronizeFunctionDeclarations(
TypeId typeId, Storage::Synchronization::FunctionDeclarations &functionsDeclarations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class ProjectStorageInterface
= 0;
virtual PropertyDeclarationId defaultPropertyDeclarationId(TypeId typeId) const = 0;
virtual std::optional<Storage::Info::Type> type(TypeId typeId) const = 0;
virtual SmallSourceIds<4> typeAnnotationSourceIds(SourceId directoryId) const = 0;
virtual SmallSourceIds<64> typeAnnotationDirectorySourceIds() const = 0;
virtual SmallSourceIds<4> typeAnnotationSourceIds(SourceContextId directoryId) const = 0;
virtual SmallSourceContextIds<64> typeAnnotationDirectoryIds() 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;
Expand All @@ -81,12 +81,13 @@ class ProjectStorageInterface
virtual bool isBasedOn(TypeId, TypeId, TypeId, TypeId, TypeId, TypeId, TypeId, TypeId) const = 0;

virtual FileStatus fetchFileStatus(SourceId sourceId) const = 0;
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceId sourceId) const = 0;
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceContextId directoryId) const = 0;
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(
SourceId directorySourceId, Storage::Synchronization::FileType) const
SourceContextId directoryId, Storage::Synchronization::FileType) const
= 0;
virtual std::optional<Storage::Synchronization::DirectoryInfo> fetchDirectoryInfo(SourceId sourceId) const = 0;
virtual SmallSourceIds<32> fetchSubdirectorySourceIds(SourceId directorySourceId) const = 0;
virtual std::optional<Storage::Synchronization::DirectoryInfo>
fetchDirectoryInfo(SourceId sourceId) const = 0;
virtual SmallSourceContextIds<32> fetchSubdirectoryIds(SourceContextId directoryId) const = 0;

virtual SourceId propertyEditorPathId(TypeId typeId) const = 0;
virtual const Storage::Info::CommonTypeCache<ProjectStorageType> &commonTypeCache() const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,10 @@ using Types = std::vector<Type>;
class PropertyEditorQmlPath
{
public:
PropertyEditorQmlPath(ModuleId moduleId, TypeNameString typeName, SourceId pathId, SourceId directoryId)
PropertyEditorQmlPath(ModuleId moduleId,
TypeNameString typeName,
SourceId pathId,
SourceContextId directoryId)
: typeName{typeName}
, pathId{pathId}
, directoryId{directoryId}
Expand All @@ -1174,7 +1177,7 @@ class PropertyEditorQmlPath
TypeNameString typeName;
TypeId typeId;
SourceId pathId;
SourceId directoryId;
SourceContextId directoryId;
ModuleId moduleId;
};

Expand All @@ -1183,16 +1186,16 @@ using PropertyEditorQmlPaths = std::vector<class PropertyEditorQmlPath>;
class DirectoryInfo
{
public:
DirectoryInfo(SourceId directorySourceId, SourceId sourceId, ModuleId moduleId, FileType fileType)
: directorySourceId{directorySourceId}
DirectoryInfo(SourceContextId directoryId, SourceId sourceId, ModuleId moduleId, FileType fileType)
: directoryId{directoryId}
, sourceId{sourceId}
, moduleId{moduleId}
, fileType{fileType}
{}

friend bool operator==(const DirectoryInfo &first, const DirectoryInfo &second)
{
return first.directorySourceId == second.directorySourceId && first.sourceId == second.sourceId
return first.directoryId == second.directoryId && first.sourceId == second.sourceId
&& first.moduleId.internalId() == second.moduleId.internalId()
&& first.fileType == second.fileType;
}
Expand All @@ -1202,7 +1205,7 @@ class DirectoryInfo
{
using NanotraceHR::dictonary;
using NanotraceHR::keyValue;
auto dict = dictonary(keyValue("project source id", directoryInfo.directorySourceId),
auto dict = dictonary(keyValue("directory id", directoryInfo.directoryId),
keyValue("source id", directoryInfo.sourceId),
keyValue("module id", directoryInfo.moduleId),
keyValue("file type", directoryInfo.fileType));
Expand All @@ -1211,7 +1214,7 @@ class DirectoryInfo
}

public:
SourceId directorySourceId;
SourceContextId directoryId;
SourceId sourceId;
ModuleId moduleId;
FileType fileType;
Expand All @@ -1222,13 +1225,13 @@ using DirectoryInfos = std::vector<DirectoryInfo>;
class TypeAnnotation
{
public:
TypeAnnotation(SourceId sourceId, SourceId directorySourceId)
TypeAnnotation(SourceId sourceId, SourceContextId directoryId)
: sourceId{sourceId}
, directorySourceId{directorySourceId}
, directoryId{directoryId}
{}

TypeAnnotation(SourceId sourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Utils::SmallStringView typeName,
ModuleId moduleId,
Utils::SmallStringView iconPath,
Expand All @@ -1242,7 +1245,7 @@ class TypeAnnotation
, sourceId{sourceId}
, moduleId{moduleId}
, traits{traits}
, directorySourceId{directorySourceId}
, directoryId{directoryId}
{}

template<typename String>
Expand Down Expand Up @@ -1271,7 +1274,7 @@ class TypeAnnotation
SourceId sourceId;
ModuleId moduleId;
TypeTraits traits;
SourceId directorySourceId;
SourceContextId directoryId;
};

using TypeAnnotations = std::vector<TypeAnnotation>;
Expand Down Expand Up @@ -1311,9 +1314,10 @@ class SynchronizationPackage
, fileStatuses(std::move(fileStatuses))
{}

SynchronizationPackage(SourceIds updatedDirectoryInfoSourceIds, DirectoryInfos directoryInfos)
SynchronizationPackage(SourceContextIds updatedDirectoryInfoDirectoryIds,
DirectoryInfos directoryInfos)
: directoryInfos(std::move(directoryInfos))
, updatedDirectoryInfoSourceIds(std::move(updatedDirectoryInfoSourceIds))
, updatedDirectoryInfoDirectoryIds(std::move(updatedDirectoryInfoDirectoryIds))
{}

public:
Expand All @@ -1323,13 +1327,13 @@ class SynchronizationPackage
SourceIds updatedFileStatusSourceIds;
FileStatuses fileStatuses;
DirectoryInfos directoryInfos;
SourceIds updatedDirectoryInfoSourceIds;
SourceContextIds updatedDirectoryInfoDirectoryIds;
Imports moduleDependencies;
SourceIds updatedModuleDependencySourceIds;
ModuleExportedImports moduleExportedImports;
ModuleIds updatedModuleIds;
PropertyEditorQmlPaths propertyEditorQmlPaths;
SourceIds updatedPropertyEditorQmlPathSourceIds;
SourceContextIds updatedPropertyEditorQmlPathSourceContextIds;
TypeAnnotations typeAnnotations;
SourceIds updatedTypeAnnotationSourceIds;
};
Expand Down
Loading

0 comments on commit ad3d653

Please sign in to comment.