forked from qt-creator/qt-creator
QmlDesigner: Add kind to module id
In some cases we need to find out what kind a module is. Task-number: QTCREATORBUG-30735 Change-Id: Ibd5a70ee6fe0f619009fd645f444d3fbb2fd6e01 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -179,7 +179,7 @@ std::optional<PropertyComponentGenerator::Entry> createEntry(QmlJS::SimpleReader
|
||||
if (moduleName.isEmpty())
|
||||
return {};
|
||||
|
||||
auto module = model->module(moduleName);
|
||||
auto module = model->module(moduleName, Storage::ModuleKind::QmlLibrary);
|
||||
|
||||
auto typeName = getProperty<QByteArray>(node, "typeNames");
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ void Edit3DView::handleEntriesChanged()
|
||||
.generatedComponentUtils()
|
||||
.import3dTypePrefix();
|
||||
|
||||
auto assetsModule = model()->module(import3dTypePrefix);
|
||||
auto assetsModule = model()->module(import3dTypePrefix, Storage::ModuleKind::QmlLibrary);
|
||||
|
||||
for (const auto &metaInfo : model()->metaInfosForModule(assetsModule))
|
||||
append(metaInfo, EK_importedModels);
|
||||
|
||||
@@ -770,7 +770,8 @@ void Edit3DWidget::dropEvent(QDropEvent *dropEvent)
|
||||
->documentManager()
|
||||
.generatedComponentUtils()
|
||||
.import3dTypePrefix();
|
||||
auto metaInfo = model->metaInfo(model->module(import3dTypePrefix), fileName.toUtf8());
|
||||
auto moduleId = model->module(import3dTypePrefix, Storage::ModuleKind::QmlLibrary);
|
||||
auto metaInfo = model->metaInfo(moduleId, fileName.toUtf8());
|
||||
if (auto entries = metaInfo.itemLibrariesEntries(); entries.size()) {
|
||||
auto entry = ItemLibraryEntry{entries.front(), *model->projectStorage()};
|
||||
QmlVisualNode::createQml3DNode(view(), entry, m_canvas->activeScene(), {}, false);
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
void setMetaInfo(const MetaInfo &metaInfo);
|
||||
#endif
|
||||
|
||||
Module module(Utils::SmallStringView moduleName);
|
||||
Module module(Utils::SmallStringView moduleName, Storage::ModuleKind moduleKind);
|
||||
NodeMetaInfo metaInfo(const TypeName &typeName, int majorVersion = -1, int minorVersion = -1) const;
|
||||
NodeMetaInfo metaInfo(Module module,
|
||||
Utils::SmallStringView typeName,
|
||||
|
||||
@@ -1031,8 +1031,20 @@ TypeName createQualifiedTypeName(const ModelNode &node)
|
||||
auto exportedTypes = node.metaInfo().exportedTypeNamesForSourceId(model->fileUrlSourceId());
|
||||
if (exportedTypes.size()) {
|
||||
const auto &exportedType = exportedTypes.front();
|
||||
Utils::PathString typeName = model->projectStorage()->moduleName(exportedType.moduleId);
|
||||
typeName += '/';
|
||||
using Storage::ModuleKind;
|
||||
auto module = model->projectStorage()->module(exportedType.moduleId);
|
||||
Utils::PathString typeName;
|
||||
switch (module.kind) {
|
||||
case ModuleKind::QmlLibrary:
|
||||
typeName += module.name;
|
||||
typeName += '/';
|
||||
break;
|
||||
case ModuleKind::PathLibrary:
|
||||
break;
|
||||
case ModuleKind::CppLibrary:
|
||||
break;
|
||||
}
|
||||
|
||||
typeName += exportedType.name;
|
||||
|
||||
return typeName.toQByteArray();
|
||||
|
||||
@@ -53,6 +53,8 @@ NodeMetaInfo object will result in an InvalidMetaInfoException being thrown.
|
||||
|
||||
namespace {
|
||||
|
||||
using Storage::ModuleKind;
|
||||
|
||||
auto category = MetaInfoTracing::category;
|
||||
|
||||
struct TypeDescription
|
||||
@@ -2123,13 +2125,13 @@ NodeMetaInfos NodeMetaInfo::prototypes() const
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<const char *moduleName, const char *typeName>
|
||||
template<const char *moduleName, const char *typeName, ModuleKind moduleKind = ModuleKind::QmlLibrary>
|
||||
bool isBasedOnCommonType(NotNullPointer<const ProjectStorageType> projectStorage, TypeId typeId)
|
||||
{
|
||||
if (!typeId)
|
||||
return false;
|
||||
|
||||
auto base = projectStorage->commonTypeId<moduleName, typeName>();
|
||||
auto base = projectStorage->commonTypeId<moduleName, typeName, moduleKind>();
|
||||
|
||||
return projectStorage->isBasedOn(typeId, base);
|
||||
}
|
||||
@@ -3441,7 +3443,7 @@ bool NodeMetaInfo::isQtQuick3DParticlesAbstractShape() const
|
||||
keyValue("type id", m_typeId)};
|
||||
|
||||
using namespace Storage::Info;
|
||||
return isBasedOnCommonType<QtQuick3D_Particles3D_cppnative, QQuick3DParticleAbstractShape>(
|
||||
return isBasedOnCommonType<QtQuick3D_Particles3D, QQuick3DParticleAbstractShape, ModuleKind::CppLibrary>(
|
||||
m_projectStorage, m_typeId);
|
||||
} else {
|
||||
return isValid() && isSubclassOf("QQuick3DParticleAbstractShape");
|
||||
@@ -3578,8 +3580,8 @@ bool NodeMetaInfo::isQtQuickStateOperation() const
|
||||
keyValue("type id", m_typeId)};
|
||||
|
||||
using namespace Storage::Info;
|
||||
return isBasedOnCommonType<QtQuick_cppnative, QQuickStateOperation>(m_projectStorage,
|
||||
m_typeId);
|
||||
return isBasedOnCommonType<QtQuick, QQuickStateOperation, ModuleKind::CppLibrary>(m_projectStorage,
|
||||
m_typeId);
|
||||
} else {
|
||||
return isValid() && isSubclassOf("<cpp>.QQuickStateOperation");
|
||||
}
|
||||
@@ -4333,8 +4335,6 @@ PropertyName PropertyMetaInfo::name() const
|
||||
} else {
|
||||
return propertyName();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool PropertyMetaInfo::isWritable() const
|
||||
|
||||
@@ -170,10 +170,10 @@ Storage::Imports createStorageImports(const Imports &imports,
|
||||
SourceId fileId)
|
||||
{
|
||||
return Utils::transform<Storage::Imports>(imports, [&](const Import &import) {
|
||||
return Storage::Import{projectStorage.moduleId(Utils::SmallString{import.url()}),
|
||||
import.majorVersion(),
|
||||
import.minorVersion(),
|
||||
fileId};
|
||||
using Storage::ModuleKind;
|
||||
auto moduleKind = import.isLibraryImport() ? ModuleKind::QmlLibrary : ModuleKind::PathLibrary;
|
||||
auto moduleId = projectStorage.moduleId(Utils::SmallString{import.url()}, moduleKind);
|
||||
return Storage::Import{moduleId, import.majorVersion(), import.minorVersion(), fileId};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -390,7 +390,11 @@ ImportedTypeNameId ModelPrivate::importedTypeNameId(Utils::SmallStringView typeN
|
||||
return import.alias() == aliasName;
|
||||
});
|
||||
if (found != m_imports.end()) {
|
||||
ModuleId moduleId = projectStorage->moduleId(Utils::PathString{found->url()});
|
||||
using Storage::ModuleKind;
|
||||
auto moduleKind = found->isLibraryImport() ? ModuleKind::QmlLibrary
|
||||
: ModuleKind::PathLibrary;
|
||||
ModuleId moduleId = projectStorage->moduleId(Utils::PathString{found->url()},
|
||||
moduleKind);
|
||||
ImportId importId = projectStorage->importId(
|
||||
Storage::Import{moduleId, found->majorVersion(), found->minorVersion(), m_sourceId});
|
||||
return projectStorage->importedTypeNameId(importId, shortTypeName);
|
||||
@@ -2623,11 +2627,10 @@ MetaInfo Model::metaInfo()
|
||||
}
|
||||
#endif
|
||||
|
||||
Module Model::module(Utils::SmallStringView moduleName)
|
||||
Module Model::module(Utils::SmallStringView moduleName, Storage::ModuleKind moduleKind)
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
return Module(d->projectStorage->moduleId(moduleName), d->projectStorage);
|
||||
}
|
||||
if constexpr (useProjectStorage())
|
||||
return Module(d->projectStorage->moduleId(moduleName, moduleKind), d->projectStorage);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1027,9 +1027,25 @@ ModuleIds generateModuleIds(const ModelNodes &nodes)
|
||||
|
||||
QStringList generateImports(ModuleIds moduleIds, const ProjectStorageType &projectStorage)
|
||||
{
|
||||
return Utils::transform<QStringList>(moduleIds, [&](auto id) {
|
||||
return "import " + projectStorage.moduleName(id).toQString();
|
||||
});
|
||||
QStringList imports;
|
||||
imports.reserve(std::ssize(moduleIds));
|
||||
|
||||
for (auto moduleId : moduleIds) {
|
||||
using Storage::ModuleKind;
|
||||
auto module = projectStorage.module(moduleId);
|
||||
switch (module.kind) {
|
||||
case ModuleKind::QmlLibrary:
|
||||
imports.push_back("import " + module.name.toQString());
|
||||
break;
|
||||
case ModuleKind::PathLibrary:
|
||||
imports.push_back("import \"" + module.name.toQString() + "\"");
|
||||
break;
|
||||
case ModuleKind::CppLibrary:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return imports;
|
||||
}
|
||||
|
||||
QStringList generateImports(const ModelNodes &nodes)
|
||||
|
||||
@@ -84,7 +84,6 @@ inline constexpr char PrincipledMaterial[] = "PrincipledMaterial";
|
||||
inline constexpr char PropertyAnimation[] = "PropertyAnimation";
|
||||
inline constexpr char PropertyChanges[] = "PropertyChanges";
|
||||
inline constexpr char QML[] = "QML";
|
||||
inline constexpr char QML_cppnative[] = "QML-cppnative";
|
||||
inline constexpr char QQuick3DParticleAbstractShape[] = "QQuick3DParticleAbstractShape";
|
||||
inline constexpr char QQuickStateOperation[] = "QQuickStateOperation";
|
||||
inline constexpr char QtMultimedia[] = "QtMultimedia";
|
||||
@@ -94,7 +93,6 @@ inline constexpr char QtQml_Models[] = "QtQml.Models";
|
||||
inline constexpr char QtQml_XmlListModel[] = "QtQml.XmlListModel";
|
||||
inline constexpr char QtQuick3D[] = "QtQuick3D";
|
||||
inline constexpr char QtQuick3D_Particles3D[] = "QtQuick3D.Particles3D";
|
||||
inline constexpr char QtQuick3D_Particles3D_cppnative[] = "QtQuick3D.Particles3D-cppnative";
|
||||
inline constexpr char QtQuick[] = "QtQuick";
|
||||
inline constexpr char QtQuick_Controls[] = "QtQuick.Controls";
|
||||
inline constexpr char QtQuick_Dialogs[] = "QtQuick.Dialogs";
|
||||
@@ -104,7 +102,6 @@ inline constexpr char QtQuick_Studio_Components[] = "QtQuick.Studio.Components";
|
||||
inline constexpr char QtQuick_Templates[] = "QtQuick.Templates";
|
||||
inline constexpr char QtQuick_Timeline[] = "QtQuick.Timeline";
|
||||
inline constexpr char QtQuick_Window[] = "QtQuick.Window";
|
||||
inline constexpr char QtQuick_cppnative[] = "QtQuick-cppnative";
|
||||
inline constexpr char Qt_SafeRenderer[] = "Qt.SafeRenderer";
|
||||
inline constexpr char Rectangle[] = "Rectangle";
|
||||
inline constexpr char Repeater[] = "Repeater";
|
||||
@@ -149,7 +146,7 @@ struct BaseCacheType
|
||||
QmlDesigner::TypeId typeId;
|
||||
};
|
||||
|
||||
template<const char *moduleName_, const char *typeName_>
|
||||
template<const char *moduleName_, ModuleKind moduleKind, const char *typeName_>
|
||||
struct CacheType : public BaseCacheType
|
||||
{
|
||||
};
|
||||
@@ -157,106 +154,107 @@ struct CacheType : public BaseCacheType
|
||||
template<typename ProjectStorage>
|
||||
class CommonTypeCache
|
||||
{
|
||||
using CommonTypes = std::tuple<CacheType<FlowView, FlowActionArea>,
|
||||
CacheType<FlowView, FlowDecision>,
|
||||
CacheType<FlowView, FlowItem>,
|
||||
CacheType<FlowView, FlowTransition>,
|
||||
CacheType<FlowView, FlowView>,
|
||||
CacheType<FlowView, FlowWildcard>,
|
||||
CacheType<QML, BoolType>,
|
||||
CacheType<QML, Component>,
|
||||
CacheType<QML, DoubleType>,
|
||||
CacheType<QML, IntType>,
|
||||
CacheType<QML, QtObject>,
|
||||
CacheType<QML, date>,
|
||||
CacheType<QML, string>,
|
||||
CacheType<QML, url>,
|
||||
CacheType<QML, var>,
|
||||
CacheType<QML_cppnative, FloatType>,
|
||||
CacheType<QML_cppnative, UIntType>,
|
||||
CacheType<QtQml, Connections>,
|
||||
CacheType<QtMultimedia, SoundEffect>,
|
||||
CacheType<QtQml_Models, ListElement>,
|
||||
CacheType<QtQml_Models, ListModel>,
|
||||
CacheType<QtQml_XmlListModel, XmlListModelRole>,
|
||||
CacheType<QtQuick, BorderImage>,
|
||||
CacheType<QtQuick, GridView>,
|
||||
CacheType<QtQuick, Image>,
|
||||
CacheType<QtQuick, Item>,
|
||||
CacheType<QtQuick, ListView>,
|
||||
CacheType<QtQuick, Loader>,
|
||||
CacheType<QtQuick, MouseArea>,
|
||||
CacheType<QtQuick, Path>,
|
||||
CacheType<QtQuick, PathView>,
|
||||
CacheType<QtQuick, PauseAnimation>,
|
||||
CacheType<QtQuick, Positioner>,
|
||||
CacheType<QtQuick, PropertyAnimation>,
|
||||
CacheType<QtQuick, PropertyChanges>,
|
||||
CacheType<QtQuick, Rectangle>,
|
||||
CacheType<QtQuick, Repeater>,
|
||||
CacheType<QtQuick, State>,
|
||||
CacheType<QtQuick, StateGroup>,
|
||||
CacheType<QtQuick, Text>,
|
||||
CacheType<QtQuick, TextEdit>,
|
||||
CacheType<QtQuick, Transition>,
|
||||
CacheType<QtQuick, color>,
|
||||
CacheType<QtQuick, font>,
|
||||
CacheType<QtQuick, vector2d>,
|
||||
CacheType<QtQuick, vector3d>,
|
||||
CacheType<QtQuick, vector4d>,
|
||||
CacheType<QtQuick3D, BakedLightmap>,
|
||||
CacheType<QtQuick3D, Buffer>,
|
||||
CacheType<QtQuick3D, Camera>,
|
||||
CacheType<QtQuick3D, Command>,
|
||||
CacheType<QtQuick3D, CubeMapTexture>,
|
||||
CacheType<QtQuick3D, DefaultMaterial>,
|
||||
CacheType<QtQuick3D, DirectionalLight>,
|
||||
CacheType<QtQuick3D, Effect>,
|
||||
CacheType<QtQuick3D, InstanceList>,
|
||||
CacheType<QtQuick3D, InstanceListEntry>,
|
||||
CacheType<QtQuick3D, Light>,
|
||||
CacheType<QtQuick3D, Material>,
|
||||
CacheType<QtQuick3D, Model>,
|
||||
CacheType<QtQuick3D, Node>,
|
||||
CacheType<QtQuick3D, OrthographicCamera>,
|
||||
CacheType<QtQuick3D, Pass>,
|
||||
CacheType<QtQuick3D, PerspectiveCamera>,
|
||||
CacheType<QtQuick3D, PointLight>,
|
||||
CacheType<QtQuick3D, PrincipledMaterial>,
|
||||
CacheType<QtQuick3D, SceneEnvironment>,
|
||||
CacheType<QtQuick3D, Shader>,
|
||||
CacheType<QtQuick3D, SpecularGlossyMaterial>,
|
||||
CacheType<QtQuick3D, SpotLight>,
|
||||
CacheType<QtQuick3D, Texture>,
|
||||
CacheType<QtQuick3D, TextureInput>,
|
||||
CacheType<QtQuick3D, View3D>,
|
||||
CacheType<QtQuick3D_Particles3D, Affector3D>,
|
||||
CacheType<QtQuick3D_Particles3D, Attractor3D>,
|
||||
CacheType<QtQuick3D_Particles3D, Model>,
|
||||
CacheType<QtQuick3D_Particles3D, Particle3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ParticleEmitter3D>,
|
||||
CacheType<QtQuick3D_Particles3D, SpriteParticle3D>,
|
||||
CacheType<QtQuick3D_Particles3D_cppnative, QQuick3DParticleAbstractShape>,
|
||||
CacheType<QtQuick_Controls, Control>,
|
||||
CacheType<QtQuick_Controls, Popup>,
|
||||
CacheType<QtQuick_Controls, SplitView>,
|
||||
CacheType<QtQuick_Controls, SwipeView>,
|
||||
CacheType<QtQuick_Controls, TabBar>,
|
||||
CacheType<QtQuick_Controls, TextArea>,
|
||||
CacheType<QtQuick_Dialogs, Dialog>,
|
||||
CacheType<QtQuick_Extras, Picture>,
|
||||
CacheType<QtQuick_Layouts, Layout>,
|
||||
CacheType<QtQuick_Studio_Components, GroupItem>,
|
||||
CacheType<QtQuick_Studio_Components, JsonListModel>,
|
||||
CacheType<QtQuick_Templates, Control>,
|
||||
CacheType<QtQuick_Timeline, Keyframe>,
|
||||
CacheType<QtQuick_Timeline, KeyframeGroup>,
|
||||
CacheType<QtQuick_Timeline, Timeline>,
|
||||
CacheType<QtQuick_Timeline, TimelineAnimation>,
|
||||
CacheType<QtQuick_cppnative, QQuickStateOperation>,
|
||||
CacheType<Qt_SafeRenderer, SafePicture>,
|
||||
CacheType<Qt_SafeRenderer, SafeRendererPicture>,
|
||||
CacheType<QtQuick_Window, Window>>;
|
||||
using CommonTypes = std::tuple<
|
||||
CacheType<FlowView, ModuleKind::QmlLibrary, FlowActionArea>,
|
||||
CacheType<FlowView, ModuleKind::QmlLibrary, FlowDecision>,
|
||||
CacheType<FlowView, ModuleKind::QmlLibrary, FlowItem>,
|
||||
CacheType<FlowView, ModuleKind::QmlLibrary, FlowTransition>,
|
||||
CacheType<FlowView, ModuleKind::QmlLibrary, FlowView>,
|
||||
CacheType<FlowView, ModuleKind::QmlLibrary, FlowWildcard>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, BoolType>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, Component>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, DoubleType>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, IntType>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, QtObject>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, date>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, string>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, url>,
|
||||
CacheType<QML, ModuleKind::QmlLibrary, var>,
|
||||
CacheType<QML, ModuleKind::CppLibrary, FloatType>,
|
||||
CacheType<QML, ModuleKind::CppLibrary, UIntType>,
|
||||
CacheType<QtQml, ModuleKind::QmlLibrary, Connections>,
|
||||
CacheType<QtMultimedia, ModuleKind::QmlLibrary, SoundEffect>,
|
||||
CacheType<QtQml_Models, ModuleKind::QmlLibrary, ListElement>,
|
||||
CacheType<QtQml_Models, ModuleKind::QmlLibrary, ListModel>,
|
||||
CacheType<QtQml_XmlListModel, ModuleKind::QmlLibrary, XmlListModelRole>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, BorderImage>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, GridView>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Image>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Item>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, ListView>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Loader>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, MouseArea>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Path>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, PathView>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, PauseAnimation>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Positioner>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, PropertyAnimation>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, PropertyChanges>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Rectangle>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Repeater>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, State>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, StateGroup>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Text>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, TextEdit>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, Transition>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, color>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, font>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, vector2d>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, vector3d>,
|
||||
CacheType<QtQuick, ModuleKind::QmlLibrary, vector4d>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, BakedLightmap>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Buffer>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Camera>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Command>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, CubeMapTexture>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, DefaultMaterial>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, DirectionalLight>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Effect>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, InstanceList>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, InstanceListEntry>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Light>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Material>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Model>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Node>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, OrthographicCamera>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Pass>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, PerspectiveCamera>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, PointLight>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, PrincipledMaterial>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, SceneEnvironment>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Shader>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, SpecularGlossyMaterial>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, SpotLight>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Texture>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, TextureInput>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, View3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, Affector3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, Attractor3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, Model>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, Particle3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, ParticleEmitter3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, SpriteParticle3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::CppLibrary, QQuick3DParticleAbstractShape>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, Control>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, Popup>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, SplitView>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, SwipeView>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, TabBar>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, TextArea>,
|
||||
CacheType<QtQuick_Dialogs, ModuleKind::QmlLibrary, Dialog>,
|
||||
CacheType<QtQuick_Extras, ModuleKind::QmlLibrary, Picture>,
|
||||
CacheType<QtQuick_Layouts, ModuleKind::QmlLibrary, Layout>,
|
||||
CacheType<QtQuick_Studio_Components, ModuleKind::QmlLibrary, GroupItem>,
|
||||
CacheType<QtQuick_Studio_Components, ModuleKind::QmlLibrary, JsonListModel>,
|
||||
CacheType<QtQuick_Templates, ModuleKind::QmlLibrary, Control>,
|
||||
CacheType<QtQuick_Timeline, ModuleKind::QmlLibrary, Keyframe>,
|
||||
CacheType<QtQuick_Timeline, ModuleKind::QmlLibrary, KeyframeGroup>,
|
||||
CacheType<QtQuick_Timeline, ModuleKind::QmlLibrary, Timeline>,
|
||||
CacheType<QtQuick_Timeline, ModuleKind::QmlLibrary, TimelineAnimation>,
|
||||
CacheType<QtQuick, ModuleKind::CppLibrary, QQuickStateOperation>,
|
||||
CacheType<Qt_SafeRenderer, ModuleKind::QmlLibrary, SafePicture>,
|
||||
CacheType<Qt_SafeRenderer, ModuleKind::QmlLibrary, SafeRendererPicture>,
|
||||
CacheType<QtQuick_Window, ModuleKind::QmlLibrary, Window>>;
|
||||
|
||||
public:
|
||||
CommonTypeCache(const ProjectStorage &projectStorage)
|
||||
@@ -283,14 +281,14 @@ public:
|
||||
std::fill(std::begin(m_typesWithoutProperties), std ::end(m_typesWithoutProperties), TypeId{});
|
||||
}
|
||||
|
||||
template<const char *moduleName, const char *typeName>
|
||||
template<const char *moduleName, const char *typeName, ModuleKind moduleKind = ModuleKind::QmlLibrary>
|
||||
TypeId typeId() const
|
||||
{
|
||||
auto &type = std::get<CacheType<moduleName, typeName>>(m_types);
|
||||
auto &type = std::get<CacheType<moduleName, moduleKind, typeName>>(m_types);
|
||||
if (type.typeId)
|
||||
return type.typeId;
|
||||
|
||||
return refreshTypedId(type, moduleName, typeName);
|
||||
return refreshTypedId(type, moduleName, moduleKind, typeName);
|
||||
}
|
||||
|
||||
template<const char *typeName>
|
||||
@@ -307,11 +305,11 @@ public:
|
||||
else if constexpr (std::is_same_v<Type, int>)
|
||||
return typeId<QML, IntType>();
|
||||
else if constexpr (std::is_same_v<Type, uint>)
|
||||
return typeId<QML_cppnative, UIntType>();
|
||||
return typeId<QML, UIntType, ModuleKind::CppLibrary>();
|
||||
else if constexpr (std::is_same_v<Type, bool>)
|
||||
return typeId<QML, BoolType>();
|
||||
else if constexpr (std::is_same_v<Type, float>)
|
||||
return typeId<QML_cppnative, FloatType>();
|
||||
return typeId<QML, FloatType, ModuleKind::CppLibrary>();
|
||||
else if constexpr (std::is_same_v<Type, QString>)
|
||||
return typeId<QML, string>();
|
||||
else if constexpr (std::is_same_v<Type, QDateTime>)
|
||||
@@ -341,10 +339,11 @@ public:
|
||||
private:
|
||||
TypeId refreshTypedId(BaseCacheType &type,
|
||||
::Utils::SmallStringView moduleName,
|
||||
ModuleKind moduleKind,
|
||||
::Utils::SmallStringView typeName) const
|
||||
{
|
||||
if (!type.moduleId)
|
||||
type.moduleId = m_projectStorage.moduleId(moduleName);
|
||||
type.moduleId = m_projectStorage.moduleId(moduleName, moduleKind);
|
||||
|
||||
type.typeId = m_projectStorage.typeId(type.moduleId, typeName, Storage::Version{});
|
||||
|
||||
@@ -353,10 +352,11 @@ private:
|
||||
|
||||
TypeId refreshTypedIdWithoutTransaction(BaseCacheType &type,
|
||||
::Utils::SmallStringView moduleName,
|
||||
::Utils::SmallStringView typeName) const
|
||||
::Utils::SmallStringView typeName,
|
||||
ModuleKind moduleKind) const
|
||||
{
|
||||
if (!type.moduleId)
|
||||
type.moduleId = m_projectStorage.fetchModuleIdUnguarded(moduleName);
|
||||
type.moduleId = m_projectStorage.fetchModuleIdUnguarded(moduleName, moduleKind);
|
||||
|
||||
type.typeId = m_projectStorage.fetchTypeIdByModuleIdAndExportedName(type.moduleId, typeName);
|
||||
|
||||
@@ -371,26 +371,27 @@ private:
|
||||
std::copy(std::begin(typeIds), std::end(typeIds), std::begin(m_typesWithoutProperties));
|
||||
}
|
||||
|
||||
template<const char *moduleName, const char *typeName>
|
||||
template<const char *moduleName, const char *typeName, ModuleKind moduleKind = ModuleKind::QmlLibrary>
|
||||
TypeId typeIdWithoutTransaction() const
|
||||
{
|
||||
auto &type = std::get<CacheType<moduleName, typeName>>(m_types);
|
||||
auto &type = std::get<CacheType<moduleName, moduleKind, typeName>>(m_types);
|
||||
if (type.typeId)
|
||||
return type.typeId;
|
||||
|
||||
return refreshTypedIdWithoutTransaction(type, moduleName, typeName);
|
||||
return refreshTypedIdWithoutTransaction(type, moduleName, typeName, moduleKind);
|
||||
}
|
||||
|
||||
void updateTypeIdsWithoutProperties()
|
||||
{
|
||||
setupTypeIdsWithoutProperties({typeIdWithoutTransaction<QML, BoolType>(),
|
||||
typeIdWithoutTransaction<QML, IntType>(),
|
||||
typeIdWithoutTransaction<QML_cppnative, UIntType>(),
|
||||
typeIdWithoutTransaction<QML, DoubleType>(),
|
||||
typeIdWithoutTransaction<QML_cppnative, FloatType>(),
|
||||
typeIdWithoutTransaction<QML, date>(),
|
||||
typeIdWithoutTransaction<QML, string>(),
|
||||
typeIdWithoutTransaction<QML, url>()});
|
||||
setupTypeIdsWithoutProperties(
|
||||
{typeIdWithoutTransaction<QML, BoolType>(),
|
||||
typeIdWithoutTransaction<QML, IntType>(),
|
||||
typeIdWithoutTransaction<QML, UIntType, ModuleKind::CppLibrary>(),
|
||||
typeIdWithoutTransaction<QML, DoubleType>(),
|
||||
typeIdWithoutTransaction<QML, FloatType, ModuleKind::CppLibrary>(),
|
||||
typeIdWithoutTransaction<QML, date>(),
|
||||
typeIdWithoutTransaction<QML, string>(),
|
||||
typeIdWithoutTransaction<QML, url>()});
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -235,14 +235,14 @@ struct ProjectStorage::Statements
|
||||
database};
|
||||
Sqlite::WriteStatement<1> deleteEnumerationDeclarationStatement{
|
||||
"DELETE FROM enumerationDeclarations WHERE enumerationDeclarationId=?", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectModuleIdByNameStatement{
|
||||
"SELECT moduleId FROM modules WHERE name=? LIMIT 1", database};
|
||||
mutable Sqlite::ReadWriteStatement<1, 1> insertModuleNameStatement{
|
||||
"INSERT INTO modules(name) VALUES(?1) RETURNING moduleId", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectModuleNameStatement{
|
||||
"SELECT name FROM modules WHERE moduleId =?1", database};
|
||||
mutable Sqlite::ReadStatement<2> selectAllModulesStatement{"SELECT name, moduleId FROM modules",
|
||||
database};
|
||||
mutable Sqlite::ReadStatement<1, 2> selectModuleIdByNameStatement{
|
||||
"SELECT moduleId FROM modules WHERE kind=?1 AND name=?2 LIMIT 1", database};
|
||||
mutable Sqlite::ReadWriteStatement<1, 2> insertModuleNameStatement{
|
||||
"INSERT INTO modules(kind, name) VALUES(?1, ?2) RETURNING moduleId", database};
|
||||
mutable Sqlite::ReadStatement<2, 1> selectModuleStatement{
|
||||
"SELECT name, kind FROM modules WHERE moduleId =?1", database};
|
||||
mutable Sqlite::ReadStatement<3> selectAllModulesStatement{
|
||||
"SELECT name, kind, moduleId FROM modules", database};
|
||||
mutable Sqlite::ReadStatement<1, 2> selectTypeIdBySourceIdAndNameStatement{
|
||||
"SELECT typeId FROM types WHERE sourceId=?1 and name=?2", database};
|
||||
mutable Sqlite::ReadStatement<1, 3> selectTypeIdByModuleIdsAndExportedNameStatement{
|
||||
@@ -942,9 +942,10 @@ public:
|
||||
auto &modelIdColumn = table.addColumn("moduleId",
|
||||
Sqlite::StrictColumnType::Integer,
|
||||
{Sqlite::PrimaryKey{}});
|
||||
auto &kindColumn = table.addColumn("kind", Sqlite::StrictColumnType::Integer);
|
||||
auto &nameColumn = table.addColumn("name", Sqlite::StrictColumnType::Text);
|
||||
|
||||
table.addUniqueIndex({nameColumn});
|
||||
table.addUniqueIndex({kindColumn, nameColumn});
|
||||
|
||||
table.initialize(database);
|
||||
|
||||
@@ -1207,21 +1208,21 @@ void ProjectStorage::removeObserver(ProjectStorageObserver *observer)
|
||||
observers.removeOne(observer);
|
||||
}
|
||||
|
||||
ModuleId ProjectStorage::moduleId(Utils::SmallStringView moduleName) const
|
||||
ModuleId ProjectStorage::moduleId(Utils::SmallStringView moduleName, Storage::ModuleKind kind) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"get module id"_t,
|
||||
projectStorageCategory(),
|
||||
keyValue("module name", moduleName)};
|
||||
|
||||
auto moduleId = moduleCache.id(moduleName);
|
||||
auto moduleId = moduleCache.id({moduleName, kind});
|
||||
|
||||
tracer.end(keyValue("module id", moduleId));
|
||||
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
Utils::SmallString ProjectStorage::moduleName(ModuleId moduleId) const
|
||||
Storage::Module ProjectStorage::module(ModuleId moduleId) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"get module name"_t,
|
||||
@@ -1231,11 +1232,12 @@ Utils::SmallString ProjectStorage::moduleName(ModuleId moduleId) const
|
||||
if (!moduleId)
|
||||
throw ModuleDoesNotExists{};
|
||||
|
||||
auto moduleName = moduleCache.value(moduleId);
|
||||
auto module = moduleCache.value(moduleId);
|
||||
|
||||
tracer.end(keyValue("module name", moduleName));
|
||||
tracer.end(keyValue("module name", module.name));
|
||||
tracer.end(keyValue("module kind", module.kind));
|
||||
|
||||
return moduleName;
|
||||
return {module.name, module.kind};
|
||||
}
|
||||
|
||||
TypeId ProjectStorage::typeId(ModuleId moduleId,
|
||||
@@ -2168,20 +2170,17 @@ void ProjectStorage::resetForTestsOnly()
|
||||
moduleCache.clearForTestOnly();
|
||||
}
|
||||
|
||||
bool ProjectStorage::moduleNameLess(Utils::SmallStringView first, Utils::SmallStringView second) noexcept
|
||||
{
|
||||
return first < second;
|
||||
}
|
||||
|
||||
ModuleId ProjectStorage::fetchModuleId(Utils::SmallStringView moduleName)
|
||||
ModuleId ProjectStorage::fetchModuleId(Utils::SmallStringView moduleName,
|
||||
Storage::ModuleKind moduleKind)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch module id"_t,
|
||||
projectStorageCategory(),
|
||||
keyValue("module name", moduleName)};
|
||||
keyValue("module name", moduleName),
|
||||
keyValue("module kind", moduleKind)};
|
||||
|
||||
auto moduleId = Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchModuleIdUnguarded(moduleName);
|
||||
return fetchModuleIdUnguarded(moduleName, moduleKind);
|
||||
});
|
||||
|
||||
tracer.end(keyValue("module id", moduleId));
|
||||
@@ -2189,26 +2188,26 @@ ModuleId ProjectStorage::fetchModuleId(Utils::SmallStringView moduleName)
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
Utils::PathString ProjectStorage::fetchModuleName(ModuleId id)
|
||||
Storage::Module ProjectStorage::fetchModule(ModuleId id)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch module name"_t,
|
||||
projectStorageCategory(),
|
||||
keyValue("module id", id)};
|
||||
|
||||
auto moduleName = Sqlite::withDeferredTransaction(database,
|
||||
[&] { return fetchModuleNameUnguarded(id); });
|
||||
auto module = Sqlite::withDeferredTransaction(database, [&] { return fetchModuleUnguarded(id); });
|
||||
|
||||
tracer.end(keyValue("module name", moduleName));
|
||||
tracer.end(keyValue("module name", module.name));
|
||||
tracer.end(keyValue("module name", module.kind));
|
||||
|
||||
return moduleName;
|
||||
return module;
|
||||
}
|
||||
|
||||
ProjectStorage::Modules ProjectStorage::fetchAllModules() const
|
||||
ProjectStorage::ModuleCacheEntries ProjectStorage::fetchAllModules() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch all modules"_t, projectStorageCategory()};
|
||||
|
||||
return s->selectAllModulesStatement.valuesWithTransaction<Module, 128>();
|
||||
return s->selectAllModulesStatement.valuesWithTransaction<ModuleCacheEntry, 128>();
|
||||
}
|
||||
|
||||
void ProjectStorage::callRefreshMetaInfoCallback(const TypeIds &deletedTypeIds)
|
||||
@@ -2644,38 +2643,41 @@ void ProjectStorage::synchromizeModuleExportedImports(
|
||||
Sqlite::insertUpdateDelete(range, moduleExportedImports, compareKey, insert, update, remove);
|
||||
}
|
||||
|
||||
ModuleId ProjectStorage::fetchModuleIdUnguarded(Utils::SmallStringView name) const
|
||||
ModuleId ProjectStorage::fetchModuleIdUnguarded(Utils::SmallStringView name,
|
||||
Storage::ModuleKind kind) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch module id ungarded"_t,
|
||||
projectStorageCategory(),
|
||||
keyValue("module name", name)};
|
||||
keyValue("module name", name),
|
||||
keyValue("module kind", kind)};
|
||||
|
||||
auto moduleId = s->selectModuleIdByNameStatement.value<ModuleId>(name);
|
||||
auto moduleId = s->selectModuleIdByNameStatement.value<ModuleId>(kind, name);
|
||||
|
||||
if (!moduleId)
|
||||
moduleId = s->insertModuleNameStatement.value<ModuleId>(name);
|
||||
moduleId = s->insertModuleNameStatement.value<ModuleId>(kind, name);
|
||||
|
||||
tracer.end(keyValue("module id", moduleId));
|
||||
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
Utils::PathString ProjectStorage::fetchModuleNameUnguarded(ModuleId id) const
|
||||
Storage::Module ProjectStorage::fetchModuleUnguarded(ModuleId id) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch module name ungarded"_t,
|
||||
NanotraceHR::Tracer tracer{"fetch module ungarded"_t,
|
||||
projectStorageCategory(),
|
||||
keyValue("module id", id)};
|
||||
|
||||
auto moduleName = s->selectModuleNameStatement.value<Utils::PathString>(id);
|
||||
auto module = s->selectModuleStatement.value<Storage::Module>(id);
|
||||
|
||||
if (moduleName.empty())
|
||||
if (!module)
|
||||
throw ModuleDoesNotExists{};
|
||||
|
||||
tracer.end(keyValue("module name", moduleName));
|
||||
tracer.end(keyValue("module name", module.name));
|
||||
tracer.end(keyValue("module name", module.kind));
|
||||
|
||||
return moduleName;
|
||||
return module;
|
||||
}
|
||||
|
||||
void ProjectStorage::handleAliasPropertyDeclarationsWithPropertyType(
|
||||
|
||||
@@ -50,9 +50,9 @@ public:
|
||||
|
||||
void removeObserver(ProjectStorageObserver *observer) override;
|
||||
|
||||
ModuleId moduleId(Utils::SmallStringView moduleName) const override;
|
||||
ModuleId moduleId(Utils::SmallStringView moduleName, Storage::ModuleKind kind) const override;
|
||||
|
||||
Utils::SmallString moduleName(ModuleId moduleId) const override;
|
||||
Storage::Module module(ModuleId moduleId) const override;
|
||||
|
||||
TypeId typeId(ModuleId moduleId,
|
||||
Utils::SmallStringView exportedTypeName,
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
return commonTypeCache_;
|
||||
}
|
||||
|
||||
template<const char *moduleName, const char *typeName>
|
||||
template<const char *moduleName, const char *typeName, Storage::ModuleKind moduleKind = Storage::ModuleKind::QmlLibrary>
|
||||
TypeId commonTypeId() const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
keyValue("module name", std::string_view{moduleName}),
|
||||
keyValue("type name", std::string_view{typeName})};
|
||||
|
||||
auto typeId = commonTypeCache_.typeId<moduleName, typeName>();
|
||||
auto typeId = commonTypeCache_.typeId<moduleName, typeName, moduleKind>();
|
||||
|
||||
tracer.end(keyValue("type id", typeId));
|
||||
|
||||
@@ -244,50 +244,90 @@ public:
|
||||
void resetForTestsOnly();
|
||||
|
||||
private:
|
||||
struct ModuleView
|
||||
{
|
||||
ModuleView() = default;
|
||||
|
||||
ModuleView(Utils::SmallStringView name, Storage::ModuleKind kind)
|
||||
: name{name}
|
||||
, kind{kind}
|
||||
{}
|
||||
|
||||
ModuleView(const Storage::Module &module)
|
||||
: name{module.name}
|
||||
, kind{module.kind}
|
||||
{}
|
||||
|
||||
Utils::SmallStringView name;
|
||||
Storage::ModuleKind kind;
|
||||
|
||||
friend bool operator<(ModuleView first, ModuleView second)
|
||||
{
|
||||
return std::tie(first.kind, first.name) < std::tie(second.kind, second.name);
|
||||
}
|
||||
|
||||
friend bool operator==(const Storage::Module &first, ModuleView second)
|
||||
{
|
||||
return first.name == second.name && first.kind == second.kind;
|
||||
}
|
||||
|
||||
friend bool operator==(ModuleView first, const Storage::Module &second)
|
||||
{
|
||||
return second == first;
|
||||
}
|
||||
};
|
||||
|
||||
class ModuleStorageAdapter
|
||||
{
|
||||
public:
|
||||
auto fetchId(const Utils::SmallStringView name) { return storage.fetchModuleId(name); }
|
||||
auto fetchId(ModuleView module) { return storage.fetchModuleId(module.name, module.kind); }
|
||||
|
||||
auto fetchValue(ModuleId id) { return storage.fetchModuleName(id); }
|
||||
auto fetchValue(ModuleId id) { return storage.fetchModule(id); }
|
||||
|
||||
auto fetchAll() { return storage.fetchAllModules(); }
|
||||
|
||||
ProjectStorage &storage;
|
||||
};
|
||||
|
||||
class Module : public StorageCacheEntry<Utils::PathString, Utils::SmallStringView, ModuleId>
|
||||
friend ModuleStorageAdapter;
|
||||
|
||||
static bool moduleNameLess(ModuleView first, ModuleView second) noexcept
|
||||
{
|
||||
using Base = StorageCacheEntry<Utils::PathString, Utils::SmallStringView, ModuleId>;
|
||||
return first < second;
|
||||
}
|
||||
|
||||
class ModuleCacheEntry : public StorageCacheEntry<Storage::Module, ModuleView, ModuleId>
|
||||
{
|
||||
using Base = StorageCacheEntry<Storage::Module, ModuleView, ModuleId>;
|
||||
|
||||
public:
|
||||
using Base::Base;
|
||||
|
||||
friend bool operator==(const Module &first, const Module &second)
|
||||
ModuleCacheEntry(Utils::SmallStringView name, Storage::ModuleKind kind, ModuleId moduleId)
|
||||
: Base{{name, kind}, moduleId}
|
||||
{}
|
||||
|
||||
friend bool operator==(const ModuleCacheEntry &first, const ModuleCacheEntry &second)
|
||||
{
|
||||
return &first == &second && first.value == second.value;
|
||||
}
|
||||
|
||||
friend bool operator==(const ModuleCacheEntry &first, ModuleView second)
|
||||
{
|
||||
return first.value.name == second.name && first.value.kind == second.kind;
|
||||
}
|
||||
};
|
||||
|
||||
using Modules = std::vector<Module>;
|
||||
using ModuleCacheEntries = std::vector<ModuleCacheEntry>;
|
||||
|
||||
friend ModuleStorageAdapter;
|
||||
using ModuleCache
|
||||
= StorageCache<Storage::Module, ModuleView, ModuleId, ModuleStorageAdapter, NonLockingMutex, moduleNameLess, ModuleCacheEntry>;
|
||||
|
||||
static bool moduleNameLess(Utils::SmallStringView first, Utils::SmallStringView second) noexcept;
|
||||
ModuleId fetchModuleId(Utils::SmallStringView moduleName, Storage::ModuleKind moduleKind);
|
||||
|
||||
using ModuleCache = StorageCache<Utils::PathString,
|
||||
Utils::SmallStringView,
|
||||
ModuleId,
|
||||
ModuleStorageAdapter,
|
||||
NonLockingMutex,
|
||||
moduleNameLess,
|
||||
Module>;
|
||||
Storage::Module fetchModule(ModuleId id);
|
||||
|
||||
ModuleId fetchModuleId(Utils::SmallStringView moduleName);
|
||||
|
||||
Utils::PathString fetchModuleName(ModuleId id);
|
||||
|
||||
Modules fetchAllModules() const;
|
||||
ModuleCacheEntries fetchAllModules() const;
|
||||
|
||||
void callRefreshMetaInfoCallback(const TypeIds &deletedTypeIds);
|
||||
|
||||
@@ -532,9 +572,10 @@ private:
|
||||
Storage::Synchronization::ModuleExportedImports &moduleExportedImports,
|
||||
const ModuleIds &updatedModuleIds);
|
||||
|
||||
ModuleId fetchModuleIdUnguarded(Utils::SmallStringView name) const override;
|
||||
ModuleId fetchModuleIdUnguarded(Utils::SmallStringView name,
|
||||
Storage::ModuleKind moduleKind) const override;
|
||||
|
||||
Utils::PathString fetchModuleNameUnguarded(ModuleId id) const;
|
||||
Storage::Module fetchModuleUnguarded(ModuleId id) const;
|
||||
|
||||
void handleAliasPropertyDeclarationsWithPropertyType(
|
||||
TypeId typeId, AliasPropertyDeclarations &relinkableAliasPropertyDeclarations);
|
||||
|
||||
@@ -42,6 +42,34 @@ void convertToString(String &string, const FlagIs &flagIs)
|
||||
|
||||
namespace QmlDesigner::Storage {
|
||||
|
||||
enum class ModuleKind { QmlLibrary, CppLibrary, PathLibrary };
|
||||
|
||||
struct Module
|
||||
{
|
||||
Module() = default;
|
||||
|
||||
Module(Utils::SmallStringView name, Storage::ModuleKind kind)
|
||||
: name{name}
|
||||
, kind{kind}
|
||||
{}
|
||||
|
||||
template<typename ModuleType>
|
||||
Module(const ModuleType &module)
|
||||
: name{module.name}
|
||||
, kind{module.kind}
|
||||
{}
|
||||
|
||||
Utils::PathString name;
|
||||
Storage::ModuleKind kind = Storage::ModuleKind::QmlLibrary;
|
||||
|
||||
friend bool operator==(const Module &first, const Module &second)
|
||||
{
|
||||
return first.name == second.name && first.kind == second.kind;
|
||||
}
|
||||
|
||||
explicit operator bool() const { return name.size(); }
|
||||
};
|
||||
|
||||
enum class PropertyDeclarationTraits : int {
|
||||
None = 0,
|
||||
IsReadOnly = 1 << 0,
|
||||
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
virtual void addObserver(ProjectStorageObserver *observer) = 0;
|
||||
virtual void removeObserver(ProjectStorageObserver *observer) = 0;
|
||||
|
||||
virtual ModuleId moduleId(::Utils::SmallStringView name) const = 0;
|
||||
virtual Utils::SmallString moduleName(ModuleId moduleId) const = 0;
|
||||
virtual ModuleId moduleId(::Utils::SmallStringView name, Storage::ModuleKind kind) const = 0;
|
||||
virtual QmlDesigner::Storage::Module module(ModuleId moduleId) const = 0;
|
||||
virtual std::optional<Storage::Info::PropertyDeclaration>
|
||||
propertyDeclaration(PropertyDeclarationId propertyDeclarationId) const = 0;
|
||||
virtual TypeId typeId(ModuleId moduleId,
|
||||
@@ -86,10 +86,10 @@ public:
|
||||
virtual SourceId propertyEditorPathId(TypeId typeId) const = 0;
|
||||
virtual const Storage::Info::CommonTypeCache<ProjectStorageType> &commonTypeCache() const = 0;
|
||||
|
||||
template<const char *moduleName, const char *typeName>
|
||||
template<const char *moduleName, const char *typeName, Storage::ModuleKind moduleKind = Storage::ModuleKind::QmlLibrary>
|
||||
TypeId commonTypeId() const
|
||||
{
|
||||
return commonTypeCache().template typeId<moduleName, typeName>();
|
||||
return commonTypeCache().template typeId<moduleName, typeName, moduleKind>();
|
||||
}
|
||||
|
||||
template<typename BuiltinType>
|
||||
@@ -108,7 +108,7 @@ protected:
|
||||
ProjectStorageInterface() = default;
|
||||
~ProjectStorageInterface() = default;
|
||||
|
||||
virtual ModuleId fetchModuleIdUnguarded(Utils::SmallStringView name) const = 0;
|
||||
virtual ModuleId fetchModuleIdUnguarded(Utils::SmallStringView name, Storage::ModuleKind moduleKind) const = 0;
|
||||
virtual TypeId fetchTypeIdByModuleIdAndExportedName(ModuleId moduleId, Utils::SmallStringView name) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -164,8 +164,8 @@ void addDependencies(Storage::Imports &dependencies,
|
||||
Tracer &tracer)
|
||||
{
|
||||
for (const QmlDirParser::Import &qmldirDependency : qmldirDependencies) {
|
||||
ModuleId moduleId = projectStorage.moduleId(Utils::PathString{qmldirDependency.module}
|
||||
+ "-cppnative");
|
||||
ModuleId moduleId = projectStorage.moduleId(Utils::PathString{qmldirDependency.module},
|
||||
Storage::ModuleKind::CppLibrary);
|
||||
auto &import = dependencies.emplace_back(moduleId, Storage::Version{}, sourceId);
|
||||
tracer.tick(message, keyValue("import", import));
|
||||
}
|
||||
@@ -177,6 +177,7 @@ void addModuleExportedImport(Storage::Synchronization::ModuleExportedImports &im
|
||||
Storage::Version version,
|
||||
Storage::Synchronization::IsAutoVersion isAutoVersion,
|
||||
std::string_view moduleName,
|
||||
Storage::ModuleKind moduleKind,
|
||||
std::string_view exportedModuleName)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"add module exported imports"_t,
|
||||
@@ -186,6 +187,7 @@ void addModuleExportedImport(Storage::Synchronization::ModuleExportedImports &im
|
||||
keyValue("version", version),
|
||||
keyValue("is auto version", isAutoVersion),
|
||||
keyValue("module name", moduleName),
|
||||
keyValue("module kind", moduleKind),
|
||||
keyValue("exported module name", exportedModuleName)};
|
||||
|
||||
imports.emplace_back(moduleId, exportedModuleId, version, isAutoVersion);
|
||||
@@ -200,7 +202,6 @@ void addModuleExportedImports(Storage::Synchronization::ModuleExportedImports &i
|
||||
ModuleId moduleId,
|
||||
ModuleId cppModuleId,
|
||||
std::string_view moduleName,
|
||||
std::string_view cppModuleName,
|
||||
const QList<QmlDirParser::Import> &qmldirImports,
|
||||
ProjectStorageInterface &projectStorage)
|
||||
{
|
||||
@@ -214,23 +215,27 @@ void addModuleExportedImports(Storage::Synchronization::ModuleExportedImports &i
|
||||
continue;
|
||||
|
||||
Utils::PathString exportedModuleName{qmldirImport.module};
|
||||
ModuleId exportedModuleId = projectStorage.moduleId(exportedModuleName);
|
||||
using Storage::ModuleKind;
|
||||
ModuleId exportedModuleId = projectStorage.moduleId(exportedModuleName,
|
||||
ModuleKind::QmlLibrary);
|
||||
addModuleExportedImport(imports,
|
||||
moduleId,
|
||||
exportedModuleId,
|
||||
convertVersion(qmldirImport.version),
|
||||
convertToIsAutoVersion(qmldirImport.flags),
|
||||
moduleName,
|
||||
ModuleKind::QmlLibrary,
|
||||
exportedModuleName);
|
||||
|
||||
exportedModuleName += "-cppnative";
|
||||
ModuleId exportedCppModuleId = projectStorage.moduleId(exportedModuleName);
|
||||
ModuleId exportedCppModuleId = projectStorage.moduleId(exportedModuleName,
|
||||
ModuleKind::CppLibrary);
|
||||
addModuleExportedImport(imports,
|
||||
cppModuleId,
|
||||
exportedCppModuleId,
|
||||
Storage::Version{},
|
||||
Storage::Synchronization::IsAutoVersion::No,
|
||||
cppModuleName,
|
||||
moduleName,
|
||||
ModuleKind::CppLibrary,
|
||||
exportedModuleName);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +302,7 @@ void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
|
||||
|
||||
NanotraceHR::Tracer tracer{"update qmltypes file"_t, category()};
|
||||
|
||||
ModuleId moduleId = m_projectStorage.moduleId("QML-cppnative");
|
||||
ModuleId moduleId = m_projectStorage.moduleId("QML", Storage::ModuleKind::CppLibrary);
|
||||
|
||||
for (const QString &qmlTypesPath : qmlTypesPaths) {
|
||||
SourceId sourceId = m_pathCache.sourceId(SourcePath{qmlTypesPath});
|
||||
@@ -360,11 +365,11 @@ void ProjectStorageUpdater::updateDirectoryChanged(std::string_view directoryPat
|
||||
package.updatedSourceIds.push_back(qmldirSourceId);
|
||||
}
|
||||
|
||||
using Storage::ModuleKind;
|
||||
Utils::PathString moduleName{parser.typeNamespace()};
|
||||
ModuleId moduleId = m_projectStorage.moduleId(moduleName);
|
||||
Utils::PathString cppModuleName = moduleName + "-cppnative";
|
||||
ModuleId cppModuleId = m_projectStorage.moduleId(cppModuleName);
|
||||
ModuleId pathModuleId = m_projectStorage.moduleId(directoryPath);
|
||||
ModuleId moduleId = m_projectStorage.moduleId(moduleName, ModuleKind::QmlLibrary);
|
||||
ModuleId cppModuleId = m_projectStorage.moduleId(moduleName, ModuleKind::CppLibrary);
|
||||
ModuleId pathModuleId = m_projectStorage.moduleId(directoryPath, ModuleKind::PathLibrary);
|
||||
|
||||
auto imports = filterMultipleEntries(parser.imports());
|
||||
|
||||
@@ -372,7 +377,6 @@ void ProjectStorageUpdater::updateDirectoryChanged(std::string_view directoryPat
|
||||
moduleId,
|
||||
cppModuleId,
|
||||
moduleName,
|
||||
cppModuleName,
|
||||
imports,
|
||||
m_projectStorage);
|
||||
tracer.tick("append updated module id"_t, keyValue("module id", moduleId));
|
||||
@@ -696,7 +700,8 @@ void ProjectStorageUpdater::updatePropertyEditorFilePath(
|
||||
moduleName.replace('/', '.');
|
||||
if (oldModuleName != moduleName) {
|
||||
oldModuleName = moduleName;
|
||||
moduleId = m_projectStorage.moduleId(Utils::SmallString{moduleName});
|
||||
moduleId = m_projectStorage.moduleId(Utils::SmallString{moduleName},
|
||||
Storage::ModuleKind::QmlLibrary);
|
||||
}
|
||||
Storage::TypeNameString typeName{match.capturedView(2)};
|
||||
SourceId pathId = m_pathCache.sourceId(SourcePath{path});
|
||||
|
||||
@@ -66,23 +66,32 @@ Storage::Import createImport(const QmlDom::Import &qmlImport,
|
||||
Utils::SmallStringView directoryPath,
|
||||
QmlDocumentParser::ProjectStorage &storage)
|
||||
{
|
||||
using Storage::ModuleKind;
|
||||
using QmlUriKind = QQmlJS::Dom::QmlUri::Kind;
|
||||
|
||||
auto &&uri = qmlImport.uri;
|
||||
|
||||
if (uri.kind() == QmlUriKind::RelativePath) {
|
||||
auto path = createNormalizedPath(directoryPath, uri.localPath());
|
||||
auto moduleId = storage.moduleId(createNormalizedPath(directoryPath, uri.localPath()));
|
||||
return Storage::Import(moduleId, Storage::Version{}, sourceId);
|
||||
}
|
||||
|
||||
if (uri.kind() == QmlUriKind::ModuleUri) {
|
||||
auto moduleId = storage.moduleId(Utils::PathString{uri.moduleUri()});
|
||||
switch (uri.kind()) {
|
||||
case QmlUriKind::AbsolutePath:
|
||||
case QmlUriKind::DirectoryUrl: {
|
||||
auto moduleId = storage.moduleId(Utils::PathString{uri.toString()}, ModuleKind::PathLibrary);
|
||||
return Storage::Import(moduleId, convertVersion(qmlImport.version), sourceId);
|
||||
}
|
||||
case QmlUriKind::RelativePath: {
|
||||
auto path = createNormalizedPath(directoryPath, uri.localPath());
|
||||
auto moduleId = storage.moduleId(createNormalizedPath(directoryPath, uri.localPath()),
|
||||
ModuleKind::PathLibrary);
|
||||
return Storage::Import(moduleId, Storage::Version{}, sourceId);
|
||||
}
|
||||
case QmlUriKind::ModuleUri: {
|
||||
auto moduleId = storage.moduleId(Utils::PathString{uri.moduleUri()}, ModuleKind::QmlLibrary);
|
||||
return Storage::Import(moduleId, convertVersion(qmlImport.version), sourceId);
|
||||
}
|
||||
case QmlUriKind::Invalid:
|
||||
return Storage::Import{};
|
||||
}
|
||||
|
||||
auto moduleId = storage.moduleId(Utils::PathString{uri.toString()});
|
||||
return Storage::Import(moduleId, convertVersion(qmlImport.version), sourceId);
|
||||
return Storage::Import{};
|
||||
}
|
||||
|
||||
QualifiedImports createQualifiedImports(const QList<QmlDom::Import> &qmlImports,
|
||||
@@ -122,11 +131,13 @@ void addImports(Storage::Imports &imports,
|
||||
}
|
||||
}
|
||||
|
||||
auto localDirectoryModuleId = storage.moduleId(directoryPath);
|
||||
using Storage::ModuleKind;
|
||||
|
||||
auto localDirectoryModuleId = storage.moduleId(directoryPath, ModuleKind::PathLibrary);
|
||||
imports.emplace_back(localDirectoryModuleId, Storage::Version{}, sourceId);
|
||||
++importCount;
|
||||
|
||||
auto qmlModuleId = storage.moduleId("QML");
|
||||
auto qmlModuleId = storage.moduleId("QML", ModuleKind::QmlLibrary);
|
||||
imports.emplace_back(qmlModuleId, Storage::Version{}, sourceId);
|
||||
++importCount;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace QmlDesigner {
|
||||
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
|
||||
using NanotraceHR::keyValue;
|
||||
using Tracer = ProjectStorageTracing::Category::TracerType;
|
||||
|
||||
using Storage::ModuleKind;
|
||||
namespace QmlDom = QQmlJS::Dom;
|
||||
|
||||
namespace {
|
||||
@@ -71,8 +71,7 @@ const Storage::Import &appendImports(Storage::Imports &imports,
|
||||
});
|
||||
|
||||
Utils::PathString moduleName{QStringView(dependency.begin(), spaceFound)};
|
||||
moduleName.append("-cppnative");
|
||||
ModuleId cppModuleId = storage.moduleId(moduleName);
|
||||
ModuleId cppModuleId = storage.moduleId(moduleName, ModuleKind::CppLibrary);
|
||||
|
||||
return imports.emplace_back(cppModuleId, Storage::Version{}, sourceId);
|
||||
}
|
||||
@@ -98,7 +97,8 @@ void addImports(Storage::Imports &imports,
|
||||
const auto &import = imports.emplace_back(cppModuleId, Storage::Version{}, sourceId);
|
||||
tracer.tick("append import"_t, keyValue("import", import));
|
||||
|
||||
if (ModuleId qmlCppModuleId = storage.moduleId("QML-cppnative"); cppModuleId != qmlCppModuleId) {
|
||||
if (ModuleId qmlCppModuleId = storage.moduleId("QML", ModuleKind::CppLibrary);
|
||||
cppModuleId != qmlCppModuleId) {
|
||||
const auto &import = imports.emplace_back(qmlCppModuleId, Storage::Version{}, sourceId);
|
||||
tracer.tick("append import"_t, keyValue("import", import));
|
||||
}
|
||||
@@ -145,7 +145,8 @@ Storage::Synchronization::ExportedTypes createExports(const QList<QQmlJSScope::E
|
||||
|
||||
for (const QQmlJSScope::Export &qmlExport : qmlExports) {
|
||||
TypeNameString exportedTypeName{qmlExport.type()};
|
||||
exportedTypes.emplace_back(storage.moduleId(Utils::SmallString{qmlExport.package()}),
|
||||
exportedTypes.emplace_back(storage.moduleId(Utils::SmallString{qmlExport.package()},
|
||||
ModuleKind::QmlLibrary),
|
||||
std::move(exportedTypeName),
|
||||
createVersion(qmlExport.version()));
|
||||
}
|
||||
@@ -469,16 +470,16 @@ void addType(Storage::Synchronization::Types &types,
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
constexpr auto skipLists = std::make_tuple(
|
||||
std::pair{"QtQuick.Templates-cppnative"sv, std::array{"QQuickItem"_L1}});
|
||||
std::pair{std::pair{"QtQuick.Templates"_sv, ModuleKind::CppLibrary}, std::array{"QQuickItem"_L1}});
|
||||
|
||||
Utils::span<const QLatin1StringView> getSkipList(std::string_view moduleName)
|
||||
Utils::span<const QLatin1StringView> getSkipList(const Storage::Module &module)
|
||||
{
|
||||
static constexpr Utils::span<const QLatin1StringView> emptySkipList;
|
||||
auto currentSkipList = emptySkipList;
|
||||
|
||||
std::apply(
|
||||
[&](const auto &entry) {
|
||||
if (entry.first == moduleName)
|
||||
if (entry.first.first == module.name && entry.first.second == module.kind)
|
||||
currentSkipList = entry.second;
|
||||
},
|
||||
skipLists);
|
||||
@@ -502,7 +503,7 @@ void addTypes(Storage::Synchronization::Types &types,
|
||||
NanotraceHR::Tracer tracer{"add types"_t, category()};
|
||||
types.reserve(Utils::usize(objects) + types.size());
|
||||
|
||||
const auto skipList = getSkipList(storage.moduleName(projectData.moduleId));
|
||||
const auto skipList = getSkipList(storage.module(projectData.moduleId));
|
||||
|
||||
for (const auto &object : objects) {
|
||||
if (skipType(object, skipList))
|
||||
|
||||
@@ -313,7 +313,7 @@ private:
|
||||
return entries.end();
|
||||
}
|
||||
|
||||
auto value = *found;
|
||||
const auto &value = *found;
|
||||
|
||||
if (value == view) {
|
||||
return found;
|
||||
|
||||
@@ -258,7 +258,8 @@ void TypeAnnotationReader::readTypeProperty(QStringView name, const QVariant &va
|
||||
auto [moduleName, typeName] = decomposeTypePath(fullTypeName);
|
||||
|
||||
m_typeAnnotations.back().typeName = typeName;
|
||||
m_typeAnnotations.back().moduleId = m_projectStorage.moduleId(moduleName);
|
||||
m_typeAnnotations.back().moduleId = m_projectStorage.moduleId(moduleName,
|
||||
ModuleKind::QmlLibrary);
|
||||
|
||||
} else if (name == "icon"_L1) {
|
||||
m_typeAnnotations.back().iconPath = absoluteFilePathForDocument(value.toString());
|
||||
|
||||
Reference in New Issue
Block a user