forked from qt-creator/qt-creator
QmlDesigner: Change import export architecture
The new architecture should be a better abstractions for qml. ImportedTypeNames are introduced. ModuleDependencies are now taken over by document imports. Modules lost their version and ExportedTypeNames gained it. Task-number: QDS-4938 Task-number: QDS-4933 Task-number: QDS-5009 Task-number: QDS-5032 Change-Id: Ia86921c5be9107fe7d5bfd28f12bf8453769dc10 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -77,15 +77,16 @@ enum class BasicIdType {
|
||||
Type,
|
||||
PropertyType,
|
||||
PropertyDeclaration,
|
||||
SourceId,
|
||||
SourceContextId,
|
||||
Source,
|
||||
SourceContext,
|
||||
StorageCacheIndex,
|
||||
FunctionDeclaration,
|
||||
SignalDeclaration,
|
||||
EnumerationDeclaration,
|
||||
Module,
|
||||
TypeName,
|
||||
ProjectPartId
|
||||
ProjectPartId,
|
||||
Import,
|
||||
ImportedTypeName
|
||||
};
|
||||
|
||||
using TypeId = BasicId<BasicIdType::Type>;
|
||||
@@ -103,19 +104,22 @@ using SignalDeclarationIds = std::vector<SignalDeclarationId>;
|
||||
using EnumerationDeclarationId = BasicId<BasicIdType::EnumerationDeclaration>;
|
||||
using EnumerationDeclarationIds = std::vector<EnumerationDeclarationId>;
|
||||
|
||||
using SourceContextId = BasicId<BasicIdType::SourceContextId, int>;
|
||||
using SourceContextId = BasicId<BasicIdType::SourceContext, int>;
|
||||
using SourceContextIds = std::vector<SourceContextId>;
|
||||
|
||||
using SourceId = BasicId<BasicIdType::SourceId, int>;
|
||||
using SourceId = BasicId<BasicIdType::Source, int>;
|
||||
using SourceIds = std::vector<SourceId>;
|
||||
|
||||
using ModuleId = BasicId<BasicIdType::Module>;
|
||||
using ModuleId = BasicId<BasicIdType::Module, int>;
|
||||
using ModuleIds = std::vector<ModuleId>;
|
||||
|
||||
using TypeNameId = BasicId<BasicIdType::TypeName>;
|
||||
using TypeNameIds = std::vector<TypeNameId>;
|
||||
|
||||
using ProjectPartId = BasicId<BasicIdType::ProjectPartId>;
|
||||
using ProjectPartIds = std::vector<ProjectPartId>;
|
||||
|
||||
using ImportId = BasicId<BasicIdType::Import>;
|
||||
using ImportIds = std::vector<ImportId>;
|
||||
|
||||
using ImportedTypeNameId = BasicId<BasicIdType::ImportedTypeName>;
|
||||
using ImportedTypeNameIds = std::vector<ImportedTypeNameId>;
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -33,8 +33,8 @@ namespace QmlDesigner {
|
||||
class ProjectStorageInterface
|
||||
{
|
||||
public:
|
||||
virtual void synchronize(Storage::ModuleDependencies moduleDependencies,
|
||||
Storage::Documents documents,
|
||||
virtual void synchronize(Storage::Modules modules,
|
||||
Storage::Imports imports,
|
||||
Storage::Types types,
|
||||
SourceIds sourceIds,
|
||||
FileStatuses fileStatuses)
|
||||
|
@@ -43,7 +43,7 @@ enum class PropertyDeclarationTraits : unsigned int {
|
||||
IsList = 1 << 2
|
||||
};
|
||||
|
||||
enum class TypeNameKind { Native = 0, Exported = 1 };
|
||||
enum class TypeNameKind { Native = 0, Exported = 1, QualifiedExported = 2 };
|
||||
|
||||
constexpr PropertyDeclarationTraits operator|(PropertyDeclarationTraits first,
|
||||
PropertyDeclarationTraits second)
|
||||
@@ -60,15 +60,15 @@ class VersionNumber
|
||||
{
|
||||
public:
|
||||
explicit VersionNumber() = default;
|
||||
explicit VersionNumber(int version)
|
||||
: version{version}
|
||||
explicit VersionNumber(int value)
|
||||
: value{value}
|
||||
{}
|
||||
|
||||
explicit operator bool() const { return version >= 0; }
|
||||
explicit operator bool() const { return value >= 0; }
|
||||
|
||||
friend bool operator==(VersionNumber first, VersionNumber second) noexcept
|
||||
{
|
||||
return first.version == second.version;
|
||||
return first.value == second.value;
|
||||
}
|
||||
|
||||
friend bool operator!=(VersionNumber first, VersionNumber second) noexcept
|
||||
@@ -76,8 +76,13 @@ public:
|
||||
return !(first == second);
|
||||
}
|
||||
|
||||
friend bool operator<(VersionNumber first, VersionNumber second) noexcept
|
||||
{
|
||||
return first.value < second.value;
|
||||
}
|
||||
|
||||
public:
|
||||
int version = -1;
|
||||
int value = -1;
|
||||
};
|
||||
|
||||
class Version
|
||||
@@ -103,7 +108,12 @@ public:
|
||||
return first.major == second.major && first.minor == second.minor;
|
||||
}
|
||||
|
||||
explicit operator bool() { return major && minor; }
|
||||
friend bool operator<(Version first, Version second) noexcept
|
||||
{
|
||||
return std::tie(first.major, first.minor) < std::tie(second.major, second.minor);
|
||||
}
|
||||
|
||||
explicit operator bool() const { return major && minor; }
|
||||
|
||||
public:
|
||||
VersionNumber major;
|
||||
@@ -115,34 +125,147 @@ class Module
|
||||
public:
|
||||
explicit Module() = default;
|
||||
|
||||
explicit Module(Utils::SmallStringView name, VersionNumber version = VersionNumber{})
|
||||
explicit Module(Utils::SmallStringView name, SourceId sourceId = SourceId{})
|
||||
: name{name}
|
||||
, version{version}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
explicit Module(Utils::SmallStringView name, int version)
|
||||
explicit Module(Utils::SmallStringView name, int sourceId)
|
||||
: name{name}
|
||||
, version{version}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
friend bool operator==(const Module &first, const Module &second)
|
||||
{
|
||||
return first.name == second.name && first.version == second.version;
|
||||
return first.name == second.name;
|
||||
}
|
||||
|
||||
public:
|
||||
Utils::PathString name;
|
||||
VersionNumber version;
|
||||
SourceId sourceId;
|
||||
};
|
||||
|
||||
using Modules = std::vector<Module>;
|
||||
|
||||
enum class IsQualified : int { No, Yes };
|
||||
|
||||
inline int operator-(IsQualified first, IsQualified second)
|
||||
{
|
||||
return static_cast<int>(first) - static_cast<int>(second);
|
||||
}
|
||||
|
||||
inline int operator<(IsQualified first, IsQualified second)
|
||||
{
|
||||
return static_cast<int>(first) < static_cast<int>(second);
|
||||
}
|
||||
|
||||
class Import
|
||||
{
|
||||
public:
|
||||
explicit Import() = default;
|
||||
|
||||
explicit Import(Utils::SmallStringView name, Version version, SourceId sourceId)
|
||||
: name{name}
|
||||
, version{version}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
explicit Import(Utils::SmallStringView name, int majorVersion, int minorVersion, int sourceId)
|
||||
: name{name}
|
||||
, version{majorVersion, minorVersion}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
friend bool operator==(const Import &first, const Import &second)
|
||||
{
|
||||
return first.name == second.name && first.version == second.version
|
||||
&& first.sourceId == second.sourceId;
|
||||
}
|
||||
|
||||
public:
|
||||
Utils::PathString name;
|
||||
Version version;
|
||||
ModuleId moduleId;
|
||||
SourceId sourceId;
|
||||
};
|
||||
|
||||
using Imports = std::vector<Import>;
|
||||
|
||||
class ImportView
|
||||
{
|
||||
public:
|
||||
explicit ImportView() = default;
|
||||
|
||||
explicit ImportView(long long importId, int sourceId, int moduleId, int majorVersion, int minorVersion)
|
||||
: importId{importId}
|
||||
, sourceId{sourceId}
|
||||
, moduleId{moduleId}
|
||||
, version{majorVersion, minorVersion}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ImportView &first, const ImportView &second)
|
||||
{
|
||||
return first.sourceId == second.sourceId && first.moduleId == second.moduleId
|
||||
&& first.version == second.version;
|
||||
}
|
||||
|
||||
public:
|
||||
ImportId importId;
|
||||
SourceId sourceId;
|
||||
ModuleId moduleId;
|
||||
Version version;
|
||||
};
|
||||
|
||||
class ImportedType
|
||||
{
|
||||
public:
|
||||
explicit ImportedType() = default;
|
||||
explicit ImportedType(Utils::SmallStringView name)
|
||||
: name{name}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ImportedType &first, const ImportedType &second)
|
||||
{
|
||||
return first.name == second.name;
|
||||
}
|
||||
|
||||
public:
|
||||
Utils::SmallString name;
|
||||
};
|
||||
|
||||
class QualifiedImportedType
|
||||
{
|
||||
public:
|
||||
explicit QualifiedImportedType() = default;
|
||||
explicit QualifiedImportedType(Utils::SmallStringView name, Import import)
|
||||
: name{name}
|
||||
, import{std::move(import)}
|
||||
{}
|
||||
|
||||
friend bool operator==(const QualifiedImportedType &first, const QualifiedImportedType &second)
|
||||
{
|
||||
return first.name == second.name && first.import == second.import;
|
||||
}
|
||||
|
||||
public:
|
||||
Utils::SmallString name;
|
||||
Import import;
|
||||
};
|
||||
|
||||
using ImportedTypes = std::vector<ImportedType>;
|
||||
|
||||
class ExportedType
|
||||
{
|
||||
public:
|
||||
explicit ExportedType() = default;
|
||||
explicit ExportedType(Utils::SmallStringView name)
|
||||
explicit ExportedType(Utils::SmallStringView name, Version version = Version{})
|
||||
: name{name}
|
||||
, version{version}
|
||||
{}
|
||||
|
||||
explicit ExportedType(Utils::SmallStringView name, int majorVersion, int minorVersion)
|
||||
: name{name}
|
||||
, version{majorVersion, minorVersion}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ExportedType &first, const ExportedType &second)
|
||||
@@ -152,25 +275,7 @@ public:
|
||||
|
||||
public:
|
||||
Utils::SmallString name;
|
||||
};
|
||||
|
||||
class ExplicitExportedType
|
||||
{
|
||||
public:
|
||||
explicit ExplicitExportedType() = default;
|
||||
explicit ExplicitExportedType(Utils::SmallStringView name, Module module)
|
||||
: name{name}
|
||||
, module{std::move(module)}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ExplicitExportedType &first, const ExplicitExportedType &second)
|
||||
{
|
||||
return first.name == second.name && first.module == second.module;
|
||||
}
|
||||
|
||||
public:
|
||||
Utils::SmallString name;
|
||||
Module module;
|
||||
Storage::Version version;
|
||||
};
|
||||
|
||||
using ExportedTypes = std::vector<ExportedType>;
|
||||
@@ -192,7 +297,7 @@ public:
|
||||
Utils::SmallString name;
|
||||
};
|
||||
|
||||
using TypeName = Utils::variant<NativeType, ExportedType, ExplicitExportedType>;
|
||||
using ImportedTypeName = Utils::variant<NativeType, ImportedType, QualifiedImportedType>;
|
||||
|
||||
class EnumeratorDeclaration
|
||||
{
|
||||
@@ -398,7 +503,7 @@ class PropertyDeclaration
|
||||
public:
|
||||
explicit PropertyDeclaration() = default;
|
||||
explicit PropertyDeclaration(Utils::SmallStringView name,
|
||||
TypeName typeName,
|
||||
ImportedTypeName typeName,
|
||||
PropertyDeclarationTraits traits)
|
||||
: name{name}
|
||||
, typeName{std::move(typeName)}
|
||||
@@ -407,7 +512,7 @@ public:
|
||||
{}
|
||||
|
||||
explicit PropertyDeclaration(Utils::SmallStringView name,
|
||||
TypeName typeName,
|
||||
ImportedTypeName typeName,
|
||||
PropertyDeclarationTraits traits,
|
||||
Utils::SmallStringView aliasPropertyName)
|
||||
: name{name}
|
||||
@@ -429,7 +534,7 @@ public:
|
||||
{}
|
||||
|
||||
explicit PropertyDeclaration(Utils::SmallStringView name,
|
||||
TypeName aliasTypeName,
|
||||
ImportedTypeName aliasTypeName,
|
||||
Utils::SmallStringView aliasPropertyName)
|
||||
: name{name}
|
||||
, typeName{std::move(aliasTypeName)}
|
||||
@@ -446,7 +551,7 @@ public:
|
||||
|
||||
public:
|
||||
Utils::SmallString name;
|
||||
TypeName typeName;
|
||||
ImportedTypeName typeName;
|
||||
Utils::SmallString aliasPropertyName;
|
||||
PropertyDeclarationTraits traits = {};
|
||||
TypeId typeId;
|
||||
@@ -476,7 +581,7 @@ public:
|
||||
Utils::SmallStringView name;
|
||||
PropertyDeclarationTraits traits = {};
|
||||
TypeId typeId;
|
||||
TypeNameId typeNameId;
|
||||
ImportedTypeNameId typeNameId;
|
||||
PropertyDeclarationId id;
|
||||
PropertyDeclarationId aliasId;
|
||||
};
|
||||
@@ -487,7 +592,7 @@ public:
|
||||
explicit Type() = default;
|
||||
explicit Type(Module module,
|
||||
Utils::SmallStringView typeName,
|
||||
TypeName prototype,
|
||||
ImportedTypeName prototype,
|
||||
TypeAccessSemantics accessSemantics,
|
||||
SourceId sourceId,
|
||||
ExportedTypes exportedTypes = {},
|
||||
@@ -510,21 +615,19 @@ public:
|
||||
{}
|
||||
|
||||
explicit Type(Utils::SmallStringView moduleName,
|
||||
int moduleVersion,
|
||||
Utils::SmallStringView typeName,
|
||||
Utils::SmallStringView prototype,
|
||||
int accessSemantics,
|
||||
int sourceId)
|
||||
: typeName{typeName}
|
||||
, prototype{NativeType{prototype}}
|
||||
, module{moduleName, moduleVersion}
|
||||
, module{moduleName}
|
||||
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
||||
, sourceId{sourceId}
|
||||
|
||||
{}
|
||||
|
||||
explicit Type(Utils::SmallStringView moduleName,
|
||||
int moduleVersion,
|
||||
Utils::SmallStringView typeName,
|
||||
long long typeId,
|
||||
Utils::SmallStringView prototype,
|
||||
@@ -532,7 +635,22 @@ public:
|
||||
int sourceId)
|
||||
: typeName{typeName}
|
||||
, prototype{NativeType{prototype}}
|
||||
, module{moduleName, moduleVersion}
|
||||
, module{moduleName}
|
||||
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
||||
, sourceId{sourceId}
|
||||
, typeId{typeId}
|
||||
{}
|
||||
|
||||
explicit Type(Utils::SmallStringView moduleName,
|
||||
int moduleId,
|
||||
Utils::SmallStringView typeName,
|
||||
long long typeId,
|
||||
Utils::SmallStringView prototype,
|
||||
int accessSemantics,
|
||||
int sourceId)
|
||||
: typeName{typeName}
|
||||
, prototype{NativeType{prototype}}
|
||||
, module{moduleName, moduleId}
|
||||
, accessSemantics{static_cast<TypeAccessSemantics>(accessSemantics)}
|
||||
, sourceId{sourceId}
|
||||
, typeId{typeId}
|
||||
@@ -551,7 +669,7 @@ public:
|
||||
|
||||
public:
|
||||
Utils::SmallString typeName;
|
||||
TypeName prototype;
|
||||
ImportedTypeName prototype;
|
||||
ExportedTypes exportedTypes;
|
||||
PropertyDeclarations propertyDeclarations;
|
||||
FunctionDeclarations functionDeclarations;
|
||||
@@ -565,70 +683,21 @@ public:
|
||||
|
||||
using Types = std::vector<Type>;
|
||||
|
||||
class Document
|
||||
{
|
||||
public:
|
||||
explicit Document() = default;
|
||||
explicit Document(SourceId sourceId, Modules modules)
|
||||
: modules{std::move(modules)}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
public:
|
||||
Modules modules;
|
||||
SourceId sourceId;
|
||||
};
|
||||
|
||||
using Documents = std::vector<Document>;
|
||||
|
||||
class ModuleDependency : public Module
|
||||
{
|
||||
public:
|
||||
explicit ModuleDependency(Utils::SmallStringView name,
|
||||
VersionNumber version,
|
||||
SourceId sourceId,
|
||||
Modules moduleDependencies = {})
|
||||
: Module(name, version)
|
||||
, dependencies{std::move(moduleDependencies)}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
explicit ModuleDependency(Utils::SmallStringView name, int version, int sourceId)
|
||||
: Module(name, version)
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ModuleDependency &first, const ModuleDependency &second)
|
||||
{
|
||||
return static_cast<const Module &>(first) == static_cast<const Module &>(second)
|
||||
&& first.sourceId == second.sourceId && first.dependencies == second.dependencies;
|
||||
}
|
||||
|
||||
public:
|
||||
Modules dependencies;
|
||||
SourceId sourceId;
|
||||
};
|
||||
|
||||
using ModuleDependencies = std::vector<ModuleDependency>;
|
||||
|
||||
class ModuleView
|
||||
{
|
||||
public:
|
||||
explicit ModuleView(Utils::SmallStringView name, int version, int sourceId)
|
||||
explicit ModuleView(Utils::SmallStringView name, int sourceId)
|
||||
: name{name}
|
||||
, version{version}
|
||||
, sourceId{sourceId}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ModuleView &first, const ModuleView &second)
|
||||
{
|
||||
return first.name == second.name && first.version == second.version
|
||||
&& first.sourceId == second.sourceId;
|
||||
return first.name == second.name && first.sourceId == second.sourceId;
|
||||
}
|
||||
|
||||
public:
|
||||
Utils::SmallStringView name;
|
||||
VersionNumber version;
|
||||
SourceId sourceId;
|
||||
};
|
||||
|
||||
|
@@ -52,8 +52,8 @@ ComponentReferences createComponentReferences(const QMultiHash<QString, QmlDirPa
|
||||
|
||||
void ProjectUpdater::update()
|
||||
{
|
||||
Storage::ModuleDependencies moduleDependencies;
|
||||
Storage::Documents documents;
|
||||
Storage::Modules modules;
|
||||
Storage::Imports imports;
|
||||
Storage::Types types;
|
||||
SourceIds sourceIds;
|
||||
FileStatuses fileStatuses;
|
||||
@@ -72,18 +72,18 @@ void ProjectUpdater::update()
|
||||
Utils::SmallString moduleName{parser.typeNamespace()};
|
||||
SourceContextId directoryId = m_pathCache.sourceContextId(qmlDirSourceId);
|
||||
|
||||
parseTypeInfos(parser.typeInfos(), directoryId, moduleDependencies, types, sourceIds);
|
||||
parseTypeInfos(parser.typeInfos(), directoryId, modules, types, sourceIds);
|
||||
parseQmlComponents(createComponentReferences(parser.components()),
|
||||
directoryId,
|
||||
moduleName,
|
||||
moduleDependencies,
|
||||
modules,
|
||||
types,
|
||||
sourceIds);
|
||||
break;
|
||||
}
|
||||
case FileState::NotChanged: {
|
||||
SourceIds qmltypesSourceIds = m_projectStorage.fetchSourceDependencieIds(qmlDirSourceId);
|
||||
parseTypeInfos(qmltypesSourceIds, moduleDependencies, types, sourceIds);
|
||||
parseTypeInfos(qmltypesSourceIds, modules, types, sourceIds);
|
||||
break;
|
||||
}
|
||||
case FileState::NotExists: {
|
||||
@@ -93,8 +93,8 @@ void ProjectUpdater::update()
|
||||
}
|
||||
}
|
||||
|
||||
m_projectStorage.synchronize(std::move(moduleDependencies),
|
||||
std::move(documents),
|
||||
m_projectStorage.synchronize(std::move(modules),
|
||||
std::move(imports),
|
||||
std::move(types),
|
||||
std::move(sourceIds),
|
||||
std::move(fileStatuses));
|
||||
@@ -102,7 +102,7 @@ void ProjectUpdater::update()
|
||||
|
||||
void ProjectUpdater::parseTypeInfos(const QStringList &typeInfos,
|
||||
SourceContextId directoryId,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds)
|
||||
{
|
||||
@@ -112,39 +112,39 @@ void ProjectUpdater::parseTypeInfos(const QStringList &typeInfos,
|
||||
SourceId sourceId = m_pathCache.sourceId(directoryId, Utils::SmallString{typeInfo});
|
||||
QString qmltypesPath = directory + "/" + typeInfo;
|
||||
|
||||
parseTypeInfo(sourceId, qmltypesPath, moduleDependencies, types, sourceIds);
|
||||
parseTypeInfo(sourceId, qmltypesPath, modules, types, sourceIds);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectUpdater::parseTypeInfos(const SourceIds &qmltypesSourceIds,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds)
|
||||
{
|
||||
for (SourceId sourceId : qmltypesSourceIds) {
|
||||
QString qmltypesPath = m_pathCache.sourcePath(sourceId).toQString();
|
||||
|
||||
parseTypeInfo(sourceId, qmltypesPath, moduleDependencies, types, sourceIds);
|
||||
parseTypeInfo(sourceId, qmltypesPath, modules, types, sourceIds);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectUpdater::parseTypeInfo(SourceId sourceId,
|
||||
const QString &qmltypesPath,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds)
|
||||
{
|
||||
if (fileState(sourceId) == FileState::Changed) {
|
||||
sourceIds.push_back(sourceId);
|
||||
const auto content = m_fileSystem.contentAsQString(qmltypesPath);
|
||||
m_qmlTypesParser.parse(content, moduleDependencies, types, sourceIds);
|
||||
m_qmlTypesParser.parse(content, modules, types, sourceIds);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectUpdater::parseQmlComponents(ComponentReferences components,
|
||||
SourceContextId directoryId,
|
||||
Utils::SmallStringView moduleName,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds)
|
||||
{
|
||||
@@ -173,7 +173,6 @@ void ProjectUpdater::parseQmlComponents(ComponentReferences components,
|
||||
|
||||
type.typeName = fileName;
|
||||
type.module.name = moduleName;
|
||||
type.module.version.version = component.majorVersion;
|
||||
type.accessSemantics = Storage::TypeAccessSemantics::Reference;
|
||||
type.sourceId = sourceId;
|
||||
type.exportedTypes.push_back(Storage::ExportedType{Utils::SmallString{component.typeName}});
|
||||
|
@@ -85,22 +85,22 @@ private:
|
||||
|
||||
void parseTypeInfos(const QStringList &typeInfos,
|
||||
SourceContextId directoryId,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds);
|
||||
void parseTypeInfos(const SourceIds &qmltypesSourceIds,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds);
|
||||
void parseTypeInfo(SourceId sourceId,
|
||||
const QString &qmltypesPath,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds);
|
||||
void parseQmlComponents(ComponentReferences components,
|
||||
SourceContextId directoryId,
|
||||
Utils::SmallStringView moduleName,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds);
|
||||
|
||||
|
@@ -35,7 +35,7 @@ class QmlTypesParserInterface
|
||||
{
|
||||
public:
|
||||
virtual void parse(const QString &sourceContent,
|
||||
Storage::ModuleDependencies &moduleDependencies,
|
||||
Storage::Modules &modules,
|
||||
Storage::Types &types,
|
||||
SourceIds &sourceIds)
|
||||
= 0;
|
||||
|
@@ -1035,9 +1035,7 @@ bool operator&(TypeAccessSemantics first, TypeAccessSemantics second)
|
||||
return static_cast<int>(first) & static_cast<int>(second);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
static const char *typeAccessSemanticsFlagsToString(TypeAccessSemantics accessSemantics)
|
||||
const char *typeAccessSemanticsFlagsToString(TypeAccessSemantics accessSemantics)
|
||||
{
|
||||
if (accessSemantics & TypeAccessSemantics::IsEnum)
|
||||
return "(IsEnum)";
|
||||
@@ -1045,15 +1043,34 @@ static const char *typeAccessSemanticsFlagsToString(TypeAccessSemantics accessSe
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *isQualifiedToString(IsQualified isQualified)
|
||||
{
|
||||
switch (isQualified) {
|
||||
case IsQualified::No:
|
||||
return "no";
|
||||
case IsQualified::Yes:
|
||||
return "yes";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, TypeAccessSemantics accessSemantics)
|
||||
{
|
||||
return out << typeAccessSemanticsToString(accessSemantics)
|
||||
<< typeAccessSemanticsFlagsToString(accessSemantics);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, IsQualified isQualified)
|
||||
{
|
||||
return out << isQualifiedToString(isQualified);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, VersionNumber versionNumber)
|
||||
{
|
||||
return out << versionNumber.version;
|
||||
return out << versionNumber.value;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, Version version)
|
||||
@@ -1066,16 +1083,20 @@ std::ostream &operator<<(std::ostream &out, const ExportedType &exportedType)
|
||||
return out << "(\"" << exportedType.name << "\")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ExplicitExportedType &exportedType)
|
||||
{
|
||||
return out << "(\"" << exportedType.name << "\", " << exportedType.module << ")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const NativeType &nativeType)
|
||||
{
|
||||
return out << "(\"" << nativeType.name << "\")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ImportedType &importedType)
|
||||
{
|
||||
return out << "(\"" << importedType.name << ")";
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &out, const QualifiedImportedType &importedType)
|
||||
{
|
||||
return out << "(\"" << importedType.name << "\", " << importedType.import << ")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Type &type)
|
||||
{
|
||||
using Utils::operator<<;
|
||||
@@ -1151,13 +1172,12 @@ std::ostream &operator<<(std::ostream &out, const EnumerationDeclaration &enumer
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Module &module)
|
||||
{
|
||||
return out << "(" << module.name << ", " << module.version << ")";
|
||||
return out << "(" << module.name << ", " << module.sourceId << ")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ModuleDependency &module)
|
||||
std::ostream &operator<<(std::ostream &out, const Import &import)
|
||||
{
|
||||
return out << "(" << module.name << ", " << module.version << ", " << module.sourceId << ", "
|
||||
<< module.dependencies << ")";
|
||||
return out << "(" << import.name << ", " << import.version << ", " << import.sourceId << ")";
|
||||
}
|
||||
|
||||
} // namespace Storage
|
||||
|
@@ -247,8 +247,9 @@ namespace Storage {
|
||||
class Type;
|
||||
class ExportedType;
|
||||
class NativeType;
|
||||
class ExplicitExportedType;
|
||||
using TypeName = Utils::variant<NativeType, ExportedType, ExplicitExportedType>;
|
||||
class ImportedType;
|
||||
class QualifiedImportedType;
|
||||
using TypeName = Utils::variant<NativeType, ExportedType>;
|
||||
class Version;
|
||||
class VersionNumber;
|
||||
enum class TypeAccessSemantics : int;
|
||||
@@ -261,6 +262,8 @@ class EnumerationDeclaration;
|
||||
class EnumeratorDeclaration;
|
||||
class Module;
|
||||
class ModuleDependency;
|
||||
class Import;
|
||||
enum class IsQualified : int;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, TypeAccessSemantics accessSemantics);
|
||||
std::ostream &operator<<(std::ostream &out, VersionNumber versionNumber);
|
||||
@@ -268,7 +271,8 @@ std::ostream &operator<<(std::ostream &out, Version version);
|
||||
std::ostream &operator<<(std::ostream &out, const Type &type);
|
||||
std::ostream &operator<<(std::ostream &out, const ExportedType &exportedType);
|
||||
std::ostream &operator<<(std::ostream &out, const NativeType &nativeType);
|
||||
std::ostream &operator<<(std::ostream &out, const ExplicitExportedType &exportedType);
|
||||
std::ostream &operator<<(std::ostream &out, const ImportedType &importedType);
|
||||
std::ostream &operator<<(std::ostream &out, const QualifiedImportedType &importedType);
|
||||
std::ostream &operator<<(std::ostream &out, const PropertyDeclaration &propertyDeclaration);
|
||||
std::ostream &operator<<(std::ostream &out, PropertyDeclarationTraits traits);
|
||||
std::ostream &operator<<(std::ostream &out, const FunctionDeclaration &functionDeclaration);
|
||||
@@ -278,6 +282,8 @@ std::ostream &operator<<(std::ostream &out, const EnumerationDeclaration &enumer
|
||||
std::ostream &operator<<(std::ostream &out, const EnumeratorDeclaration &enumeratorDeclaration);
|
||||
std::ostream &operator<<(std::ostream &out, const Module &module);
|
||||
std::ostream &operator<<(std::ostream &out, const ModuleDependency &module);
|
||||
std::ostream &operator<<(std::ostream &out, const Import &import);
|
||||
std::ostream &operator<<(std::ostream &out, IsQualified isQualified);
|
||||
|
||||
} // namespace Storage
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -38,8 +38,8 @@ class ProjectStorageMock : public QmlDesigner::ProjectStorageInterface
|
||||
public:
|
||||
MOCK_METHOD(void,
|
||||
synchronize,
|
||||
(QmlDesigner::Storage::ModuleDependencies moduleDependencies,
|
||||
QmlDesigner::Storage::Documents documents,
|
||||
(QmlDesigner::Storage::Modules modules,
|
||||
QmlDesigner::Storage::Imports imports,
|
||||
QmlDesigner::Storage::Types types,
|
||||
QmlDesigner::SourceIds sourceIds,
|
||||
QmlDesigner::FileStatuses fileStatuses),
|
||||
|
@@ -45,6 +45,7 @@ using QmlDesigner::FileStatus;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::Storage::TypeAccessSemantics;
|
||||
namespace Storage = QmlDesigner::Storage;
|
||||
using QmlDesigner::Storage::Version;
|
||||
|
||||
MATCHER_P5(IsStorageType,
|
||||
module,
|
||||
@@ -59,7 +60,7 @@ MATCHER_P5(IsStorageType,
|
||||
|
||||
return type.module == module && type.typeName == typeName
|
||||
&& type.accessSemantics == accessSemantics && type.sourceId == sourceId
|
||||
&& Storage::TypeName{prototype} == type.prototype;
|
||||
&& Storage::ImportedTypeName{prototype} == type.prototype;
|
||||
}
|
||||
|
||||
MATCHER_P3(IsPropertyDeclaration,
|
||||
@@ -72,7 +73,7 @@ MATCHER_P3(IsPropertyDeclaration,
|
||||
const Storage::PropertyDeclaration &propertyDeclaration = arg;
|
||||
|
||||
return propertyDeclaration.name == name
|
||||
&& Storage::TypeName{typeName} == propertyDeclaration.typeName
|
||||
&& Storage::ImportedTypeName{typeName} == propertyDeclaration.typeName
|
||||
&& propertyDeclaration.traits == traits;
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ protected:
|
||||
qmlDocumentParserMock,
|
||||
qmlTypesParserMock};
|
||||
SourceId objectTypeSourceId{sourcePathCache.sourceId("/path/Object")};
|
||||
Storage::Type objectType{Storage::Module{"Qml", 2},
|
||||
Storage::Type objectType{Storage::Module{"Qml"},
|
||||
"QObject",
|
||||
Storage::NativeType{},
|
||||
Storage::TypeAccessSemantics::Reference,
|
||||
@@ -330,11 +331,11 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
||||
auto qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First.2.qml");
|
||||
auto qmlDocumentSourceId3 = sourcePathCache.sourceId("/path/Second.qml");
|
||||
Storage::Type firstType;
|
||||
firstType.prototype = Storage::ExportedType{"Object"};
|
||||
firstType.prototype = Storage::ImportedType{"Object"};
|
||||
Storage::Type secondType;
|
||||
secondType.prototype = Storage::ExportedType{"Object2"};
|
||||
secondType.prototype = Storage::ImportedType{"Object2"};
|
||||
Storage::Type thirdType;
|
||||
thirdType.prototype = Storage::ExportedType{"Object3"};
|
||||
thirdType.prototype = Storage::ImportedType{"Object3"};
|
||||
auto firstQmlDocumentSourceId = sourcePathCache.sourceId("/path/First.qml");
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml"))))
|
||||
@@ -350,9 +351,9 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(_,
|
||||
_,
|
||||
Contains(AllOf(IsStorageType(Storage::Module{"Example", 1},
|
||||
Contains(AllOf(IsStorageType(Storage::Module{"Example"},
|
||||
"First.qml",
|
||||
Storage::ExportedType{"Object"},
|
||||
Storage::ImportedType{"Object"},
|
||||
TypeAccessSemantics::Reference,
|
||||
firstQmlDocumentSourceId),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
MOCK_METHOD(void,
|
||||
parse,
|
||||
(const QString &sourceContent,
|
||||
QmlDesigner::Storage::ModuleDependencies &moduleDependencies,
|
||||
QmlDesigner::Storage::Modules &modules,
|
||||
QmlDesigner::Storage::Types &types,
|
||||
QmlDesigner::SourceIds &sourceIds),
|
||||
(override));
|
||||
|
Reference in New Issue
Block a user