forked from qt-creator/qt-creator
QmlDesigner: Rename Import into Module
Task-number: QDS-4933 Change-Id: Ibc28ae731ffb27734f61eb438230fa58fe800bdc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -83,7 +83,7 @@ enum class BasicIdType {
|
|||||||
FunctionDeclaration,
|
FunctionDeclaration,
|
||||||
SignalDeclaration,
|
SignalDeclaration,
|
||||||
EnumerationDeclaration,
|
EnumerationDeclaration,
|
||||||
Import,
|
Module,
|
||||||
TypeName,
|
TypeName,
|
||||||
ProjectPartId
|
ProjectPartId
|
||||||
};
|
};
|
||||||
@@ -109,8 +109,8 @@ using SourceContextIds = std::vector<SourceContextId>;
|
|||||||
using SourceId = BasicId<BasicIdType::SourceId, int>;
|
using SourceId = BasicId<BasicIdType::SourceId, int>;
|
||||||
using SourceIds = std::vector<SourceId>;
|
using SourceIds = std::vector<SourceId>;
|
||||||
|
|
||||||
using ImportId = BasicId<BasicIdType::Import>;
|
using ModuleId = BasicId<BasicIdType::Module>;
|
||||||
using ImportIds = std::vector<ImportId>;
|
using ModuleIds = std::vector<ModuleId>;
|
||||||
|
|
||||||
using TypeNameId = BasicId<BasicIdType::TypeName>;
|
using TypeNameId = BasicId<BasicIdType::TypeName>;
|
||||||
using TypeNameIds = std::vector<TypeNameId>;
|
using TypeNameIds = std::vector<TypeNameId>;
|
||||||
|
@@ -55,7 +55,7 @@ public:
|
|||||||
, initializer{database, isInitialized}
|
, initializer{database, isInitialized}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void synchronize(Storage::ImportDependencies importDependencies,
|
void synchronize(Storage::ModuleDependencies moduleDependencies,
|
||||||
Storage::Documents documents,
|
Storage::Documents documents,
|
||||||
Storage::Types types,
|
Storage::Types types,
|
||||||
SourceIds sourceIds,
|
SourceIds sourceIds,
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
synchronizeFileStatuses(fileStatuses, sourceIdValues);
|
synchronizeFileStatuses(fileStatuses, sourceIdValues);
|
||||||
synchronizeImports(importDependencies, deletedTypeIds, sourceIdValues);
|
synchronizeModules(moduleDependencies, deletedTypeIds, sourceIdValues);
|
||||||
synchronizeDocuments(documents, sourceIdValues);
|
synchronizeDocuments(documents, sourceIdValues);
|
||||||
synchronizeTypes(types,
|
synchronizeTypes(types,
|
||||||
updatedTypeIds,
|
updatedTypeIds,
|
||||||
@@ -90,26 +90,26 @@ public:
|
|||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportIds fetchImportIds(const Storage::Imports &imports)
|
ModuleIds fetchModuleIds(const Storage::Modules &modules)
|
||||||
{
|
{
|
||||||
Sqlite::DeferredTransaction transaction{database};
|
Sqlite::DeferredTransaction transaction{database};
|
||||||
|
|
||||||
ImportIds importIds = fetchImportIdsUnguarded(imports);
|
ModuleIds moduleIds = fetchModuleIdsUnguarded(modules);
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
return importIds;
|
return moduleIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportIds fetchImportIds(SourceId sourceId)
|
ModuleIds fetchModuleIds(SourceId sourceId)
|
||||||
{
|
{
|
||||||
return selectImportIdsForSourceIdStatement.template valeWithTransaction(16, &sourceId);
|
return selectModuleIdsForSourceIdStatement.template valeWithTransaction(16, &sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportIds fetchImportDependencyIds(ImportIds importIds) const
|
ModuleIds fetchModuleDependencyIds(ModuleIds moduleIds) const
|
||||||
{
|
{
|
||||||
return fetchImportDependencyIdsStatement.template valuesWithTransaction<ImportId>(
|
return fetchModuleDependencyIdsStatement.template valuesWithTransaction<ModuleId>(
|
||||||
16, static_cast<void *>(importIds.data()), static_cast<long long>(importIds.size()));
|
16, static_cast<void *>(moduleIds.data()), static_cast<long long>(moduleIds.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyDeclarationId fetchPropertyDeclarationByTypeIdAndName(TypeId typeId,
|
PropertyDeclarationId fetchPropertyDeclarationByTypeIdAndName(TypeId typeId,
|
||||||
@@ -124,15 +124,15 @@ public:
|
|||||||
return selectTypeIdByExportedNameStatement.template valueWithTransaction<TypeId>(name);
|
return selectTypeIdByExportedNameStatement.template valueWithTransaction<TypeId>(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeId fetchTypeIdByImportIdsAndExportedName(ImportIds importIds, Utils::SmallStringView name) const
|
TypeId fetchTypeIdByModuleIdsAndExportedName(ModuleIds moduleIds, Utils::SmallStringView name) const
|
||||||
{
|
{
|
||||||
return selectTypeIdByImportIdsAndExportedNameStatement.template valueWithTransaction<TypeId>(
|
return selectTypeIdByModuleIdsAndExportedNameStatement.template valueWithTransaction<TypeId>(
|
||||||
static_cast<void *>(importIds.data()), static_cast<long long>(importIds.size()), name);
|
static_cast<void *>(moduleIds.data()), static_cast<long long>(moduleIds.size()), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeId fetchTypeIdByName(ImportId importId, Utils::SmallStringView name)
|
TypeId fetchTypeIdByName(ModuleId moduleId, Utils::SmallStringView name)
|
||||||
{
|
{
|
||||||
return selectTypeIdByImportIdAndNameStatement.template valueWithTransaction<TypeId>(&importId,
|
return selectTypeIdByModuleIdAndNameStatement.template valueWithTransaction<TypeId>(&moduleId,
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,25 +271,25 @@ public:
|
|||||||
return writeSourceId(sourceContextId, sourceName);
|
return writeSourceId(sourceContextId, sourceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fetchAllImports() const
|
auto fetchAllModules() const
|
||||||
{
|
{
|
||||||
Storage::ImportDependencies imports;
|
Storage::ModuleDependencies modules;
|
||||||
imports.reserve(128);
|
modules.reserve(128);
|
||||||
|
|
||||||
auto callback = [&](Utils::SmallStringView name, int version, int importId) {
|
auto callback = [&](Utils::SmallStringView name, int version, int moduleId) {
|
||||||
auto &lastImport = imports.emplace_back(name,
|
auto &lastModule = modules.emplace_back(name,
|
||||||
Storage::VersionNumber{version},
|
Storage::VersionNumber{version},
|
||||||
SourceId{importId});
|
SourceId{moduleId});
|
||||||
|
|
||||||
lastImport.dependencies = selectImportsForThatDependentOnThisImportIdStatement
|
lastModule.dependencies = selectModulesForThatDependentOnThisModuleIdStatement
|
||||||
.template values<Storage::Import>(6, importId);
|
.template values<Storage::Module>(6, moduleId);
|
||||||
|
|
||||||
return Sqlite::CallbackControl::Continue;
|
return Sqlite::CallbackControl::Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
selectAllImportsStatement.readCallbackWithTransaction(callback);
|
selectAllModulesStatement.readCallbackWithTransaction(callback);
|
||||||
|
|
||||||
return imports;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fetchAllFileStatuses() const
|
auto fetchAllFileStatuses() const
|
||||||
@@ -369,8 +369,8 @@ private:
|
|||||||
bool isExplicitTypeName = typeNameIdValue < 0;
|
bool isExplicitTypeName = typeNameIdValue < 0;
|
||||||
|
|
||||||
if (isExplicitTypeName) {
|
if (isExplicitTypeName) {
|
||||||
auto callback = [&](Utils::SmallStringView type, Utils::SmallStringView import, int version) {
|
auto callback = [&](Utils::SmallStringView type, Utils::SmallStringView module, int version) {
|
||||||
typeName = Storage::ExplicitExportedType{type, Storage::Import{import, version}};
|
typeName = Storage::ExplicitExportedType{type, Storage::Module{module, version}};
|
||||||
return Sqlite::CallbackControl::Abort;
|
return Sqlite::CallbackControl::Abort;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -386,27 +386,27 @@ private:
|
|||||||
return typeName;
|
return typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImportDependency
|
struct ModuleDependency
|
||||||
{
|
{
|
||||||
ImportDependency(ImportId id, ImportId dependencyId)
|
ModuleDependency(ModuleId id, ModuleId dependencyId)
|
||||||
: id{id}
|
: id{id}
|
||||||
, dependencyId{dependencyId}
|
, dependencyId{dependencyId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ImportDependency(long long id, long long dependencyId)
|
ModuleDependency(long long id, long long dependencyId)
|
||||||
: id{id}
|
: id{id}
|
||||||
, dependencyId{dependencyId}
|
, dependencyId{dependencyId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ImportId id;
|
ModuleId id;
|
||||||
ImportId dependencyId;
|
ModuleId dependencyId;
|
||||||
|
|
||||||
friend bool operator<(ImportDependency first, ImportDependency second)
|
friend bool operator<(ModuleDependency first, ModuleDependency second)
|
||||||
{
|
{
|
||||||
return std::tie(first.id, first.dependencyId) < std::tie(second.id, second.dependencyId);
|
return std::tie(first.id, first.dependencyId) < std::tie(second.id, second.dependencyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(ImportDependency first, ImportDependency second)
|
friend bool operator==(ModuleDependency first, ModuleDependency second)
|
||||||
{
|
{
|
||||||
return first.id == second.id && first.dependencyId == second.dependencyId;
|
return first.id == second.id && first.dependencyId == second.dependencyId;
|
||||||
}
|
}
|
||||||
@@ -470,23 +470,23 @@ private:
|
|||||||
Sqlite::insertUpdateDelete(range, fileStatuses, compareKey, insert, update, remove);
|
Sqlite::insertUpdateDelete(range, fileStatuses, compareKey, insert, update, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizeImports(Storage::ImportDependencies &imports,
|
void synchronizeModules(Storage::ModuleDependencies &modules,
|
||||||
TypeIds &deletedTypeIds,
|
TypeIds &deletedTypeIds,
|
||||||
const std::vector<int> &importIdValues)
|
const std::vector<int> &moduleIdValues)
|
||||||
{
|
{
|
||||||
synchronizeImportsAndUpdatesImportIds(imports, deletedTypeIds, importIdValues);
|
synchronizeModulesAndUpdatesModuleIds(modules, deletedTypeIds, moduleIdValues);
|
||||||
synchronizeImportDependencies(createSortedImportDependecies(imports), importIdValues);
|
synchronizeModuleDependencies(createSortedModuleDependecies(modules), moduleIdValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizeDocuments(Storage::Documents &documents, std::vector<int> &sourceIdValues)
|
void synchronizeDocuments(Storage::Documents &documents, std::vector<int> &sourceIdValues)
|
||||||
{
|
{
|
||||||
deleteDocumentImportsForDeletedDocuments(documents, sourceIdValues);
|
deleteDocumentModulesForDeletedDocuments(documents, sourceIdValues);
|
||||||
|
|
||||||
for (auto &&document : documents)
|
for (auto &&document : documents)
|
||||||
synchronizeDocumentImports(document.sourceId, document.imports);
|
synchronizeDocumentModules(document.sourceId, document.modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteDocumentImportsForDeletedDocuments(Storage::Documents &documents,
|
void deleteDocumentModulesForDeletedDocuments(Storage::Documents &documents,
|
||||||
const std::vector<int> &sourceIdValues)
|
const std::vector<int> &sourceIdValues)
|
||||||
{
|
{
|
||||||
const std::vector<int> documentSourceIds = Utils::transform<std::vector<int>>(
|
const std::vector<int> documentSourceIds = Utils::transform<std::vector<int>>(
|
||||||
@@ -500,70 +500,70 @@ private:
|
|||||||
documentSourceIds.end(),
|
documentSourceIds.end(),
|
||||||
std::back_inserter(documentSourceIdsToBeDeleted));
|
std::back_inserter(documentSourceIdsToBeDeleted));
|
||||||
|
|
||||||
deleteDocumentImportsWithSourceIdsStatement.write(Utils::span{documentSourceIdsToBeDeleted});
|
deleteDocumentModulesWithSourceIdsStatement.write(Utils::span{documentSourceIdsToBeDeleted});
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizeImportsAndUpdatesImportIds(Storage::ImportDependencies &imports,
|
void synchronizeModulesAndUpdatesModuleIds(Storage::ModuleDependencies &modules,
|
||||||
TypeIds &deletedTypeIds,
|
TypeIds &deletedTypeIds,
|
||||||
const std::vector<int> &importIds)
|
const std::vector<int> &moduleIds)
|
||||||
{
|
{
|
||||||
auto compareKey = [](auto &&first, auto &&second) {
|
auto compareKey = [](auto &&first, auto &&second) {
|
||||||
return first.sourceId.id - second.sourceId.id;
|
return first.sourceId.id - second.sourceId.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::sort(imports.begin(), imports.end(), [&](auto &&first, auto &&second) {
|
std::sort(modules.begin(), modules.end(), [&](auto &&first, auto &&second) {
|
||||||
return compareKey(first, second) < 0;
|
return compareKey(first, second) < 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto range = selectImportsForIdsStatement.template range<Storage::ImportView>(
|
auto range = selectModulesForIdsStatement.template range<Storage::ModuleView>(
|
||||||
Utils::span(importIds));
|
Utils::span(moduleIds));
|
||||||
|
|
||||||
auto insert = [&](Storage::ImportDependency &import) {
|
auto insert = [&](Storage::ModuleDependency &module) {
|
||||||
insertImportStatement.write(import.name, import.version.version, &import.sourceId);
|
insertModuleStatement.write(module.name, module.version.version, &module.sourceId);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto update = [&](const Storage::ImportView &importView, Storage::ImportDependency &import) {
|
auto update = [&](const Storage::ModuleView &moduleView, Storage::ModuleDependency &module) {
|
||||||
if (importView.name != import.name || importView.version != import.version)
|
if (moduleView.name != module.name || moduleView.version != module.version)
|
||||||
updateImportStatement.write(&importView.sourceId, import.name, import.version.version);
|
updateModuleStatement.write(&moduleView.sourceId, module.name, module.version.version);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto remove = [&](const Storage::ImportView &importView) {
|
auto remove = [&](const Storage::ModuleView &moduleView) {
|
||||||
deleteImportStatement.write(&importView.sourceId);
|
deleteModuleStatement.write(&moduleView.sourceId);
|
||||||
selectTypeIdsForImportIdStatement.readTo(deletedTypeIds, &importView.sourceId);
|
selectTypeIdsForModuleIdStatement.readTo(deletedTypeIds, &moduleView.sourceId);
|
||||||
};
|
};
|
||||||
|
|
||||||
Sqlite::insertUpdateDelete(range, imports, compareKey, insert, update, remove);
|
Sqlite::insertUpdateDelete(range, modules, compareKey, insert, update, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ImportDependency> createSortedImportDependecies(
|
std::vector<ModuleDependency> createSortedModuleDependecies(
|
||||||
const Storage::ImportDependencies &importDependencies) const
|
const Storage::ModuleDependencies &moduleDependencies) const
|
||||||
{
|
{
|
||||||
std::vector<ImportDependency> importDependecies;
|
std::vector<ModuleDependency> moduleDependecies;
|
||||||
importDependecies.reserve(importDependencies.size() * 5);
|
moduleDependecies.reserve(moduleDependencies.size() * 5);
|
||||||
|
|
||||||
for (const Storage::ImportDependency &importDependency : importDependencies) {
|
for (const Storage::ModuleDependency &moduleDependency : moduleDependencies) {
|
||||||
for (const Storage::Import &dependency : importDependency.dependencies) {
|
for (const Storage::Module &dependency : moduleDependency.dependencies) {
|
||||||
auto importIdForDependency = fetchImportId(dependency);
|
auto moduleIdForDependency = fetchModuleId(dependency);
|
||||||
|
|
||||||
if (!importIdForDependency)
|
if (!moduleIdForDependency)
|
||||||
throw ImportDoesNotExists{};
|
throw ModuleDoesNotExists{};
|
||||||
|
|
||||||
importDependecies.emplace_back(ImportId{&importDependency.sourceId},
|
moduleDependecies.emplace_back(ModuleId{&moduleDependency.sourceId},
|
||||||
importIdForDependency);
|
moduleIdForDependency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(importDependecies.begin(), importDependecies.end());
|
std::sort(moduleDependecies.begin(), moduleDependecies.end());
|
||||||
importDependecies.erase(std::unique(importDependecies.begin(), importDependecies.end()),
|
moduleDependecies.erase(std::unique(moduleDependecies.begin(), moduleDependecies.end()),
|
||||||
importDependecies.end());
|
moduleDependecies.end());
|
||||||
|
|
||||||
return importDependecies;
|
return moduleDependecies;
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizeImportDependencies(const std::vector<ImportDependency> &importDependecies,
|
void synchronizeModuleDependencies(const std::vector<ModuleDependency> &moduleDependecies,
|
||||||
const std::vector<int> &importIds)
|
const std::vector<int> &moduleIds)
|
||||||
{
|
{
|
||||||
auto compareKey = [](ImportDependency first, ImportDependency second) {
|
auto compareKey = [](ModuleDependency first, ModuleDependency second) {
|
||||||
auto idCompare = first.id.id - second.id.id;
|
auto idCompare = first.id.id - second.id.id;
|
||||||
|
|
||||||
if (idCompare != 0)
|
if (idCompare != 0)
|
||||||
@@ -572,30 +572,30 @@ private:
|
|||||||
return first.dependencyId.id - second.dependencyId.id;
|
return first.dependencyId.id - second.dependencyId.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto range = selectImportDependenciesForIdsStatement.template range<ImportDependency>(
|
auto range = selectModuleDependenciesForIdsStatement.template range<ModuleDependency>(
|
||||||
Utils::span(importIds));
|
Utils::span(moduleIds));
|
||||||
|
|
||||||
auto insert = [&](ImportDependency dependency) {
|
auto insert = [&](ModuleDependency dependency) {
|
||||||
insertImportDependencyStatement.write(&dependency.id, &dependency.dependencyId);
|
insertModuleDependencyStatement.write(&dependency.id, &dependency.dependencyId);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto update = [](ImportDependency, ImportDependency) {};
|
auto update = [](ModuleDependency, ModuleDependency) {};
|
||||||
|
|
||||||
auto remove = [&](ImportDependency dependency) {
|
auto remove = [&](ModuleDependency dependency) {
|
||||||
deleteImportDependencyStatement.write(&dependency.id, &dependency.dependencyId);
|
deleteModuleDependencyStatement.write(&dependency.id, &dependency.dependencyId);
|
||||||
};
|
};
|
||||||
|
|
||||||
Sqlite::insertUpdateDelete(range, importDependecies, compareKey, insert, update, remove);
|
Sqlite::insertUpdateDelete(range, moduleDependecies, compareKey, insert, update, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportId fetchImportId(const Storage::Import &import) const
|
ModuleId fetchModuleId(const Storage::Module &module) const
|
||||||
{
|
{
|
||||||
if (import.version) {
|
if (module.version) {
|
||||||
return selectImportIdByNameAndVersionStatement
|
return selectModuleIdByNameAndVersionStatement
|
||||||
.template value<ImportId>(import.name, import.version.version);
|
.template value<ModuleId>(module.name, module.version.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectImportIdByNameStatement.template value<ImportId>(import.name);
|
return selectModuleIdByNameStatement.template value<ModuleId>(module.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleAliasPropertyDeclarationsWithPropertyType(
|
void handleAliasPropertyDeclarationsWithPropertyType(
|
||||||
@@ -845,20 +845,20 @@ private:
|
|||||||
updateAliasPropertyDeclarationValues(updatedAliasPropertyDeclarations);
|
updateAliasPropertyDeclarationValues(updatedAliasPropertyDeclarations);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upsertExportedType(ImportId importId, Utils::SmallStringView name, TypeId typeId)
|
void upsertExportedType(ModuleId moduleId, Utils::SmallStringView name, TypeId typeId)
|
||||||
{
|
{
|
||||||
upsertTypeNamesStatement.write(&importId,
|
upsertTypeNamesStatement.write(&moduleId,
|
||||||
name,
|
name,
|
||||||
&typeId,
|
static_cast<long long>(Storage::TypeNameKind::Exported),
|
||||||
static_cast<long long>(Storage::TypeNameKind::Exported));
|
-1,
|
||||||
|
-1,
|
||||||
|
&typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upsertNativeType(ImportId importId, Utils::SmallStringView name, TypeId typeId)
|
void upsertNativeType(ModuleId moduleId, Utils::SmallStringView name, TypeId typeId)
|
||||||
{
|
{
|
||||||
upsertTypeNamesStatement.write(&importId,
|
upsertTypeNamesStatement.write(
|
||||||
name,
|
&moduleId, name, static_cast<long long>(Storage::TypeNameKind::Native), -1, -1, &typeId);
|
||||||
&typeId,
|
|
||||||
static_cast<long long>(Storage::TypeNameKind::Native));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizePropertyDeclarationsInsertAlias(
|
void synchronizePropertyDeclarationsInsertAlias(
|
||||||
@@ -1040,38 +1040,38 @@ private:
|
|||||||
Sqlite::insertUpdateDelete(range, aliasDeclarations, compareKey, insert, update, remove);
|
Sqlite::insertUpdateDelete(range, aliasDeclarations, compareKey, insert, update, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportIds fetchImportIdsUnguarded(const Storage::Imports &imports)
|
ModuleIds fetchModuleIdsUnguarded(const Storage::Modules &modules)
|
||||||
{
|
{
|
||||||
ImportIds importIds;
|
ModuleIds moduleIds;
|
||||||
importIds.reserve(importIds.size());
|
moduleIds.reserve(moduleIds.size());
|
||||||
|
|
||||||
for (auto &&import : imports)
|
for (auto &&module : modules)
|
||||||
importIds.push_back(fetchImportId(import));
|
moduleIds.push_back(fetchModuleId(module));
|
||||||
|
|
||||||
return importIds;
|
return moduleIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizeDocumentImports(SourceId sourceId, const Storage::Imports &imports)
|
void synchronizeDocumentModules(SourceId sourceId, const Storage::Modules &modules)
|
||||||
{
|
{
|
||||||
ImportIds importIds = fetchImportIdsUnguarded(imports);
|
ModuleIds moduleIds = fetchModuleIdsUnguarded(modules);
|
||||||
|
|
||||||
std::sort(importIds.begin(), importIds.end());
|
std::sort(moduleIds.begin(), moduleIds.end());
|
||||||
|
|
||||||
auto range = selectImportIdsForSourceIdStatement.template range<ImportId>(&sourceId);
|
auto range = selectModuleIdsForSourceIdStatement.template range<ModuleId>(&sourceId);
|
||||||
|
|
||||||
auto compareKey = [](ImportId first, ImportId second) { return first.id - second.id; };
|
auto compareKey = [](ModuleId first, ModuleId second) { return first.id - second.id; };
|
||||||
|
|
||||||
auto insert = [&](ImportId importId) {
|
auto insert = [&](ModuleId moduleId) {
|
||||||
insertImportIdForSourceIdStatement.write(&sourceId, &importId);
|
insertModuleIdForSourceIdStatement.write(&sourceId, &moduleId);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto update = [](ImportId, ImportId) {};
|
auto update = [](ModuleId, ModuleId) {};
|
||||||
|
|
||||||
auto remove = [&](ImportId importId) {
|
auto remove = [&](ModuleId moduleId) {
|
||||||
deleteImportIdForSourceIdStatement.write(&sourceId, &importId);
|
deleteModuleIdForSourceIdStatement.write(&sourceId, &moduleId);
|
||||||
};
|
};
|
||||||
|
|
||||||
Sqlite::insertUpdateDelete(range, importIds, compareKey, insert, update, remove);
|
Sqlite::insertUpdateDelete(range, moduleIds, compareKey, insert, update, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::PathString createJson(const Storage::ParameterDeclarations ¶meters)
|
Utils::PathString createJson(const Storage::ParameterDeclarations ¶meters)
|
||||||
@@ -1246,28 +1246,28 @@ private:
|
|||||||
|
|
||||||
TypeId declareType(Storage::Type &type)
|
TypeId declareType(Storage::Type &type)
|
||||||
{
|
{
|
||||||
if (type.import.name.isEmpty() && type.typeName.isEmpty()) {
|
if (type.module.name.isEmpty() && type.typeName.isEmpty()) {
|
||||||
type.typeId = selectTypeIdBySourceIdStatement.template value<TypeId>(&type.sourceId);
|
type.typeId = selectTypeIdBySourceIdStatement.template value<TypeId>(&type.sourceId);
|
||||||
return type.typeId;
|
return type.typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportId importId = fetchImportId(type.import);
|
ModuleId moduleId = fetchModuleId(type.module);
|
||||||
|
|
||||||
if (!importId)
|
if (!moduleId)
|
||||||
throw ImportDoesNotExists{};
|
throw ModuleDoesNotExists{};
|
||||||
|
|
||||||
type.typeId = upsertTypeStatement.template value<TypeId>(&importId,
|
type.typeId = upsertTypeStatement.template value<TypeId>(&moduleId,
|
||||||
type.typeName,
|
type.typeName,
|
||||||
static_cast<int>(type.accessSemantics),
|
static_cast<int>(type.accessSemantics),
|
||||||
&type.sourceId);
|
&type.sourceId);
|
||||||
|
|
||||||
if (!type.typeId)
|
if (!type.typeId)
|
||||||
type.typeId = selectTypeIdByImportIdAndNameStatement.template value<TypeId>(&importId,
|
type.typeId = selectTypeIdByModuleIdAndNameStatement.template value<TypeId>(&moduleId,
|
||||||
type.typeName);
|
type.typeName);
|
||||||
upsertNativeType(importId, type.typeName, type.typeId);
|
upsertNativeType(moduleId, type.typeName, type.typeId);
|
||||||
|
|
||||||
for (const auto &exportedType : type.exportedTypes)
|
for (const auto &exportedType : type.exportedTypes)
|
||||||
upsertExportedType(importId, exportedType.name, type.typeId);
|
upsertExportedType(moduleId, exportedType.name, type.typeId);
|
||||||
|
|
||||||
return type.typeId;
|
return type.typeId;
|
||||||
}
|
}
|
||||||
@@ -1367,27 +1367,27 @@ private:
|
|||||||
{
|
{
|
||||||
auto operator()(const Storage::NativeType &nativeType)
|
auto operator()(const Storage::NativeType &nativeType)
|
||||||
{
|
{
|
||||||
return storage.selectTypeIdByImportIdsFromSourceIdAndNameStatement
|
return storage.selectTypeIdByModuleIdsFromSourceIdAndNameStatement
|
||||||
.template value<TypeIdAndTypeNameId>(&sourceId, nativeType.name);
|
.template value<TypeIdAndTypeNameId>(&sourceId, nativeType.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto operator()(const Storage::ExportedType &exportedType)
|
auto operator()(const Storage::ExportedType &exportedType)
|
||||||
{
|
{
|
||||||
return storage.selectTypeIdByImportIdsFromSourceIdAndExportedNameStatement
|
return storage.selectTypeIdByModuleIdsFromSourceIdAndExportedNameStatement
|
||||||
.template value<TypeIdAndTypeNameId>(&sourceId, exportedType.name);
|
.template value<TypeIdAndTypeNameId>(&sourceId, exportedType.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto operator()(const Storage::ExplicitExportedType &exportedType)
|
auto operator()(const Storage::ExplicitExportedType &exportedType)
|
||||||
{
|
{
|
||||||
if (exportedType.import.version) {
|
if (exportedType.module.version) {
|
||||||
return storage.selectTypeIdByImportNameAndVersionAndExportedNameStatement
|
return storage.selectTypeIdByModuleNameAndVersionAndExportedNameStatement
|
||||||
.template value<TypeIdAndTypeNameId>(exportedType.import.name,
|
.template value<TypeIdAndTypeNameId>(exportedType.module.name,
|
||||||
exportedType.import.version.version,
|
exportedType.module.version.version,
|
||||||
exportedType.name);
|
exportedType.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return storage.selectTypeIdByImportNameAndExportedNameStatement
|
return storage.selectTypeIdByModuleNameAndExportedNameStatement
|
||||||
.template value<TypeIdAndTypeNameId>(exportedType.import.name, exportedType.name);
|
.template value<TypeIdAndTypeNameId>(exportedType.module.name, exportedType.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectStorage &storage;
|
ProjectStorage &storage;
|
||||||
@@ -1542,8 +1542,8 @@ private:
|
|||||||
if (!isInitialized) {
|
if (!isInitialized) {
|
||||||
Sqlite::ExclusiveTransaction transaction{database};
|
Sqlite::ExclusiveTransaction transaction{database};
|
||||||
|
|
||||||
createImportsTable(database);
|
createModulesTable(database);
|
||||||
createImportDependeciesTable(database);
|
createModuleDependeciesTable(database);
|
||||||
createSourceContextsTable(database);
|
createSourceContextsTable(database);
|
||||||
createSourcesTable(database);
|
createSourcesTable(database);
|
||||||
createTypesAndePropertyDeclarationsTables(database);
|
createTypesAndePropertyDeclarationsTables(database);
|
||||||
@@ -1551,7 +1551,7 @@ private:
|
|||||||
createEnumerationsTable(database);
|
createEnumerationsTable(database);
|
||||||
createFunctionsTable(database);
|
createFunctionsTable(database);
|
||||||
createSignalsTable(database);
|
createSignalsTable(database);
|
||||||
createSourceImportsTable(database);
|
createSourceModulesTable(database);
|
||||||
createFileStatusesTable(database);
|
createFileStatusesTable(database);
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
@@ -1599,7 +1599,7 @@ private:
|
|||||||
typesTable.setUseIfNotExists(true);
|
typesTable.setUseIfNotExists(true);
|
||||||
typesTable.setName("types");
|
typesTable.setName("types");
|
||||||
typesTable.addColumn("typeId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
typesTable.addColumn("typeId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||||
auto &importIdColumn = typesTable.addColumn("importId");
|
auto &moduleIdColumn = typesTable.addColumn("moduleId");
|
||||||
auto &typesNameColumn = typesTable.addColumn("name");
|
auto &typesNameColumn = typesTable.addColumn("name");
|
||||||
typesTable.addColumn("accessSemantics");
|
typesTable.addColumn("accessSemantics");
|
||||||
typesTable.addColumn("sourceId");
|
typesTable.addColumn("sourceId");
|
||||||
@@ -1609,7 +1609,7 @@ private:
|
|||||||
Sqlite::ForeignKeyAction::Restrict);
|
Sqlite::ForeignKeyAction::Restrict);
|
||||||
typesTable.addColumn("prototypeNameId");
|
typesTable.addColumn("prototypeNameId");
|
||||||
|
|
||||||
typesTable.addUniqueIndex({importIdColumn, typesNameColumn});
|
typesTable.addUniqueIndex({moduleIdColumn, typesNameColumn});
|
||||||
|
|
||||||
typesTable.initialize(database);
|
typesTable.initialize(database);
|
||||||
|
|
||||||
@@ -1648,12 +1648,14 @@ private:
|
|||||||
table.setUseIfNotExists(true);
|
table.setUseIfNotExists(true);
|
||||||
table.setName("typeNames");
|
table.setName("typeNames");
|
||||||
table.addColumn("typeNameId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
table.addColumn("typeNameId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||||
auto &importIdColumn = table.addColumn("importId");
|
auto &moduleIdColumn = table.addColumn("moduleId");
|
||||||
auto &nameColumn = table.addColumn("name");
|
auto &nameColumn = table.addColumn("name");
|
||||||
auto &kindColumn = table.addColumn("kind");
|
auto &kindColumn = table.addColumn("kind");
|
||||||
|
table.addColumn("majorVersion");
|
||||||
|
table.addColumn("minorVersion");
|
||||||
table.addColumn("typeId");
|
table.addColumn("typeId");
|
||||||
|
|
||||||
table.addUniqueIndex({importIdColumn, nameColumn, kindColumn});
|
table.addUniqueIndex({moduleIdColumn, nameColumn, kindColumn});
|
||||||
|
|
||||||
table.initialize(database);
|
table.initialize(database);
|
||||||
}
|
}
|
||||||
@@ -1708,12 +1710,12 @@ private:
|
|||||||
table.initialize(database);
|
table.initialize(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createImportsTable(Database &database)
|
void createModulesTable(Database &database)
|
||||||
{
|
{
|
||||||
Sqlite::Table table;
|
Sqlite::Table table;
|
||||||
table.setUseIfNotExists(true);
|
table.setUseIfNotExists(true);
|
||||||
table.setName("imports");
|
table.setName("modules");
|
||||||
table.addColumn("importId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
table.addColumn("moduleId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||||
auto &nameColumn = table.addColumn("name");
|
auto &nameColumn = table.addColumn("name");
|
||||||
auto &versionColumn = table.addColumn("version");
|
auto &versionColumn = table.addColumn("version");
|
||||||
|
|
||||||
@@ -1722,30 +1724,30 @@ private:
|
|||||||
table.initialize(database);
|
table.initialize(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createImportDependeciesTable(Database &database)
|
void createModuleDependeciesTable(Database &database)
|
||||||
{
|
{
|
||||||
Sqlite::Table table;
|
Sqlite::Table table;
|
||||||
table.setUseIfNotExists(true);
|
table.setUseIfNotExists(true);
|
||||||
table.setUseWithoutRowId(true);
|
table.setUseWithoutRowId(true);
|
||||||
table.setName("importDependencies");
|
table.setName("moduleDependencies");
|
||||||
auto &importIdColumn = table.addColumn("importId");
|
auto &moduleIdColumn = table.addColumn("moduleId");
|
||||||
auto &parentImportIdColumn = table.addColumn("parentImportId");
|
auto &parentModuleIdColumn = table.addColumn("parentModuleId");
|
||||||
|
|
||||||
table.addPrimaryKeyContraint({importIdColumn, parentImportIdColumn});
|
table.addPrimaryKeyContraint({moduleIdColumn, parentModuleIdColumn});
|
||||||
|
|
||||||
table.initialize(database);
|
table.initialize(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSourceImportsTable(Database &database)
|
void createSourceModulesTable(Database &database)
|
||||||
{
|
{
|
||||||
Sqlite::Table table;
|
Sqlite::Table table;
|
||||||
table.setUseIfNotExists(true);
|
table.setUseIfNotExists(true);
|
||||||
table.setUseWithoutRowId(true);
|
table.setUseWithoutRowId(true);
|
||||||
table.setName("documentImports");
|
table.setName("documentModules");
|
||||||
auto &sourceIdColumn = table.addColumn("sourceId");
|
auto &sourceIdColumn = table.addColumn("sourceId");
|
||||||
auto &importIdColumn = table.addColumn("importId");
|
auto &moduleIdColumn = table.addColumn("moduleId");
|
||||||
|
|
||||||
table.addPrimaryKeyContraint({sourceIdColumn, importIdColumn});
|
table.addPrimaryKeyContraint({sourceIdColumn, moduleIdColumn});
|
||||||
|
|
||||||
table.initialize(database);
|
table.initialize(database);
|
||||||
}
|
}
|
||||||
@@ -1773,7 +1775,7 @@ public:
|
|||||||
Database &database;
|
Database &database;
|
||||||
Initializer initializer;
|
Initializer initializer;
|
||||||
ReadWriteStatement<1> upsertTypeStatement{
|
ReadWriteStatement<1> upsertTypeStatement{
|
||||||
"INSERT INTO types(importId, name, accessSemantics, sourceId) VALUES(?1, ?2, "
|
"INSERT INTO types(moduleId, name, accessSemantics, sourceId) VALUES(?1, ?2, "
|
||||||
"?3, nullif(?4, -1)) ON CONFLICT DO UPDATE SET accessSemantics=excluded.accessSemantics, "
|
"?3, nullif(?4, -1)) ON CONFLICT DO UPDATE SET accessSemantics=excluded.accessSemantics, "
|
||||||
"sourceId=excluded.sourceId WHERE accessSemantics IS NOT excluded.accessSemantics OR "
|
"sourceId=excluded.sourceId WHERE accessSemantics IS NOT excluded.accessSemantics OR "
|
||||||
"sourceId IS NOT excluded.sourceId RETURNING typeId",
|
"sourceId IS NOT excluded.sourceId RETURNING typeId",
|
||||||
@@ -1814,8 +1816,11 @@ public:
|
|||||||
" WHERE name=?2 ORDER BY level LIMIT 1",
|
" WHERE name=?2 ORDER BY level LIMIT 1",
|
||||||
database};
|
database};
|
||||||
WriteStatement upsertTypeNamesStatement{
|
WriteStatement upsertTypeNamesStatement{
|
||||||
"INSERT INTO typeNames(importId, name, typeId, kind) VALUES(?1, ?2, ?3, ?4) ON CONFLICT DO "
|
"INSERT INTO typeNames(moduleId, name, kind, majorVersion, minorVersion, typeId) "
|
||||||
"UPDATE SET typeId=excluded.typeId WHERE typeId IS NOT excluded.typeId",
|
"VALUES(?1, ?2, ?3, ?4, ?5, ?6) ON CONFLICT DO UPDATE SET typeId=excluded.typeId, "
|
||||||
|
"majorVersion=excluded.majorVersion, minorVersion=excluded.minorVersion WHERE typeId IS "
|
||||||
|
"NOT excluded.typeId OR majorVersion IS NOT excluded.majorVersion OR minorVersion IS NOT "
|
||||||
|
"excluded.minorVersion",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<1> selectPrototypeIdsStatement{
|
mutable ReadStatement<1> selectPrototypeIdsStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
@@ -1844,14 +1849,14 @@ public:
|
|||||||
"INSERT INTO sources(sourceContextId, sourceName) VALUES (?,?)", database};
|
"INSERT INTO sources(sourceContextId, sourceName) VALUES (?,?)", database};
|
||||||
mutable ReadStatement<3> selectAllSourcesStatement{
|
mutable ReadStatement<3> selectAllSourcesStatement{
|
||||||
"SELECT sourceName, sourceContextId, sourceId FROM sources", database};
|
"SELECT sourceName, sourceContextId, sourceId FROM sources", database};
|
||||||
mutable ReadStatement<1> selectTypeIdByImportIdsAndNameStatement{
|
mutable ReadStatement<1> selectTypeIdByModuleIdsAndNameStatement{
|
||||||
"SELECT typeId FROM types WHERE importId IN carray(?1, ?2, 'int64') AND name=?3", database};
|
"SELECT typeId FROM types WHERE moduleId IN carray(?1, ?2, 'int64') AND name=?3", database};
|
||||||
mutable ReadStatement<2> selectTypeIdByImportIdsFromSourceIdAndNameStatement{
|
mutable ReadStatement<2> selectTypeIdByModuleIdsFromSourceIdAndNameStatement{
|
||||||
"SELECT typeId, typeNameId FROM typeNames JOIN documentImports AS di USING(importId) WHERE "
|
"SELECT typeId, typeNameId FROM typeNames JOIN documentModules AS di USING(moduleId) WHERE "
|
||||||
" name=?2 AND kind=0 AND di.sourceId=?1 LIMIT 1",
|
" name=?2 AND kind=0 AND di.sourceId=?1 LIMIT 1",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<5> selectTypeByTypeIdStatement{
|
mutable ReadStatement<5> selectTypeByTypeIdStatement{
|
||||||
"SELECT importId, name, (SELECT name FROM types WHERE typeId=outerTypes.prototypeId), "
|
"SELECT moduleId, name, (SELECT name FROM types WHERE typeId=outerTypes.prototypeId), "
|
||||||
"accessSemantics, ifnull(sourceId, -1) FROM types AS outerTypes WHERE typeId=?",
|
"accessSemantics, ifnull(sourceId, -1) FROM types AS outerTypes WHERE typeId=?",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<1> selectExportedTypesByTypeIdStatement{
|
mutable ReadStatement<1> selectExportedTypesByTypeIdStatement{
|
||||||
@@ -1859,7 +1864,7 @@ public:
|
|||||||
mutable ReadStatement<7> selectTypesStatement{
|
mutable ReadStatement<7> selectTypesStatement{
|
||||||
"SELECT i.name, i.version, t.name, typeId, (SELECT name FROM types WHERE "
|
"SELECT i.name, i.version, t.name, typeId, (SELECT name FROM types WHERE "
|
||||||
"typeId=t.prototypeId), accessSemantics, ifnull(sourceId, -1) FROM types AS "
|
"typeId=t.prototypeId), accessSemantics, ifnull(sourceId, -1) FROM types AS "
|
||||||
"t JOIN imports AS i USING (importId)",
|
"t JOIN modules AS i USING (moduleId)",
|
||||||
database};
|
database};
|
||||||
ReadStatement<1> selectNotUpdatedTypesInSourcesStatement{
|
ReadStatement<1> selectNotUpdatedTypesInSourcesStatement{
|
||||||
"SELECT typeId FROM types WHERE (sourceId IN carray(?1) AND typeId NOT IN carray(?2))",
|
"SELECT typeId FROM types WHERE (sourceId IN carray(?1) AND typeId NOT IN carray(?2))",
|
||||||
@@ -2005,76 +2010,76 @@ public:
|
|||||||
database};
|
database};
|
||||||
WriteStatement deleteEnumerationDeclarationStatement{
|
WriteStatement deleteEnumerationDeclarationStatement{
|
||||||
"DELETE FROM enumerationDeclarations WHERE enumerationDeclarationId=?", database};
|
"DELETE FROM enumerationDeclarations WHERE enumerationDeclarationId=?", database};
|
||||||
WriteStatement insertImportStatement{
|
WriteStatement insertModuleStatement{
|
||||||
"INSERT INTO imports(name, version, importId) VALUES(?1, ?2, ?3)", database};
|
"INSERT INTO modules(name, version, moduleId) VALUES(?1, ?2, ?3)", database};
|
||||||
WriteStatement updateImportStatement{"UPDATE imports SET name=?2, version=?3 WHERE importId=?1",
|
WriteStatement updateModuleStatement{"UPDATE modules SET name=?2, version=?3 WHERE moduleId=?1",
|
||||||
database};
|
database};
|
||||||
WriteStatement deleteImportStatement{"DELETE FROM imports WHERE importId=?", database};
|
WriteStatement deleteModuleStatement{"DELETE FROM modules WHERE moduleId=?", database};
|
||||||
mutable ReadStatement<1> selectImportIdByNameStatement{
|
mutable ReadStatement<1> selectModuleIdByNameStatement{
|
||||||
"SELECT importId FROM imports WHERE name=? ORDER BY version DESC LIMIT 1", database};
|
"SELECT moduleId FROM modules WHERE name=? ORDER BY version DESC LIMIT 1", database};
|
||||||
mutable ReadStatement<1> selectImportIdByNameAndVersionStatement{
|
mutable ReadStatement<1> selectModuleIdByNameAndVersionStatement{
|
||||||
"SELECT importId FROM imports WHERE name=? AND version=?", database};
|
"SELECT moduleId FROM modules WHERE name=? AND version=?", database};
|
||||||
mutable ReadStatement<3> selectImportsForIdsStatement{
|
mutable ReadStatement<3> selectModulesForIdsStatement{
|
||||||
"SELECT name, version, importId FROM imports WHERE importId IN carray(?1) ORDER BY "
|
"SELECT name, version, moduleId FROM modules WHERE moduleId IN carray(?1) ORDER BY "
|
||||||
"importId",
|
"moduleId",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<3> selectAllImportsStatement{
|
mutable ReadStatement<3> selectAllModulesStatement{
|
||||||
"SELECT name, version, importId FROM imports ORDER BY importId", database};
|
"SELECT name, version, moduleId FROM modules ORDER BY moduleId", database};
|
||||||
WriteStatement insertImportDependencyStatement{
|
WriteStatement insertModuleDependencyStatement{
|
||||||
"INSERT INTO importDependencies(importId, parentImportId) VALUES(?1, ?2)", database};
|
"INSERT INTO moduleDependencies(moduleId, parentModuleId) VALUES(?1, ?2)", database};
|
||||||
WriteStatement deleteImportDependencyStatement{
|
WriteStatement deleteModuleDependencyStatement{
|
||||||
"DELETE FROM importDependencies WHERE importId=?1 AND parentImportId=?2", database};
|
"DELETE FROM moduleDependencies WHERE moduleId=?1 AND parentModuleId=?2", database};
|
||||||
mutable ReadStatement<2> selectImportDependenciesForIdsStatement{
|
mutable ReadStatement<2> selectModuleDependenciesForIdsStatement{
|
||||||
"SELECT importId, parentImportId FROM importDependencies WHERE importId IN carray(?1) "
|
"SELECT moduleId, parentModuleId FROM moduleDependencies WHERE moduleId IN carray(?1) "
|
||||||
"ORDER BY importId, parentImportId",
|
"ORDER BY moduleId, parentModuleId",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<2> selectImportsForThatDependentOnThisImportIdStatement{
|
mutable ReadStatement<2> selectModulesForThatDependentOnThisModuleIdStatement{
|
||||||
"SELECT name, version FROM importDependencies JOIN imports ON "
|
"SELECT name, version FROM moduleDependencies JOIN modules ON "
|
||||||
"importDependencies.parentImportId = imports.importId WHERE importDependencies.importId=?",
|
"moduleDependencies.parentModuleId = modules.moduleId WHERE moduleDependencies.moduleId=?",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<1> selectTypeIdsForImportIdStatement{
|
mutable ReadStatement<1> selectTypeIdsForModuleIdStatement{
|
||||||
"SELECT typeId FROM types WHERE importId=?", database};
|
"SELECT typeId FROM types WHERE moduleId=?", database};
|
||||||
mutable ReadStatement<1> selectTypeIdByImportIdAndNameStatement{
|
mutable ReadStatement<1> selectTypeIdByModuleIdAndNameStatement{
|
||||||
"SELECT typeId FROM types WHERE importId=?1 and name=?2", database};
|
"SELECT typeId FROM types WHERE moduleId=?1 and name=?2", database};
|
||||||
mutable ReadStatement<1> selectTypeIdByImportIdsAndExportedNameStatement{
|
mutable ReadStatement<1> selectTypeIdByModuleIdsAndExportedNameStatement{
|
||||||
"SELECT typeId FROM typeNames WHERE importId IN carray(?1, ?2, 'int64') AND name=?3 AND "
|
"SELECT typeId FROM typeNames WHERE moduleId IN carray(?1, ?2, 'int64') AND name=?3 AND "
|
||||||
"kind=1",
|
"kind=1",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<2> selectTypeIdByImportIdsFromSourceIdAndExportedNameStatement{
|
mutable ReadStatement<2> selectTypeIdByModuleIdsFromSourceIdAndExportedNameStatement{
|
||||||
"SELECT typeId, typeNameId FROM typeNames JOIN documentImports AS di USING(importId) WHERE "
|
"SELECT typeId, typeNameId FROM typeNames JOIN documentModules AS di USING(moduleId) WHERE "
|
||||||
"name=?2 AND kind=1 AND di.sourceId=?1 LIMIT 1",
|
"name=?2 AND kind=1 AND di.sourceId=?1 LIMIT 1",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<2> selectTypeIdByImportNameAndExportedNameStatement{
|
mutable ReadStatement<2> selectTypeIdByModuleNameAndExportedNameStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
" highestImport(importId) AS ( "
|
" highestModule(moduleId) AS ( "
|
||||||
" SELECT importId FROM imports WHERE name=?1 ORDER BY version DESC LIMIT 1) "
|
" SELECT moduleId FROM modules WHERE name=?1 ORDER BY version DESC LIMIT 1) "
|
||||||
"SELECT typeId, -typeNameId FROM typeNames JOIN highestImport USING(importId) WHERE "
|
"SELECT typeId, -typeNameId FROM typeNames JOIN highestModule USING(moduleId) WHERE "
|
||||||
" name=?2 AND kind=1 LIMIT 1",
|
" name=?2 AND kind=1 LIMIT 1",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<2> selectTypeIdByImportNameAndVersionAndExportedNameStatement{
|
mutable ReadStatement<2> selectTypeIdByModuleNameAndVersionAndExportedNameStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
" highestImport(importId) AS ( "
|
" highestModule(moduleId) AS ( "
|
||||||
" SELECT importId FROM imports WHERE name=?1 AND version=?2 ORDER BY version DESC LIMIT "
|
" SELECT moduleId FROM modules WHERE name=?1 AND version=?2 ORDER BY version DESC LIMIT "
|
||||||
" 1) "
|
" 1) "
|
||||||
"SELECT typeId, -typeNameId FROM typeNames JOIN highestImport USING(importId) WHERE "
|
"SELECT typeId, -typeNameId FROM typeNames JOIN highestModule USING(moduleId) WHERE "
|
||||||
" name=?3 AND kind=1 LIMIT 1",
|
" name=?3 AND kind=1 LIMIT 1",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<1> fetchImportDependencyIdsStatement{
|
mutable ReadStatement<1> fetchModuleDependencyIdsStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
" importIds(importId) AS ("
|
" moduleIds(moduleId) AS ("
|
||||||
" SELECT value FROM carray(?1, ?2, 'int64') "
|
" SELECT value FROM carray(?1, ?2, 'int64') "
|
||||||
" UNION "
|
" UNION "
|
||||||
" SELECT parentImportId FROM importDependencies JOIN importIds USING(importId)) "
|
" SELECT parentModuleId FROM moduleDependencies JOIN moduleIds USING(moduleId)) "
|
||||||
"SELECT importId FROM importIds",
|
"SELECT moduleId FROM moduleIds",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<1> selectImportIdsForSourceIdStatement{
|
mutable ReadStatement<1> selectModuleIdsForSourceIdStatement{
|
||||||
"SELECT importId FROM documentImports WHERE sourceId=? ORDER BY importId", database};
|
"SELECT moduleId FROM documentModules WHERE sourceId=? ORDER BY moduleId", database};
|
||||||
WriteStatement insertImportIdForSourceIdStatement{
|
WriteStatement insertModuleIdForSourceIdStatement{
|
||||||
"INSERT INTO documentImports(sourceId, importId) VALUES (?1, ?2)", database};
|
"INSERT INTO documentModules(sourceId, moduleId) VALUES (?1, ?2)", database};
|
||||||
WriteStatement deleteImportIdForSourceIdStatement{
|
WriteStatement deleteModuleIdForSourceIdStatement{
|
||||||
"DELETE FROM documentImports WHERE sourceId=?1 AND importId=?2", database};
|
"DELETE FROM documentModules WHERE sourceId=?1 AND moduleId=?2", database};
|
||||||
WriteStatement deleteDocumentImportsWithSourceIdsStatement{
|
WriteStatement deleteDocumentModulesWithSourceIdsStatement{
|
||||||
"DELETE FROM documentImports WHERE sourceId=?1 IN carray(?1)", database};
|
"DELETE FROM documentModules WHERE sourceId=?1 IN carray(?1)", database};
|
||||||
ReadStatement<1> selectPropertyDeclarationIdPrototypeChainDownStatement{
|
ReadStatement<1> selectPropertyDeclarationIdPrototypeChainDownStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
" typeSelection(typeId, level) AS ("
|
" typeSelection(typeId, level) AS ("
|
||||||
@@ -2130,7 +2135,7 @@ public:
|
|||||||
ReadStatement<2> selectTypeNameStatement{"SELECT name, kind FROM typeNames WHERE typeNameId=?",
|
ReadStatement<2> selectTypeNameStatement{"SELECT name, kind FROM typeNames WHERE typeNameId=?",
|
||||||
database};
|
database};
|
||||||
ReadStatement<3> selectExplicitTypeNameStatement{
|
ReadStatement<3> selectExplicitTypeNameStatement{
|
||||||
"SELECT tn.name, i.name, i.version FROM typeNames AS tn JOIN imports AS i USING(importId) "
|
"SELECT tn.name, i.name, i.version FROM typeNames AS tn JOIN modules AS i USING(moduleId) "
|
||||||
"WHERE typeNameId=? AND kind=1",
|
"WHERE typeNameId=? AND kind=1",
|
||||||
database};
|
database};
|
||||||
ReadStatement<1> selectPropertyNameStatement{
|
ReadStatement<1> selectPropertyNameStatement{
|
||||||
|
@@ -71,10 +71,10 @@ public:
|
|||||||
const char *what() const noexcept override { return "The source id is invalid!"; }
|
const char *what() const noexcept override { return "The source id is invalid!"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImportDoesNotExists : std::exception
|
class ModuleDoesNotExists : std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char *what() const noexcept override { return "The import does not exist!"; }
|
const char *what() const noexcept override { return "The module does not exist!"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TypeNameDoesNotExists : std::exception
|
class TypeNameDoesNotExists : std::exception
|
||||||
|
@@ -33,7 +33,7 @@ namespace QmlDesigner {
|
|||||||
class ProjectStorageInterface
|
class ProjectStorageInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void synchronize(Storage::ImportDependencies importDependencies,
|
virtual void synchronize(Storage::ModuleDependencies moduleDependencies,
|
||||||
Storage::Documents documents,
|
Storage::Documents documents,
|
||||||
Storage::Types types,
|
Storage::Types types,
|
||||||
SourceIds sourceIds,
|
SourceIds sourceIds,
|
||||||
|
@@ -110,22 +110,22 @@ public:
|
|||||||
VersionNumber minor;
|
VersionNumber minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Import
|
class Module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Import() = default;
|
explicit Module() = default;
|
||||||
|
|
||||||
explicit Import(Utils::SmallStringView name, VersionNumber version = VersionNumber{})
|
explicit Module(Utils::SmallStringView name, VersionNumber version = VersionNumber{})
|
||||||
: name{name}
|
: name{name}
|
||||||
, version{version}
|
, version{version}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit Import(Utils::SmallStringView name, int version)
|
explicit Module(Utils::SmallStringView name, int version)
|
||||||
: name{name}
|
: name{name}
|
||||||
, version{version}
|
, version{version}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
friend bool operator==(const Import &first, const Import &second)
|
friend bool operator==(const Module &first, const Module &second)
|
||||||
{
|
{
|
||||||
return first.name == second.name && first.version == second.version;
|
return first.name == second.name && first.version == second.version;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
VersionNumber version;
|
VersionNumber version;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Imports = std::vector<Import>;
|
using Modules = std::vector<Module>;
|
||||||
|
|
||||||
class ExportedType
|
class ExportedType
|
||||||
{
|
{
|
||||||
@@ -158,19 +158,19 @@ class ExplicitExportedType
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ExplicitExportedType() = default;
|
explicit ExplicitExportedType() = default;
|
||||||
explicit ExplicitExportedType(Utils::SmallStringView name, Import import)
|
explicit ExplicitExportedType(Utils::SmallStringView name, Module module)
|
||||||
: name{name}
|
: name{name}
|
||||||
, import{std::move(import)}
|
, module{std::move(module)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
friend bool operator==(const ExplicitExportedType &first, const ExplicitExportedType &second)
|
friend bool operator==(const ExplicitExportedType &first, const ExplicitExportedType &second)
|
||||||
{
|
{
|
||||||
return first.name == second.name && first.import == second.import;
|
return first.name == second.name && first.module == second.module;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Utils::SmallString name;
|
Utils::SmallString name;
|
||||||
Import import;
|
Module module;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ExportedTypes = std::vector<ExportedType>;
|
using ExportedTypes = std::vector<ExportedType>;
|
||||||
@@ -485,7 +485,7 @@ class Type
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Type() = default;
|
explicit Type() = default;
|
||||||
explicit Type(Import import,
|
explicit Type(Module module,
|
||||||
Utils::SmallStringView typeName,
|
Utils::SmallStringView typeName,
|
||||||
TypeName prototype,
|
TypeName prototype,
|
||||||
TypeAccessSemantics accessSemantics,
|
TypeAccessSemantics accessSemantics,
|
||||||
@@ -503,28 +503,28 @@ public:
|
|||||||
, functionDeclarations{std::move(functionDeclarations)}
|
, functionDeclarations{std::move(functionDeclarations)}
|
||||||
, signalDeclarations{std::move(signalDeclarations)}
|
, signalDeclarations{std::move(signalDeclarations)}
|
||||||
, enumerationDeclarations{std::move(enumerationDeclarations)}
|
, enumerationDeclarations{std::move(enumerationDeclarations)}
|
||||||
, import{std::move(import)}
|
, module{std::move(module)}
|
||||||
, accessSemantics{accessSemantics}
|
, accessSemantics{accessSemantics}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
, typeId{typeId}
|
, typeId{typeId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit Type(Utils::SmallStringView importName,
|
explicit Type(Utils::SmallStringView moduleName,
|
||||||
int importVersion,
|
int moduleVersion,
|
||||||
Utils::SmallStringView typeName,
|
Utils::SmallStringView typeName,
|
||||||
Utils::SmallStringView prototype,
|
Utils::SmallStringView prototype,
|
||||||
int accessSemantics,
|
int accessSemantics,
|
||||||
int sourceId)
|
int sourceId)
|
||||||
: typeName{typeName}
|
: typeName{typeName}
|
||||||
, prototype{NativeType{prototype}}
|
, prototype{NativeType{prototype}}
|
||||||
, import{importName, importVersion}
|
, module{moduleName, moduleVersion}
|
||||||
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit Type(Utils::SmallStringView importName,
|
explicit Type(Utils::SmallStringView moduleName,
|
||||||
int importVersion,
|
int moduleVersion,
|
||||||
Utils::SmallStringView typeName,
|
Utils::SmallStringView typeName,
|
||||||
long long typeId,
|
long long typeId,
|
||||||
Utils::SmallStringView prototype,
|
Utils::SmallStringView prototype,
|
||||||
@@ -532,7 +532,7 @@ public:
|
|||||||
int sourceId)
|
int sourceId)
|
||||||
: typeName{typeName}
|
: typeName{typeName}
|
||||||
, prototype{NativeType{prototype}}
|
, prototype{NativeType{prototype}}
|
||||||
, import{importName, importVersion}
|
, module{moduleName, moduleVersion}
|
||||||
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
, typeId{typeId}
|
, typeId{typeId}
|
||||||
@@ -545,7 +545,7 @@ public:
|
|||||||
&& first.propertyDeclarations == second.propertyDeclarations
|
&& first.propertyDeclarations == second.propertyDeclarations
|
||||||
&& first.functionDeclarations == second.functionDeclarations
|
&& first.functionDeclarations == second.functionDeclarations
|
||||||
&& first.signalDeclarations == second.signalDeclarations
|
&& first.signalDeclarations == second.signalDeclarations
|
||||||
&& first.import == second.import && first.sourceId == second.sourceId
|
&& first.module == second.module && first.sourceId == second.sourceId
|
||||||
&& first.sourceId == second.sourceId;
|
&& first.sourceId == second.sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +557,7 @@ public:
|
|||||||
FunctionDeclarations functionDeclarations;
|
FunctionDeclarations functionDeclarations;
|
||||||
SignalDeclarations signalDeclarations;
|
SignalDeclarations signalDeclarations;
|
||||||
EnumerationDeclarations enumerationDeclarations;
|
EnumerationDeclarations enumerationDeclarations;
|
||||||
Import import;
|
Module module;
|
||||||
TypeAccessSemantics accessSemantics = TypeAccessSemantics::Invalid;
|
TypeAccessSemantics accessSemantics = TypeAccessSemantics::Invalid;
|
||||||
SourceId sourceId;
|
SourceId sourceId;
|
||||||
TypeId typeId;
|
TypeId typeId;
|
||||||
@@ -569,58 +569,58 @@ class Document
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Document() = default;
|
explicit Document() = default;
|
||||||
explicit Document(SourceId sourceId, Imports imports)
|
explicit Document(SourceId sourceId, Modules modules)
|
||||||
: imports{std::move(imports)}
|
: modules{std::move(modules)}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Imports imports;
|
Modules modules;
|
||||||
SourceId sourceId;
|
SourceId sourceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Documents = std::vector<Document>;
|
using Documents = std::vector<Document>;
|
||||||
|
|
||||||
class ImportDependency : public Import
|
class ModuleDependency : public Module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ImportDependency(Utils::SmallStringView name,
|
explicit ModuleDependency(Utils::SmallStringView name,
|
||||||
VersionNumber version,
|
VersionNumber version,
|
||||||
SourceId sourceId,
|
SourceId sourceId,
|
||||||
Imports importDependencies = {})
|
Modules moduleDependencies = {})
|
||||||
: Import(name, version)
|
: Module(name, version)
|
||||||
, dependencies{std::move(importDependencies)}
|
, dependencies{std::move(moduleDependencies)}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit ImportDependency(Utils::SmallStringView name, int version, int sourceId)
|
explicit ModuleDependency(Utils::SmallStringView name, int version, int sourceId)
|
||||||
: Import(name, version)
|
: Module(name, version)
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
friend bool operator==(const ImportDependency &first, const ImportDependency &second)
|
friend bool operator==(const ModuleDependency &first, const ModuleDependency &second)
|
||||||
{
|
{
|
||||||
return static_cast<const Import &>(first) == static_cast<const Import &>(second)
|
return static_cast<const Module &>(first) == static_cast<const Module &>(second)
|
||||||
&& first.sourceId == second.sourceId && first.dependencies == second.dependencies;
|
&& first.sourceId == second.sourceId && first.dependencies == second.dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Imports dependencies;
|
Modules dependencies;
|
||||||
SourceId sourceId;
|
SourceId sourceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ImportDependencies = std::vector<ImportDependency>;
|
using ModuleDependencies = std::vector<ModuleDependency>;
|
||||||
|
|
||||||
class ImportView
|
class ModuleView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ImportView(Utils::SmallStringView name, int version, int sourceId)
|
explicit ModuleView(Utils::SmallStringView name, int version, int sourceId)
|
||||||
: name{name}
|
: name{name}
|
||||||
, version{version}
|
, version{version}
|
||||||
, sourceId{sourceId}
|
, sourceId{sourceId}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
friend bool operator==(const ImportView &first, const ImportView &second)
|
friend bool operator==(const ModuleView &first, const ModuleView &second)
|
||||||
{
|
{
|
||||||
return first.name == second.name && first.version == second.version
|
return first.name == second.name && first.version == second.version
|
||||||
&& first.sourceId == second.sourceId;
|
&& first.sourceId == second.sourceId;
|
||||||
|
@@ -52,7 +52,7 @@ ComponentReferences createComponentReferences(const QMultiHash<QString, QmlDirPa
|
|||||||
|
|
||||||
void ProjectUpdater::update()
|
void ProjectUpdater::update()
|
||||||
{
|
{
|
||||||
Storage::ImportDependencies importDependencies;
|
Storage::ModuleDependencies moduleDependencies;
|
||||||
Storage::Documents documents;
|
Storage::Documents documents;
|
||||||
Storage::Types types;
|
Storage::Types types;
|
||||||
SourceIds sourceIds;
|
SourceIds sourceIds;
|
||||||
@@ -72,18 +72,18 @@ void ProjectUpdater::update()
|
|||||||
Utils::SmallString moduleName{parser.typeNamespace()};
|
Utils::SmallString moduleName{parser.typeNamespace()};
|
||||||
SourceContextId directoryId = m_pathCache.sourceContextId(qmlDirSourceId);
|
SourceContextId directoryId = m_pathCache.sourceContextId(qmlDirSourceId);
|
||||||
|
|
||||||
parseTypeInfos(parser.typeInfos(), directoryId, importDependencies, types, sourceIds);
|
parseTypeInfos(parser.typeInfos(), directoryId, moduleDependencies, types, sourceIds);
|
||||||
parseQmlComponents(createComponentReferences(parser.components()),
|
parseQmlComponents(createComponentReferences(parser.components()),
|
||||||
directoryId,
|
directoryId,
|
||||||
moduleName,
|
moduleName,
|
||||||
importDependencies,
|
moduleDependencies,
|
||||||
types,
|
types,
|
||||||
sourceIds);
|
sourceIds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileState::NotChanged: {
|
case FileState::NotChanged: {
|
||||||
SourceIds qmltypesSourceIds = m_projectStorage.fetchSourceDependencieIds(qmlDirSourceId);
|
SourceIds qmltypesSourceIds = m_projectStorage.fetchSourceDependencieIds(qmlDirSourceId);
|
||||||
parseTypeInfos(qmltypesSourceIds, importDependencies, types, sourceIds);
|
parseTypeInfos(qmltypesSourceIds, moduleDependencies, types, sourceIds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileState::NotExists: {
|
case FileState::NotExists: {
|
||||||
@@ -93,7 +93,7 @@ void ProjectUpdater::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_projectStorage.synchronize(std::move(importDependencies),
|
m_projectStorage.synchronize(std::move(moduleDependencies),
|
||||||
std::move(documents),
|
std::move(documents),
|
||||||
std::move(types),
|
std::move(types),
|
||||||
std::move(sourceIds),
|
std::move(sourceIds),
|
||||||
@@ -102,7 +102,7 @@ void ProjectUpdater::update()
|
|||||||
|
|
||||||
void ProjectUpdater::parseTypeInfos(const QStringList &typeInfos,
|
void ProjectUpdater::parseTypeInfos(const QStringList &typeInfos,
|
||||||
SourceContextId directoryId,
|
SourceContextId directoryId,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds)
|
SourceIds &sourceIds)
|
||||||
{
|
{
|
||||||
@@ -112,39 +112,39 @@ void ProjectUpdater::parseTypeInfos(const QStringList &typeInfos,
|
|||||||
SourceId sourceId = m_pathCache.sourceId(directoryId, Utils::SmallString{typeInfo});
|
SourceId sourceId = m_pathCache.sourceId(directoryId, Utils::SmallString{typeInfo});
|
||||||
QString qmltypesPath = directory + "/" + typeInfo;
|
QString qmltypesPath = directory + "/" + typeInfo;
|
||||||
|
|
||||||
parseTypeInfo(sourceId, qmltypesPath, importDependencies, types, sourceIds);
|
parseTypeInfo(sourceId, qmltypesPath, moduleDependencies, types, sourceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectUpdater::parseTypeInfos(const SourceIds &qmltypesSourceIds,
|
void ProjectUpdater::parseTypeInfos(const SourceIds &qmltypesSourceIds,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds)
|
SourceIds &sourceIds)
|
||||||
{
|
{
|
||||||
for (SourceId sourceId : qmltypesSourceIds) {
|
for (SourceId sourceId : qmltypesSourceIds) {
|
||||||
QString qmltypesPath = m_pathCache.sourcePath(sourceId).toQString();
|
QString qmltypesPath = m_pathCache.sourcePath(sourceId).toQString();
|
||||||
|
|
||||||
parseTypeInfo(sourceId, qmltypesPath, importDependencies, types, sourceIds);
|
parseTypeInfo(sourceId, qmltypesPath, moduleDependencies, types, sourceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectUpdater::parseTypeInfo(SourceId sourceId,
|
void ProjectUpdater::parseTypeInfo(SourceId sourceId,
|
||||||
const QString &qmltypesPath,
|
const QString &qmltypesPath,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds)
|
SourceIds &sourceIds)
|
||||||
{
|
{
|
||||||
if (fileState(sourceId) == FileState::Changed) {
|
if (fileState(sourceId) == FileState::Changed) {
|
||||||
sourceIds.push_back(sourceId);
|
sourceIds.push_back(sourceId);
|
||||||
const auto content = m_fileSystem.contentAsQString(qmltypesPath);
|
const auto content = m_fileSystem.contentAsQString(qmltypesPath);
|
||||||
m_qmlTypesParser.parse(content, importDependencies, types, sourceIds);
|
m_qmlTypesParser.parse(content, moduleDependencies, types, sourceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectUpdater::parseQmlComponents(ComponentReferences components,
|
void ProjectUpdater::parseQmlComponents(ComponentReferences components,
|
||||||
SourceContextId directoryId,
|
SourceContextId directoryId,
|
||||||
Utils::SmallStringView moduleName,
|
Utils::SmallStringView moduleName,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds)
|
SourceIds &sourceIds)
|
||||||
{
|
{
|
||||||
@@ -172,8 +172,8 @@ void ProjectUpdater::parseQmlComponents(ComponentReferences components,
|
|||||||
auto type = m_qmlDocumentParser.parse(content);
|
auto type = m_qmlDocumentParser.parse(content);
|
||||||
|
|
||||||
type.typeName = fileName;
|
type.typeName = fileName;
|
||||||
type.import.name = moduleName;
|
type.module.name = moduleName;
|
||||||
type.import.version.version = component.majorVersion;
|
type.module.version.version = component.majorVersion;
|
||||||
type.accessSemantics = Storage::TypeAccessSemantics::Reference;
|
type.accessSemantics = Storage::TypeAccessSemantics::Reference;
|
||||||
type.sourceId = sourceId;
|
type.sourceId = sourceId;
|
||||||
type.exportedTypes.push_back(Storage::ExportedType{Utils::SmallString{component.typeName}});
|
type.exportedTypes.push_back(Storage::ExportedType{Utils::SmallString{component.typeName}});
|
||||||
|
@@ -85,22 +85,22 @@ private:
|
|||||||
|
|
||||||
void parseTypeInfos(const QStringList &typeInfos,
|
void parseTypeInfos(const QStringList &typeInfos,
|
||||||
SourceContextId directoryId,
|
SourceContextId directoryId,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds);
|
SourceIds &sourceIds);
|
||||||
void parseTypeInfos(const SourceIds &qmltypesSourceIds,
|
void parseTypeInfos(const SourceIds &qmltypesSourceIds,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds);
|
SourceIds &sourceIds);
|
||||||
void parseTypeInfo(SourceId sourceId,
|
void parseTypeInfo(SourceId sourceId,
|
||||||
const QString &qmltypesPath,
|
const QString &qmltypesPath,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds);
|
SourceIds &sourceIds);
|
||||||
void parseQmlComponents(ComponentReferences components,
|
void parseQmlComponents(ComponentReferences components,
|
||||||
SourceContextId directoryId,
|
SourceContextId directoryId,
|
||||||
Utils::SmallStringView moduleName,
|
Utils::SmallStringView moduleName,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds);
|
SourceIds &sourceIds);
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ class QmlTypesParserInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void parse(const QString &sourceContent,
|
virtual void parse(const QString &sourceContent,
|
||||||
Storage::ImportDependencies &importDependencies,
|
Storage::ModuleDependencies &moduleDependencies,
|
||||||
Storage::Types &types,
|
Storage::Types &types,
|
||||||
SourceIds &sourceIds)
|
SourceIds &sourceIds)
|
||||||
= 0;
|
= 0;
|
||||||
|
@@ -1068,7 +1068,7 @@ std::ostream &operator<<(std::ostream &out, const ExportedType &exportedType)
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const ExplicitExportedType &exportedType)
|
std::ostream &operator<<(std::ostream &out, const ExplicitExportedType &exportedType)
|
||||||
{
|
{
|
||||||
return out << "(\"" << exportedType.name << "\", " << exportedType.import << ")";
|
return out << "(\"" << exportedType.name << "\", " << exportedType.module << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const NativeType &nativeType)
|
std::ostream &operator<<(std::ostream &out, const NativeType &nativeType)
|
||||||
@@ -1079,7 +1079,7 @@ std::ostream &operator<<(std::ostream &out, const NativeType &nativeType)
|
|||||||
std::ostream &operator<<(std::ostream &out, const Type &type)
|
std::ostream &operator<<(std::ostream &out, const Type &type)
|
||||||
{
|
{
|
||||||
using Utils::operator<<;
|
using Utils::operator<<;
|
||||||
return out << "(import: " << type.import << ", typename: \"" << type.typeName
|
return out << "(module: " << type.module << ", typename: \"" << type.typeName
|
||||||
<< "\", prototype: " << type.prototype << ", " << type.accessSemantics
|
<< "\", prototype: " << type.prototype << ", " << type.accessSemantics
|
||||||
<< ", source: " << type.sourceId << ", exports: " << type.exportedTypes
|
<< ", source: " << type.sourceId << ", exports: " << type.exportedTypes
|
||||||
<< ", properties: " << type.propertyDeclarations
|
<< ", properties: " << type.propertyDeclarations
|
||||||
@@ -1149,15 +1149,15 @@ std::ostream &operator<<(std::ostream &out, const EnumerationDeclaration &enumer
|
|||||||
<< enumerationDeclaration.enumeratorDeclarations << ")";
|
<< enumerationDeclaration.enumeratorDeclarations << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const Import &import)
|
std::ostream &operator<<(std::ostream &out, const Module &module)
|
||||||
{
|
{
|
||||||
return out << "(" << import.name << ", " << import.version << ")";
|
return out << "(" << module.name << ", " << module.version << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const ImportDependency &import)
|
std::ostream &operator<<(std::ostream &out, const ModuleDependency &module)
|
||||||
{
|
{
|
||||||
return out << "(" << import.name << ", " << import.version << ", " << import.sourceId << ", "
|
return out << "(" << module.name << ", " << module.version << ", " << module.sourceId << ", "
|
||||||
<< import.dependencies << ")";
|
<< module.dependencies << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
@@ -259,8 +259,8 @@ class ParameterDeclaration;
|
|||||||
class SignalDeclaration;
|
class SignalDeclaration;
|
||||||
class EnumerationDeclaration;
|
class EnumerationDeclaration;
|
||||||
class EnumeratorDeclaration;
|
class EnumeratorDeclaration;
|
||||||
class Import;
|
class Module;
|
||||||
class ImportDependency;
|
class ModuleDependency;
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, TypeAccessSemantics accessSemantics);
|
std::ostream &operator<<(std::ostream &out, TypeAccessSemantics accessSemantics);
|
||||||
std::ostream &operator<<(std::ostream &out, VersionNumber versionNumber);
|
std::ostream &operator<<(std::ostream &out, VersionNumber versionNumber);
|
||||||
@@ -276,8 +276,8 @@ std::ostream &operator<<(std::ostream &out, const ParameterDeclaration ¶mete
|
|||||||
std::ostream &operator<<(std::ostream &out, const SignalDeclaration &signalDeclaration);
|
std::ostream &operator<<(std::ostream &out, const SignalDeclaration &signalDeclaration);
|
||||||
std::ostream &operator<<(std::ostream &out, const EnumerationDeclaration &enumerationDeclaration);
|
std::ostream &operator<<(std::ostream &out, const EnumerationDeclaration &enumerationDeclaration);
|
||||||
std::ostream &operator<<(std::ostream &out, const EnumeratorDeclaration &enumeratorDeclaration);
|
std::ostream &operator<<(std::ostream &out, const EnumeratorDeclaration &enumeratorDeclaration);
|
||||||
std::ostream &operator<<(std::ostream &out, const Import &import);
|
std::ostream &operator<<(std::ostream &out, const Module &module);
|
||||||
std::ostream &operator<<(std::ostream &out, const ImportDependency &import);
|
std::ostream &operator<<(std::ostream &out, const ModuleDependency &module);
|
||||||
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ class ProjectStorageMock : public QmlDesigner::ProjectStorageInterface
|
|||||||
public:
|
public:
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
synchronize,
|
synchronize,
|
||||||
(QmlDesigner::Storage::ImportDependencies importDependencies,
|
(QmlDesigner::Storage::ModuleDependencies moduleDependencies,
|
||||||
QmlDesigner::Storage::Documents documents,
|
QmlDesigner::Storage::Documents documents,
|
||||||
QmlDesigner::Storage::Types types,
|
QmlDesigner::Storage::Types types,
|
||||||
QmlDesigner::SourceIds sourceIds,
|
QmlDesigner::SourceIds sourceIds,
|
||||||
|
@@ -44,19 +44,20 @@ namespace Storage = QmlDesigner::Storage;
|
|||||||
using QmlDesigner::FileStatus;
|
using QmlDesigner::FileStatus;
|
||||||
using QmlDesigner::SourceId;
|
using QmlDesigner::SourceId;
|
||||||
using QmlDesigner::Storage::TypeAccessSemantics;
|
using QmlDesigner::Storage::TypeAccessSemantics;
|
||||||
|
namespace Storage = QmlDesigner::Storage;
|
||||||
|
|
||||||
MATCHER_P5(IsStorageType,
|
MATCHER_P5(IsStorageType,
|
||||||
import,
|
module,
|
||||||
typeName,
|
typeName,
|
||||||
prototype,
|
prototype,
|
||||||
accessSemantics,
|
accessSemantics,
|
||||||
sourceId,
|
sourceId,
|
||||||
std::string(negation ? "isn't " : "is ")
|
std::string(negation ? "isn't " : "is ")
|
||||||
+ PrintToString(Storage::Type{import, typeName, prototype, accessSemantics, sourceId}))
|
+ PrintToString(Storage::Type{module, typeName, prototype, accessSemantics, sourceId}))
|
||||||
{
|
{
|
||||||
const Storage::Type &type = arg;
|
const Storage::Type &type = arg;
|
||||||
|
|
||||||
return type.import == import && type.typeName == typeName
|
return type.module == module && type.typeName == typeName
|
||||||
&& type.accessSemantics == accessSemantics && type.sourceId == sourceId
|
&& type.accessSemantics == accessSemantics && type.sourceId == sourceId
|
||||||
&& Storage::TypeName{prototype} == type.prototype;
|
&& Storage::TypeName{prototype} == type.prototype;
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ protected:
|
|||||||
qmlDocumentParserMock,
|
qmlDocumentParserMock,
|
||||||
qmlTypesParserMock};
|
qmlTypesParserMock};
|
||||||
SourceId objectTypeSourceId{sourcePathCache.sourceId("/path/Object")};
|
SourceId objectTypeSourceId{sourcePathCache.sourceId("/path/Object")};
|
||||||
Storage::Type objectType{Storage::Import{"Qml", 2},
|
Storage::Type objectType{Storage::Module{"Qml", 2},
|
||||||
"QObject",
|
"QObject",
|
||||||
Storage::NativeType{},
|
Storage::NativeType{},
|
||||||
Storage::TypeAccessSemantics::Reference,
|
Storage::TypeAccessSemantics::Reference,
|
||||||
@@ -246,7 +247,7 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes)
|
|||||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))))
|
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))))
|
||||||
.WillByDefault(Return(qmltypes));
|
.WillByDefault(Return(qmltypes));
|
||||||
ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _))
|
ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _))
|
||||||
.WillByDefault([&](auto, auto &importDependencies, auto &types, auto &sourceIds) {
|
.WillByDefault([&](auto, auto &moduleDependencies, auto &types, auto &sourceIds) {
|
||||||
types.push_back(objectType);
|
types.push_back(objectType);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -266,7 +267,7 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlTypesAreEmptyIfFileDoesNotChanged)
|
|||||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))))
|
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))))
|
||||||
.WillByDefault(Return(qmltypes));
|
.WillByDefault(Return(qmltypes));
|
||||||
ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _))
|
ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _))
|
||||||
.WillByDefault([&](auto, auto &importDependencies, auto &types, auto &sourceIds) {
|
.WillByDefault([&](auto, auto &moduleDependencies, auto &types, auto &sourceIds) {
|
||||||
types.push_back(objectType);
|
types.push_back(objectType);
|
||||||
});
|
});
|
||||||
ON_CALL(fileSystemMock, fileStatus(Eq(qmltypesPathSourceId)))
|
ON_CALL(fileSystemMock, fileStatus(Eq(qmltypesPathSourceId)))
|
||||||
@@ -349,7 +350,7 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
|||||||
EXPECT_CALL(projectStorageMock,
|
EXPECT_CALL(projectStorageMock,
|
||||||
synchronize(_,
|
synchronize(_,
|
||||||
_,
|
_,
|
||||||
Contains(AllOf(IsStorageType(Storage::Import{"Example", 1},
|
Contains(AllOf(IsStorageType(Storage::Module{"Example", 1},
|
||||||
"First.qml",
|
"First.qml",
|
||||||
Storage::ExportedType{"Object"},
|
Storage::ExportedType{"Object"},
|
||||||
TypeAccessSemantics::Reference,
|
TypeAccessSemantics::Reference,
|
||||||
|
@@ -35,7 +35,7 @@ public:
|
|||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
parse,
|
parse,
|
||||||
(const QString &sourceContent,
|
(const QString &sourceContent,
|
||||||
QmlDesigner::Storage::ImportDependencies &importDependencies,
|
QmlDesigner::Storage::ModuleDependencies &moduleDependencies,
|
||||||
QmlDesigner::Storage::Types &types,
|
QmlDesigner::Storage::Types &types,
|
||||||
QmlDesigner::SourceIds &sourceIds),
|
QmlDesigner::SourceIds &sourceIds),
|
||||||
(override));
|
(override));
|
||||||
|
Reference in New Issue
Block a user