QmlDesigner: Add tracing for project storage updater

Change-Id: I4579a256e4402a045d906a36940582b8e0ff196b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marco Bubke
2024-03-20 12:10:41 +01:00
committed by Tim Jenssen
parent 12785d4eee
commit c76c90b601
10 changed files with 443 additions and 104 deletions

View File

@@ -3491,7 +3491,7 @@ private:
NanotraceHR::Tracer tracer{"fetch imported type name id"_t, NanotraceHR::Tracer tracer{"fetch imported type name id"_t,
projectStorageCategory(), projectStorageCategory(),
keyValue("imported type name", typeName), keyValue("imported type name", typeName),
keyValue("kind", to_underlying(kind))}; keyValue("kind", kind)};
auto importedTypeNameId = selectImportedTypeNameIdStatement auto importedTypeNameId = selectImportedTypeNameIdStatement
.template value<ImportedTypeNameId>(kind, id, typeName); .template value<ImportedTypeNameId>(kind, id, typeName);
@@ -3517,7 +3517,7 @@ private:
auto typeId = fetchTypeId(typeNameId, kind); auto typeId = fetchTypeId(typeNameId, kind);
tracer.end(keyValue("type id", typeId), keyValue("type name kind", to_underlying(kind))); tracer.end(keyValue("type id", typeId), keyValue("type name kind", kind));
return typeId; return typeId;
} }
@@ -3533,7 +3533,7 @@ private:
NanotraceHR::Tracer tracer{"fetch type id"_t, NanotraceHR::Tracer tracer{"fetch type id"_t,
projectStorageCategory(), projectStorageCategory(),
keyValue("type name id", typeNameId), keyValue("type name id", typeNameId),
keyValue("type name kind", to_underlying(kind))}; keyValue("type name kind", kind)};
TypeId typeId; TypeId typeId;
if (kind == Storage::Synchronization::TypeNameKind::Exported) { if (kind == Storage::Synchronization::TypeNameKind::Exported) {
@@ -3566,7 +3566,7 @@ private:
using NanotraceHR::keyValue; using NanotraceHR::keyValue;
auto dict = dictonary(keyValue("property type id", result.propertyTypeId), auto dict = dictonary(keyValue("property type id", result.propertyTypeId),
keyValue("property declaration id", result.propertyDeclarationId), keyValue("property declaration id", result.propertyDeclarationId),
keyValue("property traits", to_underlying(result.propertyTraits))); keyValue("property traits", result.propertyTraits));
convertToString(string, dict); convertToString(string, dict);
} }

View File

@@ -12,6 +12,28 @@ namespace QmlDesigner {
enum class SourceType : int { Qml, QmlUi, QmlTypes, QmlDir, Directory }; enum class SourceType : int { Qml, QmlUi, QmlTypes, QmlDir, Directory };
template<typename String>
void convertToString(String &string, SourceType sourceType)
{
switch (sourceType) {
case SourceType::Qml:
convertToString(string, "Qml");
break;
case SourceType::QmlUi:
convertToString(string, "QmlUi");
break;
case SourceType::QmlTypes:
convertToString(string, "QmlTypes");
break;
case SourceType::QmlDir:
convertToString(string, "QmlDir");
break;
case SourceType::Directory:
convertToString(string, "Directory");
break;
}
}
class ProjectChunkId class ProjectChunkId
{ {
public: public:
@@ -46,6 +68,17 @@ public:
friend bool operator<(ProjectChunkId first, ProjectPartId second) { return first.id < second; } friend bool operator<(ProjectChunkId first, ProjectPartId second) { return first.id < second; }
friend bool operator<(ProjectPartId first, ProjectChunkId second) { return first < second.id; } friend bool operator<(ProjectPartId first, ProjectChunkId second) { return first < second.id; }
template<typename String>
friend void convertToString(String &string, const ProjectChunkId &id)
{
using NanotraceHR::dictonary;
using NanotraceHR::keyValue;
auto dict = dictonary(keyValue("project part id", id.id),
keyValue("source type", id.sourceType));
convertToString(string, dict);
}
}; };
using ProjectChunkIds = std::vector<ProjectChunkId>; using ProjectChunkIds = std::vector<ProjectChunkId>;
@@ -67,6 +100,16 @@ public:
return first.id == second.id && first.sourceIds == second.sourceIds; return first.id == second.id && first.sourceIds == second.sourceIds;
} }
template<typename String>
friend void convertToString(String &string, const IdPaths &idPaths)
{
using NanotraceHR::dictonary;
using NanotraceHR::keyValue;
auto dict = dictonary(keyValue("id", idPaths.id), keyValue("source ids", idPaths.sourceIds));
convertToString(string, dict);
}
public: public:
ProjectChunkId id; ProjectChunkId id;
SourceIds sourceIds; SourceIds sourceIds;

View File

@@ -899,7 +899,7 @@ public:
keyValue("traits", propertyDeclaration.traits), keyValue("traits", propertyDeclaration.traits),
keyValue("type id", propertyDeclaration.typeId), keyValue("type id", propertyDeclaration.typeId),
keyValue("property type id", propertyDeclaration.propertyTypeId), keyValue("property type id", propertyDeclaration.propertyTypeId),
keyValue("kind", to_underlying(propertyDeclaration.kind))); keyValue("kind", propertyDeclaration.kind));
convertToString(string, dict); convertToString(string, dict);
} }
@@ -1100,7 +1100,7 @@ public:
keyValue("enumeration declarations", type.enumerationDeclarations), keyValue("enumeration declarations", type.enumerationDeclarations),
keyValue("traits", type.traits), keyValue("traits", type.traits),
keyValue("source id", type.sourceId), keyValue("source id", type.sourceId),
keyValue("change level", to_underlying(type.changeLevel)), keyValue("change level", type.changeLevel),
keyValue("default property name", type.defaultPropertyName)); keyValue("default property name", type.defaultPropertyName));
convertToString(string, dict); convertToString(string, dict);
@@ -1185,7 +1185,7 @@ public:
auto dict = dictonary(keyValue("project source id", projectData.projectSourceId), auto dict = dictonary(keyValue("project source id", projectData.projectSourceId),
keyValue("source id", projectData.sourceId), keyValue("source id", projectData.sourceId),
keyValue("module id", projectData.moduleId), keyValue("module id", projectData.moduleId),
keyValue("file type", to_underlying(projectData.fileType))); keyValue("file type", projectData.fileType));
convertToString(string, dict); convertToString(string, dict);
} }

View File

@@ -12,6 +12,8 @@
#include "sourcepath.h" #include "sourcepath.h"
#include "sourcepathcache.h" #include "sourcepathcache.h"
#include <tracing/qmldesignertracing.h>
#include <sqlitedatabase.h> #include <sqlitedatabase.h>
#include <QDirIterator> #include <QDirIterator>
@@ -21,6 +23,26 @@
#include <functional> #include <functional>
namespace QmlDesigner { namespace QmlDesigner {
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
using NanotraceHR::keyValue;
using Tracer = ProjectStorageTracing::Category::TracerType;
template<typename String>
void convertToString(String &string, const ProjectStorageUpdater::FileState &state)
{
switch (state) {
case ProjectStorageUpdater::FileState::Changed:
convertToString(string, "Changed");
break;
case ProjectStorageUpdater::FileState::NotChanged:
convertToString(string, "NotChanged");
break;
case ProjectStorageUpdater::FileState::NotExists:
convertToString(string, "NotExists");
break;
}
}
namespace { namespace {
QStringList filterMultipleEntries(QStringList qmlTypes) QStringList filterMultipleEntries(QStringList qmlTypes)
@@ -110,10 +132,15 @@ SourceIds filterNotUpdatedSourceIds(SourceIds updatedSourceIds, SourceIds notUpd
return filteredUpdatedSourceIds; return filteredUpdatedSourceIds;
} }
void addSourceIds(SourceIds &sourceIds, const Storage::Synchronization::ProjectDatas &projectDatas) void addSourceIds(SourceIds &sourceIds,
const Storage::Synchronization::ProjectDatas &projectDatas,
TracerLiteral message,
Tracer &tracer)
{ {
for (const auto &projectData : projectDatas) for (const auto &projectData : projectDatas) {
tracer.tick(message, keyValue("source id", projectData.sourceId));
sourceIds.push_back(projectData.sourceId); sourceIds.push_back(projectData.sourceId);
}
} }
Storage::Version convertVersion(LanguageUtils::ComponentVersion version) Storage::Version convertVersion(LanguageUtils::ComponentVersion version)
@@ -131,34 +158,71 @@ Storage::Synchronization::IsAutoVersion convertToIsAutoVersion(QmlDirParser::Imp
void addDependencies(Storage::Imports &dependencies, void addDependencies(Storage::Imports &dependencies,
SourceId sourceId, SourceId sourceId,
const QList<QmlDirParser::Import> &qmldirDependencies, const QList<QmlDirParser::Import> &qmldirDependencies,
ProjectStorageInterface &projectStorage) ProjectStorageInterface &projectStorage,
TracerLiteral message,
Tracer &tracer)
{ {
for (const QmlDirParser::Import &qmldirDependency : qmldirDependencies) { for (const QmlDirParser::Import &qmldirDependency : qmldirDependencies) {
ModuleId moduleId = projectStorage.moduleId(Utils::PathString{qmldirDependency.module} ModuleId moduleId = projectStorage.moduleId(Utils::PathString{qmldirDependency.module}
+ "-cppnative"); + "-cppnative");
dependencies.emplace_back(moduleId, Storage::Version{}, sourceId); auto &import = dependencies.emplace_back(moduleId, Storage::Version{}, sourceId);
tracer.tick(message, keyValue("import", import));
} }
} }
void addModuleExportedImport(Storage::Synchronization::ModuleExportedImports &imports,
ModuleId moduleId,
ModuleId exportedModuleId,
Storage::Version version,
Storage::Synchronization::IsAutoVersion isAutoVersion,
std::string_view moduleName,
std::string_view exportedModuleName)
{
NanotraceHR::Tracer tracer{"add module exported imports"_t,
category(),
keyValue("module id", moduleId),
keyValue("exported module id", exportedModuleId),
keyValue("version", version),
keyValue("is auto version", isAutoVersion),
keyValue("module name", moduleName),
keyValue("exported module name", exportedModuleName)};
imports.emplace_back(moduleId, exportedModuleId, version, isAutoVersion);
}
void addModuleExportedImports(Storage::Synchronization::ModuleExportedImports &imports, void addModuleExportedImports(Storage::Synchronization::ModuleExportedImports &imports,
ModuleId moduleId, ModuleId moduleId,
ModuleId cppModuleId, ModuleId cppModuleId,
std::string_view moduleName,
std::string_view cppModuleName,
const QList<QmlDirParser::Import> &qmldirImports, const QList<QmlDirParser::Import> &qmldirImports,
ProjectStorageInterface &projectStorage) ProjectStorageInterface &projectStorage)
{ {
NanotraceHR::Tracer tracer{"add module exported imports"_t,
category(),
keyValue("cpp module id", cppModuleId),
keyValue("module id", moduleId)};
for (const QmlDirParser::Import &qmldirImport : qmldirImports) { for (const QmlDirParser::Import &qmldirImport : qmldirImports) {
ModuleId exportedModuleId = projectStorage.moduleId(Utils::PathString{qmldirImport.module}); Utils::PathString exportedModuleName{qmldirImport.module};
imports.emplace_back(moduleId, ModuleId exportedModuleId = projectStorage.moduleId(exportedModuleName);
addModuleExportedImport(imports,
moduleId,
exportedModuleId, exportedModuleId,
convertVersion(qmldirImport.version), convertVersion(qmldirImport.version),
convertToIsAutoVersion(qmldirImport.flags)); convertToIsAutoVersion(qmldirImport.flags),
moduleName,
exportedModuleName);
ModuleId exportedCppModuleId = projectStorage.moduleId( exportedModuleName += "-cppnative";
Utils::PathString{qmldirImport.module} + "-cppnative"); ModuleId exportedCppModuleId = projectStorage.moduleId(exportedModuleName);
imports.emplace_back(cppModuleId, addModuleExportedImport(imports,
cppModuleId,
exportedCppModuleId, exportedCppModuleId,
Storage::Version{}, Storage::Version{},
Storage::Synchronization::IsAutoVersion::No); Storage::Synchronization::IsAutoVersion::No,
cppModuleName,
exportedModuleName);
} }
} }
@@ -184,6 +248,11 @@ void ProjectStorageUpdater::update(QStringList directories,
QStringList qmlTypesPaths, QStringList qmlTypesPaths,
const QString &propertyEditorResourcesPath) const QString &propertyEditorResourcesPath)
{ {
NanotraceHR::Tracer tracer{"update"_t,
category(),
keyValue("directories", directories),
keyValue("qml types paths", qmlTypesPaths)};
Storage::Synchronization::SynchronizationPackage package; Storage::Synchronization::SynchronizationPackage package;
WatchedSourceIdsIds watchedSourceIds{Utils::span{directories}.size()}; WatchedSourceIdsIds watchedSourceIds{Utils::span{directories}.size()};
NotUpdatedSourceIds notUpdatedSourceIds{Utils::span{directories}.size()}; NotUpdatedSourceIds notUpdatedSourceIds{Utils::span{directories}.size()};
@@ -215,11 +284,16 @@ void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
if (qmlTypesPaths.empty()) if (qmlTypesPaths.empty())
return; return;
NanotraceHR::Tracer tracer{"update qmltypes file"_t, category()};
ModuleId moduleId = m_projectStorage.moduleId("QML-cppnative"); ModuleId moduleId = m_projectStorage.moduleId("QML-cppnative");
for (const QString &qmlTypesPath : qmlTypesPaths) { for (const QString &qmlTypesPath : qmlTypesPaths) {
SourceId sourceId = m_pathCache.sourceId(SourcePath{qmlTypesPath}); SourceId sourceId = m_pathCache.sourceId(SourcePath{qmlTypesPath});
watchedSourceIdsIds.qmltypesSourceIds.push_back(sourceId); watchedSourceIdsIds.qmltypesSourceIds.push_back(sourceId);
tracer.tick("append watched qml types source id"_t,
keyValue("source id", sourceId),
keyValue("qml types path", qmlTypesPath));
Storage::Synchronization::ProjectData projectData{sourceId, Storage::Synchronization::ProjectData projectData{sourceId,
sourceId, sourceId,
@@ -232,7 +306,9 @@ void ProjectStorageUpdater::updateQmlTypes(const QStringList &qmlTypesPaths,
notUpdatedSourceIds); notUpdatedSourceIds);
if (state == FileState::Changed) { if (state == FileState::Changed) {
tracer.tick("append project data"_t, keyValue("project data", projectData));
package.projectDatas.push_back(std::move(projectData)); package.projectDatas.push_back(std::move(projectData));
tracer.tick("append updated project source ids"_t, keyValue("source id", sourceId));
package.updatedProjectSourceIds.push_back(sourceId); package.updatedProjectSourceIds.push_back(sourceId);
} }
} }
@@ -250,47 +326,33 @@ ProjectStorageUpdater::FileState combineState(FileStates... fileStates)
return ProjectStorageUpdater::FileState::NotExists; return ProjectStorageUpdater::FileState::NotExists;
} }
} // namespace } // namespace
void ProjectStorageUpdater::updateDirectories(const QStringList &directories, void ProjectStorageUpdater::updateDirectoryChanged(std::string_view directoryPath,
FileState qmldirState,
SourcePath qmldirSourcePath,
SourceId qmldirSourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds, NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds) WatchedSourceIdsIds &watchedSourceIdsIds,
Tracer &tracer)
{ {
for (const QString &directory : directories)
updateDirectory({directory}, package, notUpdatedSourceIds, watchedSourceIdsIds);
}
void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds)
{
SourcePath qmldirSourcePath{directoryPath + "/qmldir"};
auto [directoryId, qmlDirSourceId] = m_pathCache.sourceContextAndSourceId(qmldirSourcePath);
SourcePath directorySourcePath{directoryPath + "/."};
auto directorySourceId = m_pathCache.sourceId(directorySourcePath);
auto directoryState = fileState(directorySourceId, package, notUpdatedSourceIds);
if (directoryState != FileState::NotExists)
watchedSourceIdsIds.directorySourceIds.push_back(directorySourceId);
auto qmldirState = fileState(qmlDirSourceId, package, notUpdatedSourceIds);
if (qmldirState != FileState::NotExists)
watchedSourceIdsIds.qmldirSourceIds.push_back(qmlDirSourceId);
switch (combineState(directoryState, qmldirState)) {
case FileState::Changed: {
QmlDirParser parser; QmlDirParser parser;
if (qmldirState != FileState::NotExists) if (qmldirState != FileState::NotExists)
parser.parse(m_fileSystem.contentAsQString(QString{qmldirSourcePath})); parser.parse(m_fileSystem.contentAsQString(QString{qmldirSourcePath}));
if (qmldirState != FileState::NotChanged) if (qmldirState != FileState::NotChanged) {
package.updatedSourceIds.push_back(qmlDirSourceId); tracer.tick("append updated source id"_t, keyValue("module id", qmldirSourceId));
package.updatedSourceIds.push_back(qmldirSourceId);
}
Utils::PathString moduleName{parser.typeNamespace()}; Utils::PathString moduleName{parser.typeNamespace()};
ModuleId moduleId = m_projectStorage.moduleId(moduleName); ModuleId moduleId = m_projectStorage.moduleId(moduleName);
ModuleId cppModuleId = m_projectStorage.moduleId(moduleName + "-cppnative"); Utils::PathString cppModuleName = moduleName + "-cppnative";
ModuleId cppModuleId = m_projectStorage.moduleId(cppModuleName);
ModuleId pathModuleId = m_projectStorage.moduleId(directoryPath); ModuleId pathModuleId = m_projectStorage.moduleId(directoryPath);
auto imports = filterMultipleEntries(parser.imports()); auto imports = filterMultipleEntries(parser.imports());
@@ -298,13 +360,19 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
addModuleExportedImports(package.moduleExportedImports, addModuleExportedImports(package.moduleExportedImports,
moduleId, moduleId,
cppModuleId, cppModuleId,
moduleName,
cppModuleName,
imports, imports,
m_projectStorage); m_projectStorage);
tracer.tick("append updated module id"_t, keyValue("module id", moduleId));
package.updatedModuleIds.push_back(moduleId); package.updatedModuleIds.push_back(moduleId);
const auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId); const auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
addSourceIds(package.updatedSourceIds, qmlProjectDatas); addSourceIds(package.updatedSourceIds, qmlProjectDatas, "append updated source id"_t, tracer);
addSourceIds(package.updatedFileStatusSourceIds, qmlProjectDatas); addSourceIds(package.updatedFileStatusSourceIds,
qmlProjectDatas,
"append updated file status source id"_t,
tracer);
auto qmlTypes = filterMultipleEntries(parser.typeInfos()); auto qmlTypes = filterMultipleEntries(parser.typeInfos());
@@ -327,10 +395,59 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
notUpdatedSourceIds, notUpdatedSourceIds,
watchedSourceIdsIds, watchedSourceIdsIds,
qmldirState); qmldirState);
tracer.tick("append updated project source id"_t, keyValue("module id", moduleId));
package.updatedProjectSourceIds.push_back(directorySourceId); package.updatedProjectSourceIds.push_back(directorySourceId);
}
void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds)
{
NanotraceHR::Tracer tracer{"update directories"_t, category()};
for (const QString &directory : directories)
updateDirectory({directory}, package, notUpdatedSourceIds, watchedSourceIdsIds);
}
void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds)
{
NanotraceHR::Tracer tracer{"update directory"_t, category(), keyValue("directory", directoryPath)};
SourcePath qmldirSourcePath{directoryPath + "/qmldir"};
auto [directoryId, qmldirSourceId] = m_pathCache.sourceContextAndSourceId(qmldirSourcePath);
SourcePath directorySourcePath{directoryPath + "/."};
auto directorySourceId = m_pathCache.sourceId(directorySourcePath);
auto directoryState = fileState(directorySourceId, package, notUpdatedSourceIds);
if (directoryState != FileState::NotExists)
watchedSourceIdsIds.directorySourceIds.push_back(directorySourceId);
auto qmldirState = fileState(qmldirSourceId, package, notUpdatedSourceIds);
if (qmldirState != FileState::NotExists)
watchedSourceIdsIds.qmldirSourceIds.push_back(qmldirSourceId);
switch (combineState(directoryState, qmldirState)) {
case FileState::Changed: {
tracer.tick("update directory changed"_t);
updateDirectoryChanged(directoryPath,
qmldirState,
qmldirSourcePath,
qmldirSourceId,
directorySourceId,
directoryId,
package,
notUpdatedSourceIds,
watchedSourceIdsIds,
tracer);
break; break;
} }
case FileState::NotChanged: { case FileState::NotChanged: {
tracer.tick("update directory not changed"_t);
parseProjectDatas(m_projectStorage.fetchProjectDatas(directorySourceId), parseProjectDatas(m_projectStorage.fetchProjectDatas(directorySourceId),
package, package,
notUpdatedSourceIds, notUpdatedSourceIds,
@@ -338,19 +455,32 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
break; break;
} }
case FileState::NotExists: { case FileState::NotExists: {
tracer.tick("update directory don't exits"_t);
package.updatedFileStatusSourceIds.push_back(directorySourceId); package.updatedFileStatusSourceIds.push_back(directorySourceId);
package.updatedFileStatusSourceIds.push_back(qmlDirSourceId); package.updatedFileStatusSourceIds.push_back(qmldirSourceId);
package.updatedProjectSourceIds.push_back(directorySourceId); package.updatedProjectSourceIds.push_back(directorySourceId);
package.updatedSourceIds.push_back(qmlDirSourceId); package.updatedSourceIds.push_back(qmldirSourceId);
auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId); auto qmlProjectDatas = m_projectStorage.fetchProjectDatas(directorySourceId);
for (const Storage::Synchronization::ProjectData &projectData : qmlProjectDatas) { for (const Storage::Synchronization::ProjectData &projectData : qmlProjectDatas) {
tracer.tick("append updated source id"_t, keyValue("source id", projectData.sourceId));
package.updatedSourceIds.push_back(projectData.sourceId); package.updatedSourceIds.push_back(projectData.sourceId);
tracer.tick("append updated file status source id"_t,
keyValue("source id", projectData.sourceId));
package.updatedFileStatusSourceIds.push_back(projectData.sourceId); package.updatedFileStatusSourceIds.push_back(projectData.sourceId);
} }
break; break;
} }
} }
tracer.end(keyValue("qmldir source path", qmldirSourcePath),
keyValue("directory source path", directorySourcePath),
keyValue("directory id", directoryId),
keyValue("qmldir source id", qmldirSourceId),
keyValue("directory source source id", directorySourceId),
keyValue("qmldir state", qmldirState),
keyValue("directory state", directoryState));
} }
void ProjectStorageUpdater::updatePropertyEditorPaths( void ProjectStorageUpdater::updatePropertyEditorPaths(
@@ -358,6 +488,10 @@ void ProjectStorageUpdater::updatePropertyEditorPaths(
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) NotUpdatedSourceIds &notUpdatedSourceIds)
{ {
NanotraceHR::Tracer tracer{"update property editor paths"_t,
category(),
keyValue("property editor resources path", propertyEditorResourcesPath)};
if (propertyEditorResourcesPath.isEmpty()) if (propertyEditorResourcesPath.isEmpty())
return; return;
@@ -390,6 +524,13 @@ void ProjectStorageUpdater::updatePropertyEditorPath(
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceId directorySourceId) SourceId directorySourceId)
{ {
NanotraceHR::Tracer tracer{"update property editor path"_t,
category(),
keyValue("directory path", directoryPath),
keyValue("directory source id", directorySourceId)};
tracer.tick("append updated property editor qml path source id"_t,
keyValue("source id", directorySourceId));
package.updatedPropertyEditorQmlPathSourceIds.push_back(directorySourceId); package.updatedPropertyEditorQmlPathSourceIds.push_back(directorySourceId);
auto dir = QDir{directoryPath}; auto dir = QDir{directoryPath};
const auto fileInfos = dir.entryInfoList({"*Pane.qml", "*Specifics.qml"}, QDir::Files); const auto fileInfos = dir.entryInfoList({"*Pane.qml", "*Specifics.qml"}, QDir::Files);
@@ -402,6 +543,11 @@ void ProjectStorageUpdater::updatePropertyEditorFilePath(
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
SourceId directorySourceId) SourceId directorySourceId)
{ {
NanotraceHR::Tracer tracer{"update property editor file path"_t,
category(),
keyValue("directory path", path),
keyValue("directory source id", directorySourceId)};
QRegularExpression regex{R"xo(.+\/(\w+)\/(\w+)(Specifics|Pane).qml)xo"}; QRegularExpression regex{R"xo(.+\/(\w+)\/(\w+)(Specifics|Pane).qml)xo"};
auto match = regex.match(path); auto match = regex.match(path);
QString oldModuleName; QString oldModuleName;
@@ -414,7 +560,12 @@ void ProjectStorageUpdater::updatePropertyEditorFilePath(
} }
Storage::TypeNameString typeName{match.capturedView(2)}; Storage::TypeNameString typeName{match.capturedView(2)};
SourceId pathId = m_pathCache.sourceId(SourcePath{path}); SourceId pathId = m_pathCache.sourceId(SourcePath{path});
package.propertyEditorQmlPaths.emplace_back(moduleId, typeName, pathId, directorySourceId); const auto &paths = package.propertyEditorQmlPaths.emplace_back(moduleId,
typeName,
pathId,
directorySourceId);
tracer.tick("append property editor qml paths"_t,
keyValue("property editor qml paths", paths));
} }
} }
@@ -451,6 +602,10 @@ bool contains(const Container &container, Id id)
void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &changedIdPaths) void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &changedIdPaths)
{ {
NanotraceHR::Tracer tracer{"paths with ids changed"_t,
category(),
keyValue("id paths", changedIdPaths)};
m_changedIdPaths.insert(m_changedIdPaths.end(), changedIdPaths.begin(), changedIdPaths.end()); m_changedIdPaths.insert(m_changedIdPaths.end(), changedIdPaths.begin(), changedIdPaths.end());
Storage::Synchronization::SynchronizationPackage package; Storage::Synchronization::SynchronizationPackage package;
@@ -543,21 +698,35 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
NotUpdatedSourceIds &notUpdatedSourceIds, NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIds) WatchedSourceIdsIds &watchedSourceIds)
{ {
NanotraceHR::Tracer tracer{"parse type infos"_t,
category(),
keyValue("directory source id", directorySourceId),
keyValue("directory path", directoryPath),
keyValue("module id", moduleId)};
for (const QString &typeInfo : typeInfos) { for (const QString &typeInfo : typeInfos) {
NanotraceHR::Tracer tracer{"parse type info"_t, category(), keyValue("type info", typeInfo)};
Utils::PathString qmltypesPath = Utils::PathString::join( Utils::PathString qmltypesPath = Utils::PathString::join(
{directoryPath, "/", Utils::SmallString{typeInfo}}); {directoryPath, "/", Utils::SmallString{typeInfo}});
SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmltypesPath}); SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmltypesPath});
tracer.tick("append qmltypes source id"_t, keyValue("source id", sourceId));
watchedSourceIds.qmltypesSourceIds.push_back(sourceId); watchedSourceIds.qmltypesSourceIds.push_back(sourceId);
addDependencies(package.moduleDependencies, addDependencies(package.moduleDependencies,
sourceId, sourceId,
joinImports(qmldirDependencies, qmldirImports), joinImports(qmldirDependencies, qmldirImports),
m_projectStorage); m_projectStorage,
"append module dependency"_t,
tracer);
tracer.tick("append module dependenct source source id"_t, keyValue("source id", sourceId));
package.updatedModuleDependencySourceIds.push_back(sourceId); package.updatedModuleDependencySourceIds.push_back(sourceId);
auto projectData = package.projectDatas.emplace_back( auto projectData = package.projectDatas.emplace_back(
directorySourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes); directorySourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes);
tracer.tick("append project data"_t, keyValue("source id", sourceId));
parseTypeInfo(projectData, qmltypesPath, package, notUpdatedSourceIds); parseTypeInfo(projectData, qmltypesPath, package, notUpdatedSourceIds);
} }
@@ -568,6 +737,8 @@ void ProjectStorageUpdater::parseProjectDatas(const Storage::Synchronization::Pr
NotUpdatedSourceIds &notUpdatedSourceIds, NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIds) WatchedSourceIdsIds &watchedSourceIds)
{ {
NanotraceHR::Tracer tracer{"parse project datas"_t, category()};
for (const Storage::Synchronization::ProjectData &projectData : projectDatas) { for (const Storage::Synchronization::ProjectData &projectData : projectDatas) {
switch (projectData.fileType) { switch (projectData.fileType) {
case Storage::Synchronization::FileType::QmlTypes: { case Storage::Synchronization::FileType::QmlTypes: {
@@ -591,9 +762,14 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Projec
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) -> FileState NotUpdatedSourceIds &notUpdatedSourceIds) -> FileState
{ {
NanotraceHR::Tracer tracer{"parse type info"_t,
category(),
keyValue("qmltypes path", qmltypesPath)};
auto state = fileState(projectData.sourceId, package, notUpdatedSourceIds); auto state = fileState(projectData.sourceId, package, notUpdatedSourceIds);
switch (state) { switch (state) {
case FileState::Changed: { case FileState::Changed: {
tracer.tick("append updated source ids"_t, keyValue("source id", projectData.sourceId));
package.updatedSourceIds.push_back(projectData.sourceId); package.updatedSourceIds.push_back(projectData.sourceId);
const auto content = m_fileSystem.contentAsQString(QString{qmltypesPath}); const auto content = m_fileSystem.contentAsQString(QString{qmltypesPath});
@@ -601,6 +777,7 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Projec
break; break;
} }
case FileState::NotChanged: { case FileState::NotChanged: {
tracer.tick("append not updated source ids"_t, keyValue("source id", projectData.sourceId));
notUpdatedSourceIds.sourceIds.push_back(projectData.sourceId); notUpdatedSourceIds.sourceIds.push_back(projectData.sourceId);
break; break;
} }
@@ -608,6 +785,8 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Projec
throw CannotParseQmlTypesFile{}; throw CannotParseQmlTypesFile{};
} }
tracer.end(keyValue("state", state));
return state; return state;
} }
@@ -620,6 +799,14 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
WatchedSourceIdsIds &watchedSourceIds, WatchedSourceIdsIds &watchedSourceIds,
FileState qmldirState) FileState qmldirState)
{ {
NanotraceHR::Tracer tracer{"parse qml component"_t,
category(),
keyValue("relative file path", relativeFilePath),
keyValue("directory path", directoryPath),
keyValue("exported types", exportedTypes),
keyValue("directory source id", directorySourceId),
keyValue("qmldir state", qmldirState)};
if (std::find(relativeFilePath.begin(), relativeFilePath.end(), '+') != relativeFilePath.end()) if (std::find(relativeFilePath.begin(), relativeFilePath.end(), '+') != relativeFilePath.end())
return; return;
@@ -629,16 +816,18 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
Storage::Synchronization::Type type; Storage::Synchronization::Type type;
auto state = fileState(sourceId, package, notUpdatedSourceIds); auto state = fileState(sourceId, package, notUpdatedSourceIds);
tracer.tick("append watched qml source id"_t, keyValue("source id", sourceId));
watchedSourceIds.qmlSourceIds.push_back(sourceId); watchedSourceIds.qmlSourceIds.push_back(sourceId);
switch (state) { switch (state) {
case FileState::NotChanged: case FileState::NotChanged:
if (qmldirState == FileState::NotExists) { if (qmldirState == FileState::NotExists) {
tracer.tick("append not updated source id"_t, keyValue("source id", sourceId));
notUpdatedSourceIds.sourceIds.emplace_back(sourceId); notUpdatedSourceIds.sourceIds.emplace_back(sourceId);
package.projectDatas.emplace_back(directorySourceId,
sourceId, const auto &projectData = package.projectDatas.emplace_back(
ModuleId{}, directorySourceId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
Storage::Synchronization::FileType::QmlDocument); tracer.tick("append project data"_t, keyValue("project data", projectData));
return; return;
} }
@@ -652,11 +841,11 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
break; break;
} }
package.projectDatas.emplace_back(directorySourceId, const auto &projectData = package.projectDatas.emplace_back(
sourceId, directorySourceId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
ModuleId{}, tracer.tick("append project data"_t, keyValue("project data", projectData));
Storage::Synchronization::FileType::QmlDocument);
tracer.tick("append updated source id"_t, keyValue("source id", sourceId));
package.updatedSourceIds.push_back(sourceId); package.updatedSourceIds.push_back(sourceId);
type.typeName = SourcePath{qmlFilePath}.name(); type.typeName = SourcePath{qmlFilePath}.name();
@@ -664,6 +853,8 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
type.sourceId = sourceId; type.sourceId = sourceId;
type.exportedTypes = std::move(exportedTypes); type.exportedTypes = std::move(exportedTypes);
tracer.end(keyValue("type", type));
package.types.push_back(std::move(type)); package.types.push_back(std::move(type));
} }
@@ -671,10 +862,13 @@ void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) NotUpdatedSourceIds &notUpdatedSourceIds)
{ {
NanotraceHR::Tracer tracer{"parse qml component"_t, category(), keyValue("source id", sourceId)};
auto state = fileState(sourceId, package, notUpdatedSourceIds); auto state = fileState(sourceId, package, notUpdatedSourceIds);
if (state == FileState::NotChanged) if (state == FileState::NotChanged)
return; return;
tracer.tick("append updated source id"_t, keyValue("source id", sourceId));
package.updatedSourceIds.push_back(sourceId); package.updatedSourceIds.push_back(sourceId);
if (state == FileState::NotExists) if (state == FileState::NotExists)
@@ -690,6 +884,8 @@ void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId,
type.sourceId = sourceId; type.sourceId = sourceId;
type.changeLevel = Storage::Synchronization::ChangeLevel::ExcludeExportedTypes; type.changeLevel = Storage::Synchronization::ChangeLevel::ExcludeExportedTypes;
tracer.end(keyValue("type", type));
package.types.push_back(std::move(type)); package.types.push_back(std::move(type));
} }
@@ -736,6 +932,12 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
WatchedSourceIdsIds &watchedSourceIdsIds, WatchedSourceIdsIds &watchedSourceIdsIds,
FileState qmldirState) FileState qmldirState)
{ {
NanotraceHR::Tracer tracer{"parse qml components"_t,
category(),
keyValue("directory source id", directorySourceId),
keyValue("directory id", directoryId),
keyValue("qmldir state", qmldirState)};
std::sort(components.begin(), components.end(), [](auto &&first, auto &&second) { std::sort(components.begin(), components.end(), [](auto &&first, auto &&second) {
return first.fileName < second.fileName; return first.fileName < second.fileName;
}); });
@@ -763,22 +965,37 @@ ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) const NotUpdatedSourceIds &notUpdatedSourceIds) const
{ {
NanotraceHR::Tracer tracer{"update property editor paths"_t,
category(),
keyValue("source id", sourceId)};
auto currentFileStatus = m_fileStatusCache.find(sourceId); auto currentFileStatus = m_fileStatusCache.find(sourceId);
if (!currentFileStatus.isValid()) { if (!currentFileStatus.isValid()) {
tracer.tick("append updated file status source id"_t, keyValue("source id", sourceId));
package.updatedFileStatusSourceIds.push_back(sourceId); package.updatedFileStatusSourceIds.push_back(sourceId);
tracer.end(keyValue("state", FileState::NotExists));
return FileState::NotExists; return FileState::NotExists;
} }
auto projectStorageFileStatus = m_projectStorage.fetchFileStatus(sourceId); auto projectStorageFileStatus = m_projectStorage.fetchFileStatus(sourceId);
if (!projectStorageFileStatus.isValid() || projectStorageFileStatus != currentFileStatus) { if (!projectStorageFileStatus.isValid() || projectStorageFileStatus != currentFileStatus) {
tracer.tick("append file status"_t, keyValue("file status", sourceId));
package.fileStatuses.push_back(currentFileStatus); package.fileStatuses.push_back(currentFileStatus);
tracer.tick("append updated file status source id"_t, keyValue("source id", sourceId));
package.updatedFileStatusSourceIds.push_back(sourceId); package.updatedFileStatusSourceIds.push_back(sourceId);
tracer.end(keyValue("state", FileState::Changed));
return FileState::Changed; return FileState::Changed;
} }
tracer.tick("append not updated file status source id"_t, keyValue("source id", sourceId));
notUpdatedSourceIds.fileStatusSourceIds.push_back(sourceId); notUpdatedSourceIds.fileStatusSourceIds.push_back(sourceId);
tracer.end(keyValue("state", FileState::NotChanged));
return FileState::NotChanged; return FileState::NotChanged;
} }

View File

@@ -11,6 +11,8 @@
#include "projectstoragetypes.h" #include "projectstoragetypes.h"
#include "sourcepath.h" #include "sourcepath.h"
#include <tracing/qmldesignertracing.h>
#include <qmljs/parser/qmldirparser_p.h> #include <qmljs/parser/qmldirparser_p.h>
#include <QStringList> #include <QStringList>
@@ -141,6 +143,16 @@ private:
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds, NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds); WatchedSourceIdsIds &watchedSourceIdsIds);
void updateDirectoryChanged(std::string_view directoryPath,
FileState qmldirState,
SourcePath qmldirSourcePath,
SourceId qmldirSourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds,
ProjectStorageTracing::Category::TracerType &tracer);
void updatePropertyEditorPaths(const QString &propertyEditorResourcesPath, void updatePropertyEditorPaths(const QString &propertyEditorResourcesPath,
Storage::Synchronization::SynchronizationPackage &package, Storage::Synchronization::SynchronizationPackage &package,

View File

@@ -10,6 +10,8 @@
#include <sqlitedatabase.h> #include <sqlitedatabase.h>
#include <tracing/qmldesignertracing.h>
#ifdef QDS_BUILD_QMLPARSER #ifdef QDS_BUILD_QMLPARSER
#include <private/qqmldomtop_p.h> #include <private/qqmldomtop_p.h>
#endif #endif
@@ -21,6 +23,10 @@ namespace QmlDesigner {
#ifdef QDS_BUILD_QMLPARSER #ifdef QDS_BUILD_QMLPARSER
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
using NanotraceHR::keyValue;
using Tracer = ProjectStorageTracing::Category::TracerType;
namespace QmlDom = QQmlJS::Dom; namespace QmlDom = QQmlJS::Dom;
namespace Synchronization = Storage::Synchronization; namespace Synchronization = Storage::Synchronization;
@@ -84,6 +90,11 @@ QualifiedImports createQualifiedImports(const QList<QmlDom::Import> &qmlImports,
Utils::SmallStringView directoryPath, Utils::SmallStringView directoryPath,
QmlDocumentParser::ProjectStorage &storage) QmlDocumentParser::ProjectStorage &storage)
{ {
NanotraceHR::Tracer tracer{"create qualified imports"_t,
category(),
keyValue("sourceId", sourceId),
keyValue("directoryPath", directoryPath)};
QualifiedImports qualifiedImports; QualifiedImports qualifiedImports;
for (const QmlDom::Import &qmlImport : qmlImports) { for (const QmlDom::Import &qmlImport : qmlImports) {
@@ -92,6 +103,8 @@ QualifiedImports createQualifiedImports(const QList<QmlDom::Import> &qmlImports,
createImport(qmlImport, sourceId, directoryPath, storage)); createImport(qmlImport, sourceId, directoryPath, storage));
} }
tracer.end(keyValue("qualified imports", qualifiedImports));
return qualifiedImports; return qualifiedImports;
} }
@@ -280,6 +293,11 @@ Storage::Synchronization::Type QmlDocumentParser::parse(const QString &sourceCon
SourceId sourceId, SourceId sourceId,
Utils::SmallStringView directoryPath) Utils::SmallStringView directoryPath)
{ {
NanotraceHR::Tracer tracer{"qml document parser parse"_t,
category(),
keyValue("sourceId", sourceId),
keyValue("directoryPath", directoryPath)};
Storage::Synchronization::Type type; Storage::Synchronization::Type type;
using Option = QmlDom::DomEnvironment::Option; using Option = QmlDom::DomEnvironment::Option;

View File

@@ -5,6 +5,8 @@
#include "projectstorage.h" #include "projectstorage.h"
#include <tracing/qmldesignertracing.h>
#include <sqlitedatabase.h> #include <sqlitedatabase.h>
#ifdef QDS_BUILD_QMLPARSER #ifdef QDS_BUILD_QMLPARSER
@@ -21,6 +23,10 @@ namespace QmlDesigner {
#ifdef QDS_BUILD_QMLPARSER #ifdef QDS_BUILD_QMLPARSER
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
using NanotraceHR::keyValue;
using Tracer = ProjectStorageTracing::Category::TracerType;
namespace QmlDom = QQmlJS::Dom; namespace QmlDom = QQmlJS::Dom;
namespace { namespace {
@@ -31,6 +37,8 @@ using Storage::TypeNameString;
ComponentWithoutNamespaces createComponentNameWithoutNamespaces(const QList<QQmlJSExportedScope> &objects) ComponentWithoutNamespaces createComponentNameWithoutNamespaces(const QList<QQmlJSExportedScope> &objects)
{ {
NanotraceHR::Tracer tracer{"parse qmltypes file"_t, category()};
ComponentWithoutNamespaces componentWithoutNamespaces; ComponentWithoutNamespaces componentWithoutNamespaces;
for (const auto &object : objects) { for (const auto &object : objects) {
@@ -46,10 +54,12 @@ ComponentWithoutNamespaces createComponentNameWithoutNamespaces(const QList<QQml
name); name);
} }
tracer.end(keyValue("components without namespace", componentWithoutNamespaces));
return componentWithoutNamespaces; return componentWithoutNamespaces;
} }
void appendImports(Storage::Imports &imports, const Storage::Import &appendImports(Storage::Imports &imports,
const QString &dependency, const QString &dependency,
SourceId sourceId, SourceId sourceId,
QmlTypesParser::ProjectStorage &storage) QmlTypesParser::ProjectStorage &storage)
@@ -62,7 +72,7 @@ void appendImports(Storage::Imports &imports,
moduleName.append("-cppnative"); moduleName.append("-cppnative");
ModuleId cppModuleId = storage.moduleId(moduleName); ModuleId cppModuleId = storage.moduleId(moduleName);
imports.emplace_back(cppModuleId, Storage::Version{}, sourceId); return imports.emplace_back(cppModuleId, Storage::Version{}, sourceId);
} }
void addImports(Storage::Imports &imports, void addImports(Storage::Imports &imports,
@@ -71,13 +81,25 @@ void addImports(Storage::Imports &imports,
QmlTypesParser::ProjectStorage &storage, QmlTypesParser::ProjectStorage &storage,
ModuleId cppModuleId) ModuleId cppModuleId)
{ {
for (const QString &dependency : dependencies) NanotraceHR::Tracer tracer{
appendImports(imports, dependency, sourceId, storage); "add imports"_t,
category(),
keyValue("source id", sourceId),
keyValue("module id", cppModuleId),
};
imports.emplace_back(cppModuleId, Storage::Version{}, sourceId); for (const QString &dependency : dependencies) {
const auto &import = appendImports(imports, dependency, sourceId, storage);
tracer.tick("append import"_t, keyValue("import", import), keyValue("dependency", dependency));
}
if (ModuleId qmlCppModuleId = storage.moduleId("QML-cppnative"); cppModuleId != qmlCppModuleId) const auto &import = imports.emplace_back(cppModuleId, Storage::Version{}, sourceId);
imports.emplace_back(qmlCppModuleId, Storage::Version{}, sourceId); tracer.tick("append import"_t, keyValue("import", import));
if (ModuleId qmlCppModuleId = storage.moduleId("QML-cppnative"); cppModuleId != qmlCppModuleId) {
const auto &import = imports.emplace_back(qmlCppModuleId, Storage::Version{}, sourceId);
tracer.tick("append import"_t, keyValue("import", import));
}
} }
Storage::TypeTraits createAccessTypeTraits(QQmlJSScope::AccessSemantics accessSematics) Storage::TypeTraits createAccessTypeTraits(QQmlJSScope::AccessSemantics accessSematics)
@@ -412,6 +434,11 @@ void addType(Storage::Synchronization::Types &types,
QmlTypesParser::ProjectStorage &storage, QmlTypesParser::ProjectStorage &storage,
const ComponentWithoutNamespaces &componentNameWithoutNamespace) const ComponentWithoutNamespaces &componentNameWithoutNamespace)
{ {
NanotraceHR::Tracer tracer{"add type"_t,
category(),
keyValue("source id", sourceId),
keyValue("module id", cppModuleId)};
const auto &component = *exportScope.scope; const auto &component = *exportScope.scope;
auto [functionsDeclarations, signalDeclarations] = createFunctionAndSignals( auto [functionsDeclarations, signalDeclarations] = createFunctionAndSignals(
@@ -421,7 +448,7 @@ void addType(Storage::Synchronization::Types &types,
auto exports = exportScope.exports; auto exports = exportScope.exports;
auto enumerationTypes = addEnumerationTypes(types, typeName, sourceId, cppModuleId, enumerations); auto enumerationTypes = addEnumerationTypes(types, typeName, sourceId, cppModuleId, enumerations);
types.emplace_back( const auto &type = types.emplace_back(
Utils::SmallStringView{typeName}, Utils::SmallStringView{typeName},
Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}}, Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}},
Storage::Synchronization::ImportedType{TypeNameString{component.extensionTypeName()}}, Storage::Synchronization::ImportedType{TypeNameString{component.extensionTypeName()}},
@@ -432,6 +459,7 @@ void addType(Storage::Synchronization::Types &types,
std::move(functionsDeclarations), std::move(functionsDeclarations),
std::move(signalDeclarations), std::move(signalDeclarations),
createEnumeration(enumerations)); createEnumeration(enumerations));
tracer.end(keyValue("type", type));
} }
void addTypes(Storage::Synchronization::Types &types, void addTypes(Storage::Synchronization::Types &types,
@@ -440,6 +468,7 @@ void addTypes(Storage::Synchronization::Types &types,
QmlTypesParser::ProjectStorage &storage, QmlTypesParser::ProjectStorage &storage,
const ComponentWithoutNamespaces &componentNameWithoutNamespaces) const ComponentWithoutNamespaces &componentNameWithoutNamespaces)
{ {
NanotraceHR::Tracer tracer{"add types"_t, category()};
types.reserve(Utils::usize(objects) + types.size()); types.reserve(Utils::usize(objects) + types.size());
for (const auto &object : objects) for (const auto &object : objects)
@@ -458,6 +487,8 @@ void QmlTypesParser::parse(const QString &sourceContent,
Storage::Synchronization::Types &types, Storage::Synchronization::Types &types,
const Storage::Synchronization::ProjectData &projectData) const Storage::Synchronization::ProjectData &projectData)
{ {
NanotraceHR::Tracer tracer{"qmltypes parser parse"_t, category()};
QQmlJSTypeDescriptionReader reader({}, sourceContent); QQmlJSTypeDescriptionReader reader({}, sourceContent);
QList<QQmlJSExportedScope> components; QList<QQmlJSExportedScope> components;
QStringList dependencies; QStringList dependencies;

View File

@@ -117,6 +117,12 @@ public:
std::ptrdiff_t slashIndex() const { return m_slashIndex; } std::ptrdiff_t slashIndex() const { return m_slashIndex; }
template<typename String>
friend void convertToString(String &string, const SourcePath &path)
{
convertToString(string, path.toStringView());
}
private: private:
std::ptrdiff_t m_slashIndex = -1; std::ptrdiff_t m_slashIndex = -1;
}; };

View File

@@ -68,14 +68,22 @@ Category &category()
namespace ProjectStorageTracing { namespace ProjectStorageTracing {
NanotraceHR::StringViewWithStringArgumentsCategory<projectStorageTracingStatus()> &projectStorageCategory() Category &projectStorageCategory()
{ {
thread_local NanotraceHR::StringViewWithStringArgumentsCategory<projectStorageTracingStatus()> thread_local Category category{"project storage"_t,
projectStorageCategory_{"project storage"_t,
Tracing::eventQueueWithStringArguments(), Tracing::eventQueueWithStringArguments(),
projectStorageCategory}; projectStorageCategory};
return projectStorageCategory_; return category;
}
Category &projectStorageUpdaterCategory()
{
thread_local Category category{"project storage updater"_t,
Tracing::eventQueueWithStringArguments(),
projectStorageCategory};
return category;
} }
} // namespace ProjectStorageTracing } // namespace ProjectStorageTracing

View File

@@ -55,7 +55,11 @@ constexpr NanotraceHR::Tracing projectStorageTracingStatus()
#endif #endif
} }
[[gnu::pure]] NanotraceHR::StringViewWithStringArgumentsCategory<projectStorageTracingStatus()> & using Category = NanotraceHR::StringViewWithStringArgumentsCategory<projectStorageTracingStatus()>;
projectStorageCategory();
[[gnu::pure]] Category &projectStorageCategory();
[[gnu::pure]] Category &projectStorageUpdaterCategory();
} // namespace ProjectStorageTracing } // namespace ProjectStorageTracing
} // namespace QmlDesigner } // namespace QmlDesigner