QmlDesigner: SourceId has now fileNameId() and directoryPathId() getter

Change-Id: I9f75e9b149ee6c47930a16b2d3501e38a97709e7
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-04-08 16:14:56 +02:00
parent 581afd3350
commit e5a44265d4
15 changed files with 167 additions and 85 deletions

View File

@@ -70,7 +70,7 @@ public:
explicit operator std::size_t() const { return static_cast<std::size_t>(id); }
InternalIntegerType internalId() const { return id; }
constexpr InternalIntegerType internalId() const { return id; }
[[noreturn, deprecated]] InternalIntegerType operator&() const { throw std::exception{}; }

View File

@@ -27,7 +27,80 @@ using FileNameIds = std::vector<FileNameId>;
template<std::size_t size>
using SmallFileNameIds = QVarLengthArray<FileNameId, size>;
using SourceId = Sqlite::CompoundBasicId<SourcePathIdType::FileName, SourcePathIdType::DirectoryPath>;
class SourceId
{
public:
using IsBasicId = std::true_type;
using DatabaseType = long long;
constexpr explicit SourceId() = default;
static constexpr SourceId create(DirectoryPathId directoryPathId, FileNameId fileNameId)
{
SourceId compoundId;
compoundId.id = (static_cast<long long>(directoryPathId.internalId()) << 32)
| static_cast<long long>(fileNameId.internalId());
return compoundId;
}
static constexpr SourceId create(long long idNumber)
{
SourceId id;
id.id = idNumber;
return id;
}
constexpr FileNameId fileNameId() const { return FileNameId::create(static_cast<int>(id)); }
constexpr DirectoryPathId directoryPathId() const { return DirectoryPathId::create(id >> 32); }
friend constexpr bool compareInvalidAreTrue(SourceId first, SourceId second)
{
return first.id == second.id;
}
friend constexpr bool operator==(SourceId first, SourceId second)
{
return first.id == second.id && first.isValid();
}
friend constexpr auto operator<=>(SourceId first, SourceId second) = default;
constexpr bool isValid() const { return id != 0; }
constexpr bool isNull() const { return id == 0; }
explicit operator bool() const { return isValid(); }
long long internalId() const { return id; }
explicit operator std::size_t() const { return static_cast<std::size_t>(id) | 0xFFFFFFFFULL; }
template<typename String>
friend void convertToString(String &string, SourceId id)
{
using NanotraceHR::dictonary;
using NanotraceHR::keyValue;
int fileNameId = static_cast<int>(id.id);
int directoryPathId = id.id >> 32;
auto dict = dictonary(keyValue("directory path id", directoryPathId),
keyValue("source name id", fileNameId),
keyValue("source id", id.id));
convertToString(string, dict);
}
friend bool compareId(SourceId first, SourceId second) { return first.id == second.id; }
private:
long long id = 0;
};
using SourceIds = std::vector<SourceId>;
template<std::size_t size>
using SmallSourceIds = QVarLengthArray<SourceId, size>;

View File

@@ -50,8 +50,8 @@ long long FileSystem::lastModified(SourceId sourceId) const
FileStatus FileSystem::fileStatus(SourceId sourceId) const
{
auto path = sourceId.mainId() ? m_sourcePathCache.sourcePath(sourceId)
: m_sourcePathCache.directoryPath(sourceId.contextId());
auto path = sourceId.fileNameId() ? m_sourcePathCache.sourcePath(sourceId)
: m_sourcePathCache.directoryPath(sourceId.directoryPathId());
QFileInfo fileInfo(QString{path});
fileInfo.refresh();

View File

@@ -2270,7 +2270,7 @@ Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
auto directoryInfos = s->selectDirectoryInfosForDirectoryIdsStatement
.valuesWithTransaction<Storage::Synchronization::DirectoryInfo, 64>(
toIntegers(directoryIds));
Sqlite::toIntegers(directoryIds));
tracer.end(keyValue("directory infos", directoryInfos));
@@ -2290,7 +2290,7 @@ SmallDirectoryPathIds<32> ProjectStorage::fetchSubdirectoryIds(DirectoryPathId d
SmallDirectoryPathIds<32> directoryIds;
for (SourceId sourceId : sourceIds)
directoryIds.push_back(sourceId.contextId());
directoryIds.push_back(sourceId.directoryPathId());
tracer.end(keyValue("directory ids", directoryIds));
@@ -2422,7 +2422,7 @@ TypeIds ProjectStorage::fetchTypeIds(const SourceIds &sourceIds)
projectStorageCategory(),
keyValue("source ids", sourceIds)};
return s->selectTypeIdsForSourceIdsStatement.values<TypeId, 128>(toIntegers(sourceIds));
return s->selectTypeIdsForSourceIdsStatement.values<TypeId, 128>(Sqlite::toIntegers(sourceIds));
}
void ProjectStorage::unique(SourceIds &sourceIds)
@@ -2467,7 +2467,7 @@ void ProjectStorage::synchronizeTypeAnnotations(Storage::Synchronization::TypeAn
std::ranges::sort(typeAnnotations, {}, &TypeAnnotation::typeId);
auto range = s->selectTypeAnnotationsForSourceIdsStatement.range<TypeAnnotationView>(
toIntegers(updatedTypeAnnotationSourceIds));
Sqlite::toIntegers(updatedTypeAnnotationSourceIds));
auto insert = [&](const TypeAnnotation &annotation) {
if (!annotation.sourceId)
@@ -2625,7 +2625,7 @@ void ProjectStorage::synchronizeDirectoryInfos(Storage::Synchronization::Directo
auto range = s->selectDirectoryInfosForDirectoryIdsStatement
.range<Storage::Synchronization::DirectoryInfo>(
toIntegers(updatedDirectoryInfoDirectoryIds));
Sqlite::toIntegers(updatedDirectoryInfoDirectoryIds));
auto insert = [&](const Storage::Synchronization::DirectoryInfo &directoryInfo) {
using NanotraceHR::keyValue;
@@ -2687,7 +2687,7 @@ void ProjectStorage::synchronizeFileStatuses(FileStatuses &fileStatuses,
std::ranges::sort(fileStatuses, {}, &FileStatus::sourceId);
auto range = s->selectFileStatusesForSourceIdsStatement.range<FileStatus>(
toIntegers(updatedSourceIds));
Sqlite::toIntegers(updatedSourceIds));
auto insert = [&](const FileStatus &fileStatus) {
using NanotraceHR::keyValue;
@@ -2775,7 +2775,7 @@ void ProjectStorage::synchromizeModuleExportedImports(
auto range = s->selectModuleExportedImportsForSourceIdStatement
.range<Storage::Synchronization::ModuleExportedImportView>(
toIntegers(updatedModuleIds));
Sqlite::toIntegers(updatedModuleIds));
auto compareKey = [](const Storage::Synchronization::ModuleExportedImportView &view,
const Storage::Synchronization::ModuleExportedImport &import) {
@@ -3193,8 +3193,8 @@ void ProjectStorage::deleteNotUpdatedTypes(const TypeIds &updatedTypeIds,
};
s->selectNotUpdatedTypesInSourcesStatement.readCallback(callback,
toIntegers(updatedSourceIds),
toIntegers(updatedTypeIds));
Sqlite::toIntegers(updatedSourceIds),
Sqlite::toIntegers(updatedTypeIds));
for (TypeId typeIdToBeDeleted : typeIdsToBeDeleted)
callback(typeIdToBeDeleted);
}
@@ -3368,7 +3368,8 @@ void ProjectStorage::synchronizeExportedTypes(
});
auto range = s->selectExportedTypesForSourceIdsStatement
.range<Storage::Synchronization::ExportedTypeView>(toIntegers(updatedTypeIds));
.range<Storage::Synchronization::ExportedTypeView>(
Sqlite::toIntegers(updatedTypeIds));
auto compareKey = [](const Storage::Synchronization::ExportedTypeView &view,
const Storage::Synchronization::ExportedType &type) {
@@ -3915,7 +3916,7 @@ void ProjectStorage::synchronizeDocumentImports(Storage::Imports &imports,
});
auto range = s->selectDocumentImportForSourceIdStatement
.range<Storage::Synchronization::ImportView>(toIntegers(updatedSourceIds),
.range<Storage::Synchronization::ImportView>(Sqlite::toIntegers(updatedSourceIds),
importKind);
auto compareKey = [](const Storage::Synchronization::ImportView &view,
@@ -4063,7 +4064,7 @@ void ProjectStorage::synchronizePropertyEditorPaths(
std::ranges::sort(paths, {}, &PropertyEditorQmlPath::typeId);
auto range = s->selectPropertyEditorPathsForForSourceIdsStatement.range<PropertyEditorQmlPathView>(
toIntegers(updatedPropertyEditorQmlPathsDirectoryPathIds));
Sqlite::toIntegers(updatedPropertyEditorQmlPathsDirectoryPathIds));
auto compareKey = [](const PropertyEditorQmlPathView &view, const PropertyEditorQmlPath &value) {
return view.typeId <=> value.typeId;

View File

@@ -118,7 +118,7 @@ public:
std::ranges::transform(idPath.sourceIds, std::back_inserter(entries), [&](SourceId sourceId) {
auto fileStatus = m_fileStatusCache.find(sourceId);
return WatcherEntry{id,
sourceId.contextId(),
sourceId.directoryPathId(),
sourceId,
fileStatus.lastModified,
fileStatus.size};

View File

@@ -551,7 +551,7 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
if (isInsideProject == IsInsideProject::Yes) {
static FileNameId ignoreInQdsFileNameId = m_pathCache.fileNameId("ignore-in-qds");
SourceId ignoreInQdsSourceId = SourceId::create(ignoreInQdsFileNameId, directoryPathId);
SourceId ignoreInQdsSourceId = SourceId::create(directoryPathId, ignoreInQdsFileNameId);
auto ignoreInQdsState = fileState(ignoreInQdsSourceId, package, notUpdatedSourceIds);
@@ -598,7 +598,7 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
if (isChangedOrAdded(directoryState)) {
for (const auto &[subdirectoryPath, subdirectoryId] : existingSubdirecories) {
package.directoryInfos.emplace_back(directoryId,
SourceId::create(FileNameId{}, subdirectoryId),
SourceId::create(subdirectoryId, FileNameId{}),
ModuleId{},
Storage::Synchronization::FileType::Directory);
}
@@ -669,11 +669,11 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
SourcePath qmldirPath{directoryPath + "/qmldir"};
SourceId qmldirSourceId = m_pathCache.sourceId(qmldirPath);
DirectoryPathId directoryId = qmldirSourceId.contextId();
DirectoryPathId directoryId = qmldirSourceId.directoryPathId();
auto directoryState = fileState(directoryId, package, notUpdatedSourceIds);
if (isExisting(directoryState))
WatchedSourceIds.directoryIds.push_back(SourceId::create(FileNameId{}, directoryId));
WatchedSourceIds.directoryIds.push_back(SourceId::create(directoryId, FileNameId{}));
auto qmldirState = fileState(qmldirSourceId, package, notUpdatedSourceIds);
if (isExisting(qmldirState))
@@ -962,7 +962,7 @@ void ProjectStorageUpdater::updatePropertyEditorFilePath(
namespace {
DirectoryPathIds filterUniqueDirectoryPathIds(const SourceIds &sourceIds)
{
auto directoryPathIds = Utils::transform(sourceIds, &SourceId::contextId);
auto directoryPathIds = Utils::transform(sourceIds, &SourceId::directoryPathId);
std::sort(directoryPathIds.begin(), directoryPathIds.end());
auto newEnd = std::unique(directoryPathIds.begin(), directoryPathIds.end());
@@ -1070,7 +1070,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
const DirectoryPathIds &directoryIds,
IsInsideProject isInsideProject) {
for (SourceId sourceId : filterUniqueSourceIds(std::move(qmlDocumentSourceIds))) {
if (!contains(directoryIds, sourceId.contextId()))
if (!contains(directoryIds, sourceId.directoryPathId()))
this->parseQmlComponent(sourceId, package, notUpdatedSourceIds, isInsideProject);
}
};
@@ -1082,7 +1082,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
const DirectoryPathIds &directoryIds,
IsInsideProject isInsideProject) {
for (SourceId sourceId : filterUniqueSourceIds(std::move(qmltypesSourceIds))) {
if (!contains(directoryIds, sourceId.contextId())) {
if (!contains(directoryIds, sourceId.directoryPathId())) {
QString qmltypesPath{m_pathCache.sourcePath(sourceId)};
auto directoryInfo = m_projectStorage.fetchDirectoryInfo(sourceId);
if (directoryInfo)
@@ -1515,7 +1515,7 @@ ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) const
{
auto sourceId = SourceId::create(FileNameId{}, directoryPathId);
auto sourceId = SourceId::create(directoryPathId, FileNameId{});
return fileState(sourceId, package, notUpdatedSourceIds);
}

View File

@@ -59,7 +59,7 @@ public:
auto fileNameId = m_fileNameCache.id(fileName);
return SourceId::create(fileNameId, directoryPathId);
return SourceId::create(directoryPathId, fileNameId);
}
FileNameId fileNameId(Utils::SmallStringView fileName) const override
@@ -71,7 +71,7 @@ public:
{
FileNameId fileNameId = m_fileNameCache.id(fileName);
return SourceId::create(fileNameId, directoryPathId);
return SourceId::create(directoryPathId, fileNameId);
}
DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const override
@@ -88,9 +88,9 @@ public:
if (!sourceId) [[unlikely]]
throw NoSourcePathForInvalidSourceId();
auto fileName = m_fileNameCache.value(sourceId.mainId());
auto fileName = m_fileNameCache.value(sourceId.fileNameId());
Utils::PathString directoryPath = m_directoryPathCache.value(sourceId.contextId());
Utils::PathString directoryPath = m_directoryPathCache.value(sourceId.directoryPathId());
return SourcePath{directoryPath, fileName};
}

View File

@@ -598,6 +598,12 @@ std::ostream &operator<<(std::ostream &out, AuxiliaryDataType type)
return out;
}
std::ostream &operator<<(std::ostream &out, SourceId sourceId)
{
return out << "id=(" << sourceId.fileNameId().internalId() << ", "
<< sourceId.directoryPathId().internalId() << ")";
}
namespace Cache {
std::ostream &operator<<(std::ostream &out, const DirectoryPath &directoryPath)

View File

@@ -139,6 +139,7 @@ struct CompoundPropertyMetaInfo;
enum class FlagIs : unsigned int;
template<typename NameType>
class BasicAuxiliaryDataKey;
class SourceId;
void PrintTo(const ThemeProperty &prop, std::ostream *os);
std::ostream &operator<<(std::ostream &out, const ThemeProperty &prop);
@@ -162,6 +163,7 @@ std::ostream &operator<<(std::ostream &out, FlagIs flagIs);
std::ostream &operator<<(std::ostream &out, const BasicAuxiliaryDataKey<Utils::SmallStringView> &key);
std::ostream &operator<<(std::ostream &out, const BasicAuxiliaryDataKey<Utils::SmallString> &key);
std::ostream &operator<<(std::ostream &out, AuxiliaryDataType type);
std::ostream &operator<<(std::ostream &out, SourceId sourceId);
namespace Cache {
class DirectoryPath;

View File

@@ -1253,13 +1253,13 @@ protected:
SourceId sourceId5{sourcePathCache.sourceId(path5)};
SourceId sourceId6{sourcePathCache.sourceId(path6)};
SourceId sourceIdPath1{sourcePathCache.sourceId(pathPath1)};
DirectoryPathId directoryPathIdPath1{sourceIdPath1.contextId()};
DirectoryPathId directoryPathIdPath1{sourceIdPath1.directoryPathId()};
SourceId sourceIdPath6{sourcePathCache.sourceId(pathPath6)};
DirectoryPathId directoryPathIdPath6{sourceIdPath6.contextId()};
DirectoryPathId directoryPathIdPath6{sourceIdPath6.directoryPathId()};
SourceId qmlProjectSourceId{sourcePathCache.sourceId("/path1/qmldir")};
DirectoryPathId qmlProjectDirectoryPathId = qmlProjectSourceId.contextId();
DirectoryPathId qmlProjectDirectoryPathId = qmlProjectSourceId.directoryPathId();
SourceId qtQuickProjectSourceId{sourcePathCache.sourceId("/path2/qmldir")};
DirectoryPathId qtQuickProjectDirectoryPathId = qtQuickProjectSourceId.contextId();
DirectoryPathId qtQuickProjectDirectoryPathId = qtQuickProjectSourceId.directoryPathId();
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
ModuleId qmlNativeModuleId{storage.moduleId("Qml", ModuleKind::CppLibrary)};
ModuleId qtQuickModuleId{storage.moduleId("QtQuick", ModuleKind::QmlLibrary)};
@@ -6065,7 +6065,7 @@ TEST_F(ProjectStorage, fetch_subdirectory_directory_path_ids)
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
auto directory1Id = SourceId::create(FileNameId{}, sourceId2.contextId());
auto directory1Id = SourceId::create(sourceId2.directoryPathId(), FileNameId{});
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
directory1Id,
ModuleId{},
@@ -6074,7 +6074,7 @@ TEST_F(ProjectStorage, fetch_subdirectory_directory_path_ids)
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
auto directory2Id = SourceId::create(FileNameId{}, sourceId4.contextId());
auto directory2Id = SourceId::create(sourceId4.directoryPathId(), FileNameId{});
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectDirectoryPathId,
directory2Id,
ModuleId{},
@@ -6086,7 +6086,7 @@ TEST_F(ProjectStorage, fetch_subdirectory_directory_path_ids)
auto directoryInfo = storage.fetchSubdirectoryIds(qmlProjectDirectoryPathId);
ASSERT_THAT(directoryInfo,
UnorderedElementsAre(directory1Id.contextId(), directory2Id.contextId()));
UnorderedElementsAre(directory1Id.directoryPathId(), directory2Id.directoryPathId()));
}
TEST_F(ProjectStorage, fetch_directory_info_by_source_id)

View File

@@ -108,9 +108,9 @@ protected:
pathCache.sourceId(path3),
pathCache.sourceId(path4),
pathCache.sourceId(path5)};
DirectoryPathIds directoryPathIds = {sourceIds[0].contextId(),
sourceIds[2].contextId(),
sourceIds[4].contextId()};
DirectoryPathIds directoryPathIds = {sourceIds[0].directoryPathId(),
sourceIds[2].directoryPathId(),
sourceIds[4].directoryPathId()};
ProjectChunkIds ids{projectChunkId1, projectChunkId2, projectChunkId3};
WatcherEntry watcherEntry1{projectChunkId1, directoryPathIds[0], sourceIds[0]};
WatcherEntry watcherEntry2{projectChunkId2, directoryPathIds[0], sourceIds[0]};
@@ -460,7 +460,7 @@ TEST_F(ProjectStoragePathWatcher, trigger_manual_two_notify_file_changes)
ElementsAre(IdPaths{projectChunkId1, {sourceIds[0], sourceIds[1]}},
IdPaths{projectChunkId2, {sourceIds[0], sourceIds[1], sourceIds[3]}})));
watcher.checkForChangeInDirectory({sourceIds[0].contextId(), sourceIds[2].contextId()});
watcher.checkForChangeInDirectory({sourceIds[0].directoryPathId(), sourceIds[2].directoryPathId()});
}
TEST_F(ProjectStoragePathWatcher, trigger_manual_notify_for_path_changes)
@@ -474,7 +474,7 @@ TEST_F(ProjectStoragePathWatcher, trigger_manual_notify_for_path_changes)
EXPECT_CALL(notifier, pathsChanged(ElementsAre(sourceIds[0])));
watcher.checkForChangeInDirectory({sourceIds[0].contextId()});
watcher.checkForChangeInDirectory({sourceIds[0].directoryPathId()});
}
TEST_F(ProjectStoragePathWatcher, trigger_manual_no_notify_for_unwatched_path_changes)
@@ -483,7 +483,7 @@ TEST_F(ProjectStoragePathWatcher, trigger_manual_no_notify_for_unwatched_path_ch
EXPECT_CALL(notifier, pathsChanged(IsEmpty()));
watcher.checkForChangeInDirectory({sourceIds[0].contextId()});
watcher.checkForChangeInDirectory({sourceIds[0].directoryPathId()});
}
TEST_F(ProjectStoragePathWatcher, update_context_id_paths_adds_entry_in_new_directory)

View File

@@ -355,7 +355,7 @@ public:
SourceId createDirectorySourceId(Utils::SmallStringView path) const
{
auto directoryId = sourcePathCache.directoryPathId(path);
return SourceId::create(FileNameId{}, directoryId);
return SourceId::create(directoryId, FileNameId{});
}
SourceId createDirectorySourceIdFromQString(const QString &path) const
@@ -470,8 +470,8 @@ protected:
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/example2.qmltypes");
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
DirectoryPathId directoryPathId = qmlDirPathSourceId.directoryPathId();
SourceId directoryPathSourceId = SourceId::create(directoryPathId, QmlDesigner::FileNameId{});
SourceId annotationDirectorySourceId = createDirectorySourceId("/path/designer");
SourceId qmlDocumentSourceId1 = sourcePathCache.sourceId("/path/First.qml");
SourceId qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First2.qml");
@@ -480,11 +480,11 @@ protected:
UNITTEST_DIR "/../../../../share/qtcreator/qmldesigner/itemLibrary/");
DirectoryPathId itemLibraryPathDirectoryPathId = sourcePathCache.directoryPathId(
Utils::PathString{itemLibraryPath});
SourceId itemLibraryPathSourceId = SourceId::create(FileNameId{}, itemLibraryPathDirectoryPathId);
SourceId itemLibraryPathSourceId = SourceId::create(itemLibraryPathDirectoryPathId, FileNameId{});
const QString qmlImportsPath = QDir::cleanPath(UNITTEST_DIR "/projectstorage/data/qml");
DirectoryPathId qmlImportsPathDirectoryPathId = sourcePathCache.directoryPathId(
Utils::PathString{itemLibraryPath});
SourceId qmlImportsPathSourceId = SourceId::create(FileNameId{}, qmlImportsPathDirectoryPathId);
SourceId qmlImportsPathSourceId = SourceId::create(qmlImportsPathDirectoryPathId, FileNameId{});
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
ModuleId qmlCppNativeModuleId{storage.moduleId("Qml", ModuleKind::CppLibrary)};
ModuleId exampleModuleId{storage.moduleId("Example", ModuleKind::QmlLibrary)};
@@ -537,11 +537,11 @@ protected:
QmlDesigner::ProjectChunkId otherQmltypesProjectChunkId{otherProjectPartId,
QmlDesigner::SourceType::QmlTypes};
DirectoryPathId path1DirectoryPathId = sourcePathCache.directoryPathId("/path/one");
SourceId path1SourceId = SourceId::create(QmlDesigner::FileNameId{}, path1DirectoryPathId);
SourceId path1SourceId = SourceId::create(path1DirectoryPathId, QmlDesigner::FileNameId{});
DirectoryPathId path2DirectoryPathId = sourcePathCache.directoryPathId("/path/two");
SourceId path2SourceId = SourceId::create(QmlDesigner::FileNameId{}, path2DirectoryPathId);
SourceId path2SourceId = SourceId::create(path2DirectoryPathId, QmlDesigner::FileNameId{});
DirectoryPathId path3DirectoryPathId = sourcePathCache.directoryPathId("/path/three");
SourceId path3SourceId = SourceId::create(QmlDesigner::FileNameId{}, path3DirectoryPathId);
SourceId path3SourceId = SourceId::create(path3DirectoryPathId, QmlDesigner::FileNameId{});
SourceId qmldir1SourceId = sourcePathCache.sourceId("/path/one/qmldir");
SourceId qmldir2SourceId = sourcePathCache.sourceId("/path/two/qmldir");
SourceId qmldir3SourceId = sourcePathCache.sourceId("/path/three/qmldir");
@@ -608,8 +608,8 @@ public:
QStringList directories = {"/path"};
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
DirectoryPathId directoryPathId = qmlDirPathSourceId.directoryPathId();
SourceId directoryPathSourceId = SourceId::create(directoryPathId, QmlDesigner::FileNameId{});
};
TEST_F(ProjectStorageUpdater_get_content_for_qml_types, added_qml_types_file_provides_content)
@@ -669,8 +669,8 @@ public:
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/root/path/example.qmltypes");
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/root/path/example2.qmltypes");
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/root/path/qmldir");
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
DirectoryPathId directoryPathId = qmlDirPathSourceId.directoryPathId();
SourceId directoryPathSourceId = SourceId::create(directoryPathId, QmlDesigner::FileNameId{});
};
TEST_F(ProjectStorageUpdater_parse_qml_types, add_directory)
@@ -782,8 +782,8 @@ public:
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/root/path/example.qmltypes");
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/root/path/example2.qmltypes");
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/root/path/qmldir");
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
DirectoryPathId directoryPathId = qmlDirPathSourceId.directoryPathId();
SourceId directoryPathSourceId = SourceId::create(directoryPathId, QmlDesigner::FileNameId{});
SourceId annotationDirectoryId = createDirectorySourceId("/root/path/designer");
SourceId rootQmlDirPathSourceId = sourcePathCache.sourceId("/root/qmldir");
SourceId rootDirectoryPathSourceId = createDirectorySourceId("/root");
@@ -877,13 +877,13 @@ public:
public:
SourceId rootDirectoryPathSourceId = createDirectorySourceId("/root");
DirectoryPathId rootDirectoryPathId = rootDirectoryPathSourceId.contextId();
DirectoryPathId rootDirectoryPathId = rootDirectoryPathSourceId.directoryPathId();
SourceId path1SourceId = createDirectorySourceId("/root/one");
DirectoryPathId path1DirectoryPathId = path1SourceId.contextId();
DirectoryPathId path1DirectoryPathId = path1SourceId.directoryPathId();
SourceId path2SourceId = createDirectorySourceId("/root/two");
DirectoryPathId path2DirectoryPathId = path2SourceId.contextId();
DirectoryPathId path2DirectoryPathId = path2SourceId.directoryPathId();
SourceId path3SourceId = createDirectorySourceId("/root/one/three");
DirectoryPathId path3DirectoryPathId = path3SourceId.contextId();
DirectoryPathId path3DirectoryPathId = path3SourceId.directoryPathId();
};
TEST_F(ProjectStorageUpdater_synchronize_subdirectories, added_qt_subdircectories)
@@ -1092,8 +1092,8 @@ public:
public:
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
DirectoryPathId directoryPathId = qmlDirPathSourceId.directoryPathId();
SourceId directoryPathSourceId = SourceId::create(directoryPathId, QmlDesigner::FileNameId{});
SourceId annotationDirectorySourceId = createDirectorySourceId("/path/designer");
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
ModuleId exampleModuleId{storage.moduleId("Example", ModuleKind::QmlLibrary)};
@@ -3244,7 +3244,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_subdirectories)
SecondType 2.2 Second.qml)"};
setContent(u"/path/qmldir", qmldir);
DirectoryPathId rootPathId = sourcePathCache.directoryPathId("/root");
SourceId rootPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, rootPathId);
SourceId rootPathSourceId = SourceId::create(rootPathId, QmlDesigner::FileNameId{});
SourceId rootQmldirPathSourceId = sourcePathCache.sourceId("/root/qmldir");
setFilesChanged({directoryPathSourceId, rootPathSourceId});
setFilesUnchanged({qmlDirPathSourceId, rootQmldirPathSourceId});
@@ -3356,7 +3356,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_directory_change
setContent(u"/path/qmldir", qmldir);
setFilesChanged({directoryPathSourceId});
setFilesUnchanged({qmlDirPathSourceId});
auto directoryDirectoryPathId = directoryPathSourceId.contextId();
auto directoryDirectoryPathId = directoryPathSourceId.directoryPathId();
EXPECT_CALL(patchWatcherMock,
updateContextIdPaths(
@@ -3471,7 +3471,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_qmldir_changes)
FirstType 2.2 First2.qml
SecondType 2.2 Second.qml)"};
setContent(u"/path/qmldir", qmldir);
auto directoryDirectoryPathId = qmlDirPathSourceId.contextId();
auto directoryDirectoryPathId = qmlDirPathSourceId.directoryPathId();
EXPECT_CALL(patchWatcherMock,
updateContextIdPaths(
@@ -4794,7 +4794,7 @@ TEST_F(ProjectStorageUpdater, update_property_editor_panes)
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML/QtObjectPane.qml"});
auto directoryId = sourcePathCache.directoryPathId(
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML"});
auto directorySourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryId);
auto directorySourceId = SourceId::create(directoryId, QmlDesigner::FileNameId{});
setFilesChanged({directorySourceId});
auto qmlModuleId = storage.moduleId("QML", ModuleKind::QmlLibrary);
@@ -4829,12 +4829,12 @@ TEST_F(ProjectStorageUpdater, update_property_editor_specifics)
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/TextSpecifics.qml"});
auto qtQuickDirectoryId = sourcePathCache.directoryPathId(
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick"});
auto qtQuickDirectorySourceId = SourceId::create(QmlDesigner::FileNameId{}, qtQuickDirectoryId);
auto qtQuickDirectorySourceId = SourceId::create(qtQuickDirectoryId, QmlDesigner::FileNameId{});
auto buttonSourceId = sourcePathCache.sourceId(
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls/ButtonSpecifics.qml"});
auto controlsDirectoryId = sourcePathCache.directoryPathId(
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls"});
auto controlsDirectorySourceId = SourceId::create(QmlDesigner::FileNameId{}, controlsDirectoryId);
auto controlsDirectorySourceId = SourceId::create(controlsDirectoryId, QmlDesigner::FileNameId{});
setFilesChanged({qtQuickDirectorySourceId, controlsDirectorySourceId});
auto qtQuickModuleId = storage.moduleId("QtQuick", ModuleKind::QmlLibrary);
auto controlsModuleId = storage.moduleId("QtQuick.Controls", ModuleKind::QmlLibrary);
@@ -5072,7 +5072,7 @@ TEST_F(ProjectStorageUpdater, synchronize_added_property_editor_qml_paths_direct
{
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
SourceId designer1SourceId = SourceId::create(designer1DirectoryId, QmlDesigner::FileNameId{});
setFilesUnchanged({path1SourceId});
setFilesAdded({designer1SourceId});
@@ -5106,7 +5106,7 @@ TEST_F(ProjectStorageUpdater, synchronize_changed_property_editor_qml_paths_dire
{
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
SourceId designer1SourceId = SourceId::create(designer1DirectoryId, QmlDesigner::FileNameId{});
setFilesUnchanged({path1SourceId});
setFilesChanged({designer1SourceId});
@@ -5140,7 +5140,7 @@ TEST_F(ProjectStorageUpdater, dont_synchronize_empty_property_editor_qml_paths_d
{
setFileSystemSubdirectories(u"/path/two", {});
DirectoryPathId designer2DirectoryId = sourcePathCache.directoryPathId("/path/two/designer");
SourceId designer2SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer2DirectoryId);
SourceId designer2SourceId = SourceId::create(designer2DirectoryId, QmlDesigner::FileNameId{});
setFilesChanged({path2SourceId});
setFilesNotExists({designer2SourceId});
@@ -5172,7 +5172,7 @@ TEST_F(ProjectStorageUpdater, dont_synchronize_empty_property_editor_qml_paths_d
TEST_F(ProjectStorageUpdater, remove_property_editor_qml_paths_if_designer_directory_is_removed)
{
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
SourceId designer1SourceId = SourceId::create(designer1DirectoryId, QmlDesigner::FileNameId{});
setFilesUnchanged({path1SourceId, qmldir1SourceId});
setFilesRemoved({designer1SourceId});
@@ -5213,7 +5213,7 @@ TEST_F(ProjectStorageUpdater,
"/path/one/designer/HuoSpecificsDynamic.qml");
SourceId propertyEditorPaneSourceId = sourcePathCache.sourceId(
"/path/one/designer/CaoPane.qml");
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
SourceId designer1SourceId = SourceId::create(designer1DirectoryId, QmlDesigner::FileNameId{});
setFilesChanged({designer1SourceId});
setFilesUnchanged({path1SourceId, qmldir1SourceId});
auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary);
@@ -5257,7 +5257,7 @@ TEST_F(ProjectStorageUpdater,
"/path/one/designer/HuoSpecificsDynamic.qml");
SourceId propertyEditorPaneSourceId = sourcePathCache.sourceId(
"/path/one/designer/CaoPane.qml");
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
SourceId designer1SourceId = SourceId::create(designer1DirectoryId, QmlDesigner::FileNameId{});
setFilesChanged({path1SourceId});
setFilesUnchanged({qmldir1SourceId, designer1SourceId});
auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary);
@@ -5300,7 +5300,7 @@ TEST_F(ProjectStorageUpdater, synchronize_property_editor_qml_paths_directory_if
"/path/one/designer/HuoSpecificsDynamic.qml");
SourceId propertyEditorPaneSourceId = sourcePathCache.sourceId(
"/path/one/designer/CaoPane.qml");
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
SourceId designer1SourceId = SourceId::create(designer1DirectoryId, QmlDesigner::FileNameId{});
setFilesChanged({qmldir1SourceId});
setFilesUnchanged({path1SourceId, designer1SourceId});
auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary);

View File

@@ -158,7 +158,7 @@ protected:
QmlDesigner::QmlDocumentParser parser{storage, sourcePathCache};
Storage::Imports imports;
SourceId qmlFileSourceId{sourcePathCache.sourceId("/path/to/qmlfile.qml")};
DirectoryPathId qmlFileDirectoryPathId{qmlFileSourceId.contextId()};
DirectoryPathId qmlFileDirectoryPathId{qmlFileSourceId.directoryPathId()};
Utils::PathString directoryPath{sourcePathCache.directoryPath(qmlFileDirectoryPathId)};
ModuleId directoryModuleId{storage.moduleId(directoryPath, ModuleKind::PathLibrary)};
};

View File

@@ -196,11 +196,11 @@ protected:
Synchronization::Types types;
SourceId qmltypesFileSourceId{sourcePathCache.sourceId("path/to/types.qmltypes")};
ModuleId qtQmlNativeModuleId = storage.moduleId("QtQml", ModuleKind::CppLibrary);
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId.contextId(),
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId.directoryPathId(),
qmltypesFileSourceId,
qtQmlNativeModuleId,
Synchronization::FileType::QmlTypes};
DirectoryPathId qmltypesFileDirectoryPathId{qmltypesFileSourceId.contextId()};
DirectoryPathId qmltypesFileDirectoryPathId{qmltypesFileSourceId.directoryPathId()};
};
TEST_F(QmlTypesParser, imports)
@@ -893,7 +893,7 @@ TEST_F(QmlTypesParser, default_property)
TEST_F(QmlTypesParser, skip_template_item)
{
ModuleId moduleId = storage.moduleId("QtQuick.Templates", ModuleKind::CppLibrary);
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId.contextId(),
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId.directoryPathId(),
qmltypesFileSourceId,
moduleId,
Synchronization::FileType::QmlTypes};

View File

@@ -48,9 +48,9 @@ protected:
FileNameId fileNameId63 = FileNameId::create(63);
DirectoryPathId directoryPathId5 = DirectoryPathId::create(5);
DirectoryPathId directoryPathId6 = DirectoryPathId::create(6);
SourceId sourceId542 = SourceId::create(fileNameId42, directoryPathId5);
SourceId sourceId563 = SourceId::create(fileNameId63, directoryPathId5);
SourceId sourceId642 = SourceId::create(fileNameId42, directoryPathId6);
SourceId sourceId542 = SourceId::create(directoryPathId5, fileNameId42);
SourceId sourceId563 = SourceId::create(directoryPathId5, fileNameId63);
SourceId sourceId642 = SourceId::create(directoryPathId6, fileNameId42);
NiceMock<ProjectStorageMock> storageMock;
Cache cache{storageMock};
NiceMock<ProjectStorageMock> storageMockFilled;
@@ -278,7 +278,7 @@ TEST_F(SourcePathCache, second_directory_path_calls_not_fetch_directory_path)
TEST_F(SourcePathCache, fetch_directory_path_from_source_id)
{
auto directoryPathId = sourceId542.contextId();
auto directoryPathId = sourceId542.directoryPathId();
ASSERT_THAT(directoryPathId, Eq(directoryPathId5));
}
@@ -287,7 +287,7 @@ TEST_F(SourcePathCache, fetch_directory_path_id_after_fetching_file_path_by_sour
{
cache.sourcePath(sourceId542);
auto directoryPathId = sourceId542.contextId();
auto directoryPathId = sourceId542.directoryPathId();
ASSERT_THAT(directoryPathId, Eq(directoryPathId5));
}
@@ -313,7 +313,7 @@ TEST_F(SourcePathCache, get_directory_path_id_in_filled_cache)
{
Cache cacheFilled{storageMockFilled};
auto id = sourceId542.contextId();
auto id = sourceId542.directoryPathId();
ASSERT_THAT(id, Eq(directoryPathId5));
}