diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-05-05 09:30:27 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-05-30 13:42:35 +0200 |
| commit | cdd7fe05f676ed1664a156beaf63093237a3beac (patch) | |
| tree | 8f7adccde1adc0e8404a96a895c5170b84f3f0cc /tools | |
| parent | 65cb77165ba18442a524faf44f712ae26661965c (diff) | |
QQmlSA: Create an abstraction layer for static analysis
This patch adds abstractions for QML Elements, Bindings, Methods and
Properties. This abstraction layer avoids exposing internal details and
should be more suited for static analysis tasks. It is now possible to
write qmllint plugins without including private headers.
As a drive-by, change tst_qmllint:verifyJsRoot to open files in text
mode instead of binary. This fixes an issue where line endings cause
issues on Windows.
Fixes: QTBUG-102276
Change-Id: I6b6e53f1e0078734a18f3aa51807fbe875b375f0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/qmllint/main.cpp | 54 | ||||
| -rw-r--r-- | tools/qmltc/main.cpp | 2 | ||||
| -rw-r--r-- | tools/qmltc/qmltccodewriter.cpp | 12 | ||||
| -rw-r--r-- | tools/qmltc/qmltccompiler.cpp | 74 | ||||
| -rw-r--r-- | tools/qmltc/qmltccompiler.h | 6 | ||||
| -rw-r--r-- | tools/qmltc/qmltccompilerpieces.cpp | 4 | ||||
| -rw-r--r-- | tools/qmltc/qmltcoutputir.h | 2 | ||||
| -rw-r--r-- | tools/qmltc/qmltcvisitor.cpp | 27 | ||||
| -rw-r--r-- | tools/qmltc/qmltcvisitor.h | 6 |
9 files changed, 107 insertions, 80 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index 947a13da08..b244868a17 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -6,6 +6,7 @@ #include <QtQmlCompiler/private/qqmljsresourcefilemapper_p.h> #include <QtQmlCompiler/private/qqmljscompiler_p.h> #include <QtQmlCompiler/private/qqmljslinter_p.h> +#include <QtQmlCompiler/private/qqmljsloggingutils_p.h> #include <QtCore/qdebug.h> #include <QtCore/qfile.h> @@ -32,7 +33,7 @@ constexpr int JSON_LOGGING_FORMAT_REVISION = 3; int main(int argv, char *argc[]) { QHashSeed::setDeterministicGlobalSeed(); - QList<QQmlJSLogger::Category> categories; + QList<QQmlJS::LoggerCategory> categories; QCoreApplication app(argv, argc); QCoreApplication::setApplicationName("qmllint"); @@ -150,20 +151,36 @@ All warnings can be set to three levels: QLatin1String("directory")); parser.addOption(pluginPathsOption); - auto addCategory = [&](const QQmlJSLogger::Category &category) { + auto levelToString = [](const QQmlJS::LoggerCategory &category) -> QString { + Q_ASSERT(category.isIgnored() || category.level() != QtCriticalMsg); + if (category.isIgnored()) + return QStringLiteral("disable"); + + switch (category.level()) { + case QtInfoMsg: + return QStringLiteral("info"); + case QtWarningMsg: + return QStringLiteral("warning"); + default: + Q_UNREACHABLE(); + break; + } + }; + + auto addCategory = [&](const QQmlJS::LoggerCategory &category) { categories.push_back(category); - if (category.isDefault) + if (category.isDefault()) return; QCommandLineOption option( category.id().name().toString(), - category.description - + QStringLiteral(" (default: %1)").arg(category.levelToString()), - QStringLiteral("level"), category.levelToString()); - if (category.ignored) + category.description() + + QStringLiteral(" (default: %1)").arg(levelToString(category)), + QStringLiteral("level"), levelToString(category)); + if (category.isIgnored()) option.setFlags(QCommandLineOption::HiddenFromHelp); parser.addOption(option); - settings.addOption(QStringLiteral("Warnings/") + category.settingsName, - category.levelToString()); + settings.addOption(QStringLiteral("Warnings/") + category.settingsName(), + levelToString(category)); }; for (const auto &category : QQmlJSLogger::defaultCategories()) { @@ -192,21 +209,30 @@ All warnings can be set to three levels: auto updateLogLevels = [&]() { for (auto &category : categories) { - if (category.isDefault) + if (category.isDefault()) continue; const QString &key = category.id().name().toString(); - const QString &settingsName = QStringLiteral("Warnings/") + category.settingsName; + const QString &settingsName = QStringLiteral("Warnings/") + category.settingsName(); if (parser.isSet(key) || settings.isSet(settingsName)) { const QString value = parser.isSet(key) ? parser.value(key) : settings.value(settingsName).toString(); // Do not try to set the levels if it's due to a default config option. // This way we can tell which options have actually been overwritten by the user. - if (category.levelToString() == value && !parser.isSet(key)) + if (levelToString(category) == value && !parser.isSet(key)) continue; - if (!category.setLevel(value)) { + if (value == "disable"_L1) { + category.setLevel(QtCriticalMsg); + category.setIgnored(true); + } else if (value == "info"_L1) { + category.setLevel(QtInfoMsg); + category.setIgnored(false); + } else if (value == "warning"_L1) { + category.setLevel(QtWarningMsg); + category.setIgnored(false); + } else { qWarning() << "Invalid logging level" << value << "provided for" << category.id().name().toString() << "(allowed are: disable, info, warning)"; @@ -267,7 +293,7 @@ All warnings can be set to three levels: QQmlJSLinter linter(qmlImportPaths, pluginPaths, useAbsolutePath); for (const QQmlJSLinter::Plugin &plugin : linter.plugins()) { - for (const QQmlJSLogger::Category &category : plugin.categories()) + for (const QQmlJS::LoggerCategory &category : plugin.categories()) addCategory(category); } diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index 65560c70e1..5d4bfcc4b7 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -31,7 +31,7 @@ using namespace Qt::StringLiterals; void setupLogger(QQmlJSLogger &logger) // prepare logger to work with compiler { - for (const QQmlJSLogger::Category &category : logger.categories()) { + for (const QQmlJS::LoggerCategory &category : logger.categories()) { if (category == qmlUnusedImports) continue; logger.setCategoryLevel(category.id(), QtCriticalMsg); diff --git a/tools/qmltc/qmltccodewriter.cpp b/tools/qmltc/qmltccodewriter.cpp index 6996277473..67ffcd6b0b 100644 --- a/tools/qmltc/qmltccodewriter.cpp +++ b/tools/qmltc/qmltccodewriter.cpp @@ -42,14 +42,14 @@ static QString getFunctionCategory(const QmltcMethod &method) { QString category = getFunctionCategory(static_cast<const QmltcMethodBase &>(method)); switch (method.type) { - case QQmlJSMetaMethod::Signal: + case QQmlJSMetaMethodType::Signal: category = u"Q_SIGNALS"_s; break; - case QQmlJSMetaMethod::Slot: + case QQmlJSMetaMethodType::Slot: category += u" Q_SLOTS"_s; break; - case QQmlJSMetaMethod::Method: - case QQmlJSMetaMethod::StaticMethod: + case QQmlJSMetaMethodType::Method: + case QQmlJSMetaMethodType::StaticMethod: break; } return category; @@ -396,14 +396,14 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcMethod &method) { const auto [hSignature, cppSignature] = functionSignatures(method); // Note: augment return type with preambles in declaration - code.rawAppendToHeader((method.type == QQmlJSMetaMethod::StaticMethod + code.rawAppendToHeader((method.type == QQmlJSMetaMethodType::StaticMethod ? u"static " + functionReturnType(method) : functionReturnType(method)) + u" " + hSignature + u";"); // do not generate method implementation if it is a signal const auto methodType = method.type; - if (methodType != QQmlJSMetaMethod::Signal) { + if (methodType != QQmlJSMetaMethodType::Signal) { code.rawAppendToCpp(u""_s); // blank line if (method.comments.size() > 0) { code.rawAppendToCpp(u"/*! \\internal"_s); diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp index 6d8fbd99b5..61205cef55 100644 --- a/tools/qmltc/qmltccompiler.cpp +++ b/tools/qmltc/qmltccompiler.cpp @@ -127,7 +127,7 @@ void QmltcCompiler::compile(const QmltcCompilerInfo &info) }; for (const auto &type : pureTypes) { - Q_ASSERT(type->scopeType() == QQmlJSScope::QMLScope); + Q_ASSERT(type->scopeType() == QQmlSA::ScopeType::QMLScope); compiledTypes.emplaceBack(); // create empty type compileType(compiledTypes.back(), type, compile); } @@ -324,7 +324,7 @@ void QmltcCompiler::compileType( staticCreate.comments << u"Used by the engine for singleton creation."_s << u"See also \\l {https://doc.qt.io/qt-6/qqmlengine.html#QML_SINGLETON}."_s; - staticCreate.type = QQmlJSMetaMethod::StaticMethod; + staticCreate.type = QQmlJSMetaMethodType::StaticMethod; staticCreate.access = QQmlJSMetaMethod::Public; staticCreate.name = u"create"_s; staticCreate.returnType = u"%1 *"_s.arg(current.cppType); @@ -453,7 +453,7 @@ compileMethodParameters(const QList<QQmlJSMetaParameter> ¶meterInfos, bool a static QString figureReturnType(const QQmlJSMetaMethod &m) { const bool isVoidMethod = - m.returnTypeName() == u"void" || m.methodType() == QQmlJSMetaMethod::Signal; + m.returnTypeName() == u"void" || m.methodType() == QQmlJSMetaMethodType::Signal; Q_ASSERT(isVoidMethod || m.returnType()); QString type; if (isVoidMethod) { @@ -470,10 +470,10 @@ void QmltcCompiler::compileMethod(QmltcType ¤t, const QQmlJSMetaMethod &m, const auto returnType = figureReturnType(m); const QList<QmltcVariable> compiledParams = compileMethodParameters(m.parameters()); - const auto methodType = QQmlJSMetaMethod::Type(m.methodType()); + const auto methodType = m.methodType(); QStringList code; - if (methodType != QQmlJSMetaMethod::Signal) { + if (methodType != QQmlJSMetaMethodType::Signal) { QmltcCodeGenerator urlGenerator { m_url, m_visitor }; QmltcCodeGenerator::generate_callExecuteRuntimeFunction( &code, urlGenerator.urlMethodName() + u"()", @@ -488,7 +488,7 @@ void QmltcCompiler::compileMethod(QmltcType ¤t, const QQmlJSMetaMethod &m, compiled.body = std::move(code); compiled.type = methodType; compiled.access = m.access(); - if (methodType != QQmlJSMetaMethod::Signal) { + if (methodType != QQmlJSMetaMethodType::Signal) { compiled.declarationPrefixes << u"Q_INVOKABLE"_s; compiled.userVisible = m.access() == QQmlJSMetaMethod::Public; } else { @@ -1060,7 +1060,7 @@ void QmltcCompiler::compileObjectBinding(QmltcType ¤t, const QQmlJSScope::ConstPtr &type, const BindingAccessorData &accessor) { - Q_ASSERT(binding.bindingType() == QQmlJSMetaPropertyBinding::Object); + Q_ASSERT(binding.bindingType() == QQmlSA::BindingType::Object); const QString &propertyName = binding.propertyName(); const QQmlJSMetaProperty property = type->property(propertyName); @@ -1157,8 +1157,8 @@ void QmltcCompiler::compileValueSourceOrInterceptorBinding(QmltcType ¤t, const QQmlJSScope::ConstPtr &type, const BindingAccessorData &accessor) { - Q_ASSERT(binding.bindingType() == QQmlJSMetaPropertyBinding::ValueSource - || binding.bindingType() == QQmlJSMetaPropertyBinding::Interceptor); + Q_ASSERT(binding.bindingType() == QQmlSA::BindingType::ValueSource + || binding.bindingType() == QQmlSA::BindingType::Interceptor); const QString &propertyName = binding.propertyName(); const QQmlJSMetaProperty property = type->property(propertyName); @@ -1166,7 +1166,7 @@ void QmltcCompiler::compileValueSourceOrInterceptorBinding(QmltcType ¤t, // NB: object is compiled with compileType(), here just need to use it QSharedPointer<const QQmlJSScope> object; - if (binding.bindingType() == QQmlJSMetaPropertyBinding::Interceptor) + if (binding.bindingType() == QQmlSA::BindingType::Interceptor) object = binding.interceptorType(); else object = binding.valueSourceType(); @@ -1215,7 +1215,7 @@ void QmltcCompiler::compileAttachedPropertyBinding(QmltcType ¤t, const QQmlJSScope::ConstPtr &type, const BindingAccessorData &accessor) { - Q_ASSERT(binding.bindingType() == QQmlJSMetaPropertyBinding::AttachedProperty); + Q_ASSERT(binding.bindingType() == QQmlSA::BindingType::AttachedProperty); const QString &propertyName = binding.propertyName(); const QQmlJSMetaProperty property = type->property(propertyName); @@ -1279,7 +1279,7 @@ void QmltcCompiler::compileGroupPropertyBinding(QmltcType ¤t, const QQmlJSScope::ConstPtr &type, const BindingAccessorData &accessor) { - Q_ASSERT(binding.bindingType() == QQmlJSMetaPropertyBinding::GroupProperty); + Q_ASSERT(binding.bindingType() == QQmlSA::BindingType::GroupProperty); const QString &propertyName = binding.propertyName(); const QQmlJSMetaProperty property = type->property(propertyName); @@ -1336,7 +1336,7 @@ void QmltcCompiler::compileGroupPropertyBinding(QmltcType ¤t, auto it = subbindings.begin(); Q_ASSERT(std::all_of(it, firstScript, [](const auto &x) { - return x.bindingType() != QQmlJSMetaPropertyBinding::Script; + return x.bindingType() != QQmlSA::BindingType::Script; })); compile(it, firstScript); it = firstScript; @@ -1357,7 +1357,7 @@ void QmltcCompiler::compileGroupPropertyBinding(QmltcType ¤t, // once the value is written back, process the script bindings Q_ASSERT(std::all_of(it, subbindings.end(), [](const auto &x) { - return x.bindingType() == QQmlJSMetaPropertyBinding::Script; + return x.bindingType() == QQmlSA::BindingType::Script; })); compile(it, subbindings.end()); } @@ -1371,8 +1371,8 @@ void QmltcCompiler::compileTranslationBinding(QmltcType ¤t, const QQmlJSScope::ConstPtr &type, const BindingAccessorData &accessor) { - Q_ASSERT(binding.bindingType() == QQmlJSMetaPropertyBinding::Translation - || binding.bindingType() == QQmlJSMetaPropertyBinding::TranslationById); + Q_ASSERT(binding.bindingType() == QQmlSA::BindingType::Translation + || binding.bindingType() == QQmlSA::BindingType::TranslationById); const QString &propertyName = binding.propertyName(); @@ -1449,7 +1449,7 @@ void QmltcCompiler::compileBinding(QmltcType ¤t, const auto location = binding.sourceLocation(); // make sure group property is not generalized by checking if type really has a property // called propertyName. If not, it is probably an id. - if (binding.bindingType() == QQmlJSMetaPropertyBinding::GroupProperty + if (binding.bindingType() == QQmlSA::BindingType::GroupProperty && type->hasProperty(propertyName)) { qCWarning(lcQmltcCompiler) << QStringLiteral("Binding at line %1 column %2 is not deferred as it is a " @@ -1496,26 +1496,26 @@ void QmltcCompiler::compileBindingByType(QmltcType ¤t, accessor.name, constructFromQObject); }; switch (binding.bindingType()) { - case QQmlJSMetaPropertyBinding::BoolLiteral: { + case QQmlSA::BindingType::BoolLiteral: { const bool value = binding.boolValue(); assignToProperty(metaProperty, value ? u"true"_s : u"false"_s); break; } - case QQmlJSMetaPropertyBinding::NumberLiteral: { + case QQmlSA::BindingType::NumberLiteral: { assignToProperty(metaProperty, QString::number(binding.numberValue())); break; } - case QQmlJSMetaPropertyBinding::StringLiteral: { + case QQmlSA::BindingType::StringLiteral: { assignToProperty(metaProperty, QQmlJSUtils::toLiteral(binding.stringValue())); break; } - case QQmlJSMetaPropertyBinding::RegExpLiteral: { + case QQmlSA::BindingType::RegExpLiteral: { const QString value = u"QRegularExpression(%1)"_s.arg(QQmlJSUtils::toLiteral(binding.regExpValue())); assignToProperty(metaProperty, value); break; } - case QQmlJSMetaPropertyBinding::Null: { + case QQmlSA::BindingType::Null: { // poor check: null bindings are only supported for var and objects Q_ASSERT(propertyType->isSameType(m_typeResolver->varType()) || propertyType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference); @@ -1525,38 +1525,38 @@ void QmltcCompiler::compileBindingByType(QmltcType ¤t, assignToProperty(metaProperty, u"QVariant::fromValue(nullptr)"_s); break; } - case QQmlJSMetaPropertyBinding::Script: { + case QQmlSA::BindingType::Script: { QString bindingSymbolName = type->internalName() + u'_' + propertyName + u"_binding"; bindingSymbolName.replace(u'.', u'_'); // can happen with group properties compileScriptBinding(current, binding, bindingSymbolName, type, propertyName, propertyType, accessor); break; } - case QQmlJSMetaPropertyBinding::Object: { + case QQmlSA::BindingType::Object: { compileObjectBinding(current, binding, type, accessor); break; } - case QQmlJSMetaPropertyBinding::Interceptor: + case QQmlSA::BindingType::Interceptor: Q_FALLTHROUGH(); - case QQmlJSMetaPropertyBinding::ValueSource: { + case QQmlSA::BindingType::ValueSource: { compileValueSourceOrInterceptorBinding(current, binding, type, accessor); break; } - case QQmlJSMetaPropertyBinding::AttachedProperty: { + case QQmlSA::BindingType::AttachedProperty: { compileAttachedPropertyBinding(current, binding, type, accessor); break; } - case QQmlJSMetaPropertyBinding::GroupProperty: { + case QQmlSA::BindingType::GroupProperty: { compileGroupPropertyBinding(current, binding, type, accessor); break; } - case QQmlJSMetaPropertyBinding::TranslationById: - case QQmlJSMetaPropertyBinding::Translation: { + case QQmlSA::BindingType::TranslationById: + case QQmlSA::BindingType::Translation: { compileTranslationBinding(current, binding, type, accessor); break; } - case QQmlJSMetaPropertyBinding::Invalid: { + case QQmlSA::BindingType::Invalid: { recordError(binding.sourceLocation(), u"This binding is invalid"_s); break; } @@ -1652,10 +1652,10 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, Q_ASSERT(!objectClassName_signal.isEmpty()); Q_ASSERT(!objectClassName_slot.isEmpty()); - const auto signalMethods = objectType->methods(name, QQmlJSMetaMethod::Signal); + const auto signalMethods = objectType->methods(name, QQmlJSMetaMethodType::Signal); Q_ASSERT(!signalMethods.isEmpty()); // an error somewhere else QQmlJSMetaMethod signal = signalMethods.at(0); - Q_ASSERT(signal.methodType() == QQmlJSMetaMethod::Signal); + Q_ASSERT(signal.methodType() == QQmlJSMetaMethodType::Signal); const QString signalName = signal.methodName(); const QString slotName = newSymbol(signalName + u"_slot"); @@ -1675,7 +1675,7 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, objectType->ownRuntimeFunctionIndex(binding.scriptIndex()), u"this"_s, // Note: because script bindings always use current QML object scope signalReturnType, slotParameters); - slotMethod.type = QQmlJSMetaMethod::Slot; + slotMethod.type = QQmlJSMetaMethodType::Slot; current.functions << std::move(slotMethod); current.setComplexBindings.body << u"QObject::connect(" + This_signal + u", " + u"&" @@ -1684,7 +1684,7 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, }; switch (binding.scriptKind()) { - case QQmlJSMetaPropertyBinding::Script_PropertyBinding: { + case QQmlSA::ScriptBindingKind::Script_PropertyBinding: { if (!propertyType) { recordError(binding.sourceLocation(), u"Binding on property '" + propertyName + u"' of unknown type"); @@ -1726,13 +1726,13 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, property, valueTypeIndex, accessor.name); break; } - case QQmlJSMetaPropertyBinding::Script_SignalHandler: { + case QQmlSA::ScriptBindingKind::Script_SignalHandler: { const auto name = QQmlJSUtils::signalName(propertyName); Q_ASSERT(name.has_value()); compileScriptSignal(*name); break; } - case QQmlJSMetaPropertyBinding::Script_ChangeHandler: { + case QQmlSA ::ScriptBindingKind::Script_ChangeHandler: { const QString objectClassName = objectType->internalName(); const QString bindingFunctorName = newSymbol(bindingSymbolName + u"Functor"); diff --git a/tools/qmltc/qmltccompiler.h b/tools/qmltc/qmltccompiler.h index baa5b23256..3deab6d44e 100644 --- a/tools/qmltc/qmltccompiler.h +++ b/tools/qmltc/qmltccompiler.h @@ -50,7 +50,7 @@ public: static bool isComplexBinding(const QQmlJSMetaPropertyBinding &binding) { // TODO: translation bindings (once supported) are also complex? - return binding.bindingType() == QQmlJSMetaPropertyBinding::Script; + return binding.bindingType() == QQmlSA::BindingType::Script; } private: @@ -187,14 +187,14 @@ private: bool hasErrors() const { return m_logger->hasErrors(); } void recordError(const QQmlJS::SourceLocation &location, const QString &message, - LoggerWarningId id = qmlCompiler) + QQmlJS::LoggerWarningId id = qmlCompiler) { // pretty much any compiler error is a critical error (we cannot // generate code - compilation fails) m_logger->log(message, id, location); } void recordError(const QV4::CompiledData::Location &location, const QString &message, - LoggerWarningId id = qmlCompiler) + QQmlJS::LoggerWarningId id = qmlCompiler) { recordError(QQmlJS::SourceLocation { 0, 0, location.line(), location.column() }, message, id); diff --git a/tools/qmltc/qmltccompilerpieces.cpp b/tools/qmltc/qmltccompilerpieces.cpp index 601cf1bbed..62b457337a 100644 --- a/tools/qmltc/qmltccompilerpieces.cpp +++ b/tools/qmltc/qmltccompilerpieces.cpp @@ -15,8 +15,8 @@ static QString scopeName(const QQmlJSScope::ConstPtr &scope) { Q_ASSERT(scope->isFullyResolved()); const auto scopeType = scope->scopeType(); - if (scopeType == QQmlJSScope::GroupedPropertyScope - || scopeType == QQmlJSScope::AttachedPropertyScope) { + if (scopeType == QQmlSA::ScopeType::GroupedPropertyScope + || scopeType == QQmlSA::ScopeType::AttachedPropertyScope) { return scope->baseType()->internalName(); } return scope->internalName(); diff --git a/tools/qmltc/qmltcoutputir.h b/tools/qmltc/qmltcoutputir.h index cd094ee7b1..bed5a2037f 100644 --- a/tools/qmltc/qmltcoutputir.h +++ b/tools/qmltc/qmltcoutputir.h @@ -75,7 +75,7 @@ struct QmltcMethodBase struct QmltcMethod : QmltcMethodBase { QString returnType; // C++ return type - QQmlJSMetaMethod::Type type = QQmlJSMetaMethod::Method; // Qt function type + QQmlJSMetaMethodType type = QQmlJSMetaMethodType::Method; // Qt function type // TODO: should be a better way to handle this bool userVisible = false; // tells if a function is prioritized during the output generation diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp index 236ad76467..3acee13bbb 100644 --- a/tools/qmltc/qmltcvisitor.cpp +++ b/tools/qmltc/qmltcvisitor.cpp @@ -133,8 +133,9 @@ void QmltcVisitor::findCppIncludes() Q_ASSERT(type); const auto scopeType = type->scopeType(); - if (scopeType != QQmlJSScope::QMLScope && scopeType != QQmlJSScope::GroupedPropertyScope - && scopeType != QQmlJSScope::AttachedPropertyScope) { + if (scopeType != QQmlSA::ScopeType::QMLScope + && scopeType != QQmlSA::ScopeType::GroupedPropertyScope + && scopeType != QQmlSA::ScopeType::AttachedPropertyScope) { continue; } @@ -174,7 +175,7 @@ void QmltcVisitor::findCppIncludes() static void addCleanQmlTypeName(QStringList *names, const QQmlJSScope::ConstPtr &scope) { - Q_ASSERT(scope->scopeType() == QQmlJSScope::QMLScope); + Q_ASSERT(scope->scopeType() == QQmlSA::ScopeType::QMLScope); Q_ASSERT(!scope->isArrayScope()); Q_ASSERT(!scope->baseTypeName().isEmpty()); // the scope is guaranteed to be a new QML type, so any prefixes (separated @@ -197,7 +198,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiObjectDefinition *object) } // we're not interested in non-QML scopes - if (m_currentScope->scopeType() != QQmlJSScope::QMLScope) + if (m_currentScope->scopeType() != QQmlSA::ScopeType::QMLScope) return true; if (m_currentScope->isInlineComponent()) { @@ -216,7 +217,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiObjectDefinition *object) void QmltcVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *object) { - if (m_currentScope->scopeType() == QQmlJSScope::QMLScope) + if (m_currentScope->scopeType() == QQmlSA::ScopeType::QMLScope) m_qmlTypeNames.removeLast(); QQmlJSImportVisitor::endVisit(object); } @@ -280,7 +281,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiPublicMember *publicMember) u"internal error: %1 found for property '%2'"_s.arg(errorString, name), qmlCompiler, publicMember->identifierToken); return false; - } else if (methods[0].methodType() != QQmlJSMetaMethod::Signal) { + } else if (methods[0].methodType() != QQmlJSMetaMethodType::Signal) { m_logger->log(u"internal error: method %1 of property %2 must be a signal"_s.arg( notifyName, name), qmlCompiler, publicMember->identifierToken); @@ -342,11 +343,11 @@ void QmltcVisitor::endVisit(QQmlJS::AST::UiProgram *program) QQmlJSScope::ConstPtr fetchType(const QQmlJSMetaPropertyBinding &binding) { switch (binding.bindingType()) { - case QQmlJSMetaPropertyBinding::Object: + case QQmlSA::BindingType::Object: return binding.objectType(); - case QQmlJSMetaPropertyBinding::Interceptor: + case QQmlSA::BindingType::Interceptor: return binding.interceptorType(); - case QQmlJSMetaPropertyBinding::ValueSource: + case QQmlSA::BindingType::ValueSource: return binding.valueSourceType(); // TODO: AttachedProperty and GroupProperty are not supported yet, // but have to also be acknowledged here @@ -435,7 +436,7 @@ void QmltcVisitor::postVisitResolve( // match scopes to indices of QmlIR::Object from QmlIR::Document qsizetype count = 0; const auto setIndex = [&](const QQmlJSScope::Ptr ¤t) { - if (current->scopeType() != QQmlJSScope::QMLScope || current->isArrayScope()) + if (current->scopeType() != QQmlSA::ScopeType::QMLScope || current->isArrayScope()) return; Q_ASSERT(!m_qmlIrObjectIndices.contains(current)); m_qmlIrObjectIndices[current] = count; @@ -547,9 +548,9 @@ void QmltcVisitor::postVisitResolve( if (scope->isArrayScope()) // special kind of QQmlJSScope::QMLScope return; switch (scope->scopeType()) { - case QQmlJSScope::QMLScope: - case QQmlJSScope::GroupedPropertyScope: - case QQmlJSScope::AttachedPropertyScope: { + case QQmlSA::ScopeType::QMLScope: + case QQmlSA::ScopeType::GroupedPropertyScope: + case QQmlSA::ScopeType::AttachedPropertyScope: { ++qmlScopeCount[scope->enclosingInlineComponentName()]; break; } diff --git a/tools/qmltc/qmltcvisitor.h b/tools/qmltc/qmltcvisitor.h index 0ec9349527..c7d2990848 100644 --- a/tools/qmltc/qmltcvisitor.h +++ b/tools/qmltc/qmltcvisitor.h @@ -57,7 +57,7 @@ public: qsizetype creationIndex(const QQmlJSScope::ConstPtr &type) const { - Q_ASSERT(type->scopeType() == QQmlJSScope::QMLScope); + Q_ASSERT(type->scopeType() == QQmlSA::ScopeType::QMLScope); return m_creationIndices.value(type, -1); } @@ -68,13 +68,13 @@ public: qsizetype qmlComponentIndex(const QQmlJSScope::ConstPtr &type) const { - Q_ASSERT(type->scopeType() == QQmlJSScope::QMLScope); + Q_ASSERT(type->scopeType() == QQmlSA::ScopeType::QMLScope); return m_syntheticTypeIndices.value(type, -1); } qsizetype qmlIrObjectIndex(const QQmlJSScope::ConstPtr &type) const { - Q_ASSERT(type->scopeType() == QQmlJSScope::QMLScope); + Q_ASSERT(type->scopeType() == QQmlSA::ScopeType::QMLScope); Q_ASSERT(m_qmlIrObjectIndices.contains(type)); return m_qmlIrObjectIndices.value(type, -1); } |
