aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-01-25 20:59:28 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-31 12:41:54 +0000
commit7affa153181c9fa08301ac08c04f7d886714924f (patch)
tree122b798f29cb14801ab0bd2bdf5ea5c9c770f348
parent802f081151b6fc188db5974ff7cd2e1e6337a691 (diff)
qmltc: Drop half-correct type name collecting procedure
Type resolver can collect (presumably C++) type names which is needed to verify that the QML document we are about to compile is named correctly and does not have name conflicts However, the collection logic gathers everything we can find: C++ names, QML names, names marked with $anonymous$ or under import namespace. At the same time, the way the procedure works involves poking (pretty much) every known QQmlJSScope a.k.a. creates every type (previously some could've been deferred) which usually means that we have a larger than necessary footprint Thus, delete this procedure and simplify the code. We can later revisit the logic and figure the proper way to collect relevant type names. For now this is just overkill though. Note that this change, consequently, should avoid instantiating types imported from implicit import dir, instead of imported from qmldir (there is a difference apparently) Task-number: QTBUG-100103 Change-Id: Iaf65e5f3a9bf53286760af0dc39a1d7036d7c474 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 25b26452018bde9c569e39e1fd776d25a5412d02) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tools/qmltc/prototype/qml2cppdefaultpasses.cpp7
-rw-r--r--tools/qmltc/prototype/typeresolver.h24
2 files changed, 0 insertions, 31 deletions
diff --git a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
index 13ce81202c..870f94359a 100644
--- a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
+++ b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
@@ -506,23 +506,16 @@ QHash<QString, qsizetype> makeUniqueCppNames(const Qml2CppContext &context,
QHash<QString, qsizetype> typeCounts;
for (const QString &str : cppKeywords)
typeCounts.insert(str, 1);
- const auto knownCppNames = context.typeResolver->gatherKnownCppClassNames();
- for (const QString &str : knownCppNames)
- typeCounts.insert(str, 1);
// root is special:
QQmlJSScope::Ptr root = context.typeResolver->root();
QFileInfo fi(context.documentUrl);
auto cppName = fi.baseName();
- // TODO: root is special and with implicit import directory cppName might be
- // in typeCounts.
-#if 0
if (typeCounts.contains(cppName)) {
context.recordError(root->sourceLocation(),
u"Root object name '" + cppName + u"' is reserved");
return typeCounts;
}
-#endif
if (cppName.isEmpty()) {
context.recordError(root->sourceLocation(), u"Root object's name is empty"_qs);
return typeCounts;
diff --git a/tools/qmltc/prototype/typeresolver.h b/tools/qmltc/prototype/typeresolver.h
index fc8e1c70eb..a382c4c07a 100644
--- a/tools/qmltc/prototype/typeresolver.h
+++ b/tools/qmltc/prototype/typeresolver.h
@@ -42,30 +42,6 @@ class TypeResolver : public QQmlJSTypeResolver
public:
TypeResolver(QQmlJSImporter *importer);
- // helper function for code generator
- QStringList gatherKnownCppClassNames() const
- {
- QStringList cppNames;
- QQmlJSImporter::ImportedTypes builtins = m_importer->builtinInternalNames();
- cppNames.reserve(builtins.size() + m_imports.size());
- const auto getInternalName = [](const QQmlJSImportedScope &t) {
- if (!t.scope)
- return QString();
- return t.scope->internalName();
- };
- std::transform(builtins.cbegin(), builtins.cend(), std::back_inserter(cppNames),
- getInternalName);
-
- // builtins must be valid: all QQmlJSScopes are not nullptr and have
- // non-empty internal names. m_imports may have nullptrs, due to import
- // namespaces
- Q_ASSERT(std::find(cppNames.cbegin(), cppNames.cend(), QString()) == cppNames.cend());
-
- std::transform(m_imports.cbegin(), m_imports.cend(), std::back_inserter(cppNames),
- getInternalName);
- return cppNames;
- }
-
void init(Visitor &visitor, QQmlJS::AST::Node *program);
// TODO: this shouldn't be exposed. instead, all the custom passes on