diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-09-25 09:50:09 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-09-25 15:21:41 +0200 |
commit | 5a88c06665d5c0295691e216740210a5172fcc9e (patch) | |
tree | 76d61e5749420afd57f7a01939502fc593afd9f3 /tools/shared | |
parent | 88fd9c3996fd0280be639ad116ebc3a1b30ae0c4 (diff) |
qmllint: Clarify the meaning of the various names a scope can have
... and notice that they are misused everywhere.
Change-Id: I2254993dc5d11e967e7e83c6f0efb37fa17744be
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/shared')
-rw-r--r-- | tools/shared/importedmembersvisitor.cpp | 6 | ||||
-rw-r--r-- | tools/shared/scopetree.h | 16 | ||||
-rw-r--r-- | tools/shared/typedescriptionreader.cpp | 10 |
3 files changed, 18 insertions, 14 deletions
diff --git a/tools/shared/importedmembersvisitor.cpp b/tools/shared/importedmembersvisitor.cpp index 0806e27aea..559c0533f7 100644 --- a/tools/shared/importedmembersvisitor.cpp +++ b/tools/shared/importedmembersvisitor.cpp @@ -35,8 +35,8 @@ ScopeTree::Ptr ImportedMembersVisitor::result(const QString &scopeName) const { ScopeTree::Ptr result = ScopeTree::create(); result->setIsComposite(true); - result->setClassName(scopeName); - result->setSuperclassName(m_rootObject->superclassName()); + result->setInternalName(scopeName); + result->setBaseTypeName(m_rootObject->baseTypeName()); const auto properties = m_rootObject->properties(); for (auto property : properties) { if (property.isAlias()) { @@ -67,7 +67,7 @@ bool ImportedMembersVisitor::visit(UiObjectDefinition *definition) superType.append(u'.'); superType.append(segment->name.toString()); } - scope->setSuperclassName(superType); + scope->setBaseTypeName(superType); if (!m_rootObject) m_rootObject = scope; m_currentObjects.append(scope); diff --git a/tools/shared/scopetree.h b/tools/shared/scopetree.h index 08d529acc9..f505ed7457 100644 --- a/tools/shared/scopetree.h +++ b/tools/shared/scopetree.h @@ -143,15 +143,19 @@ public: QString fileName() const { return m_fileName; } void setFileName(const QString &file) { m_fileName = file; } - QString className() const { return m_className; } - void setClassName(const QString &name) { m_className = name; } + // The name the type uses to refer to itself. Either C++ class name or base name of + // QML file. isComposite tells us if this is a C++ or a QML name. + QString internalName() const { return m_internalName; } + void setInternalName(const QString &internalName) { m_internalName = internalName; } void addExport(const QString &name, const QString &package, const ComponentVersion &version); void setExportMetaObjectRevision(int exportIndex, int metaObjectRevision); QList<Export> exports() const { return m_exports; } - void setSuperclassName(const QString &superclass) { m_superName = superclass; } - QString superclassName() const { return m_superName; } + // If isComposite(), this is the QML/JS name of the prototype. Otherwise it's the + // relevant base class (in the hierarchy starting from QObject) of a C++ type. + void setBaseTypeName(const QString &baseTypeName) { m_baseTypeName = baseTypeName; } + QString baseTypeName() const { return m_baseTypeName; } void addProperty(const MetaProperty &prop) { m_properties.insert(prop.propertyName(), prop); } QHash<QString, MetaProperty> properties() const { return m_properties; } @@ -223,8 +227,8 @@ private: QString m_fileName; QString m_name; - QString m_className; - QString m_superName; + QString m_internalName; + QString m_baseTypeName; ScopeType m_scopeType = ScopeType::QMLScope; QList<Export> m_exports; diff --git a/tools/shared/typedescriptionreader.cpp b/tools/shared/typedescriptionreader.cpp index ae2e481397..717dbdf843 100644 --- a/tools/shared/typedescriptionreader.cpp +++ b/tools/shared/typedescriptionreader.cpp @@ -211,9 +211,9 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast) if (name == QLatin1String("file")) { scope->setFileName(readStringBinding(script)); } else if (name == QLatin1String("name")) { - scope->setClassName(readStringBinding(script)); + scope->setInternalName(readStringBinding(script)); } else if (name == QLatin1String("prototype")) { - scope->setSuperclassName(readStringBinding(script)); + scope->setBaseTypeName(readStringBinding(script)); } else if (name == QLatin1String("defaultProperty")) { scope->setDefaultPropertyName(readStringBinding(script)); } else if (name == QLatin1String("exports")) { @@ -252,14 +252,14 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast) } } - if (scope->className().isEmpty()) { + if (scope->internalName().isEmpty()) { addError(ast->firstSourceLocation(), tr("Component definition is missing a name binding.")); return; } // ### add implicit export into the package of c++ types - scope->addExport(scope->className(), QStringLiteral("<cpp>"), ComponentVersion()); - m_objects->insert(scope->className(), scope); + scope->addExport(scope->internalName(), QStringLiteral("<cpp>"), ComponentVersion()); + m_objects->insert(scope->internalName(), scope); } void TypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isMethod, |