aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-30 11:02:53 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-02 15:33:04 +0200
commitb078890608344f0556a0ff50aab62ede83e0e180 (patch)
tree75e811d2f3062f05dca2396d34a06363d5bdb322 /tools
parent85dd91f27b16fabe04575bd3b01bccc44b43d43f (diff)
qmllint: Remove ComponentVersion
QTypeRevision does all we need there. Change-Id: Ib27ae2d58167a7a45fac31262a45e387d047af89 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/.prev_CMakeLists.txt1
-rw-r--r--tools/qmllint/CMakeLists.txt1
-rw-r--r--tools/shared/componentversion.cpp80
-rw-r--r--tools/shared/componentversion.h66
-rw-r--r--tools/shared/qmljsimporter.cpp4
-rw-r--r--tools/shared/scopetree.cpp5
-rw-r--r--tools/shared/scopetree.h8
-rw-r--r--tools/shared/shared.pri2
-rw-r--r--tools/shared/typedescriptionreader.cpp25
-rw-r--r--tools/shared/typedescriptionreader.h2
10 files changed, 28 insertions, 166 deletions
diff --git a/tools/qmllint/.prev_CMakeLists.txt b/tools/qmllint/.prev_CMakeLists.txt
index cf5dc7e28e..3034d8699f 100644
--- a/tools/qmllint/.prev_CMakeLists.txt
+++ b/tools/qmllint/.prev_CMakeLists.txt
@@ -8,7 +8,6 @@ qt_get_tool_target_name(target_name qmllint)
qt_add_tool(${target_name}
TARGET_DESCRIPTION "QML Syntax Verifier"
SOURCES
- ../shared/componentversion.cpp ../shared/componentversion.h
../shared/importedmembersvisitor.cpp ../shared/importedmembersvisitor.h
../shared/metatypes.h
../shared/qmljsimporter.cpp ../shared/qmljsimporter.h
diff --git a/tools/qmllint/CMakeLists.txt b/tools/qmllint/CMakeLists.txt
index ba4cd62e65..e9d92cc134 100644
--- a/tools/qmllint/CMakeLists.txt
+++ b/tools/qmllint/CMakeLists.txt
@@ -9,7 +9,6 @@ qt_add_tool(${target_name}
TARGET_DESCRIPTION "QML Syntax Verifier"
TOOLS_TARGET Qml # special case
SOURCES
- ../shared/componentversion.cpp ../shared/componentversion.h
../shared/importedmembersvisitor.cpp ../shared/importedmembersvisitor.h
../shared/metatypes.h
../shared/qmljsimporter.cpp ../shared/qmljsimporter.h
diff --git a/tools/shared/componentversion.cpp b/tools/shared/componentversion.cpp
deleted file mode 100644
index 5019cdcc33..0000000000
--- a/tools/shared/componentversion.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "componentversion.h"
-#include <QtCore/qstring.h>
-
-ComponentVersion::ComponentVersion(const QString &versionString)
-{
- const int dotIdx = versionString.indexOf(QLatin1Char('.'));
- if (dotIdx == -1)
- return;
- bool ok = false;
- const int maybeMajor = QStringView{versionString}.left(dotIdx).toInt(&ok);
- if (!ok)
- return;
- const int maybeMinor = QStringView{versionString}.mid(dotIdx + 1).toInt(&ok);
- if (!ok)
- return;
- m_version = QTypeRevision::fromVersion(maybeMajor, maybeMinor);
-}
-
-bool operator<(const ComponentVersion &lhs, const ComponentVersion &rhs)
-{
- return lhs.version().majorVersion() < rhs.version().majorVersion()
- || (lhs.version().majorVersion() == rhs.version().majorVersion()
- && lhs.version().minorVersion() < rhs.version().minorVersion());
-}
-
-bool operator<=(const ComponentVersion &lhs, const ComponentVersion &rhs)
-{
- return lhs.version().majorVersion() < rhs.version().majorVersion()
- || (lhs.version().majorVersion() == rhs.version().majorVersion()
- && lhs.version().minorVersion() <= rhs.version().minorVersion());
-}
-
-bool operator>(const ComponentVersion &lhs, const ComponentVersion &rhs)
-{
- return rhs < lhs;
-}
-
-bool operator>=(const ComponentVersion &lhs, const ComponentVersion &rhs)
-{
- return rhs <= lhs;
-}
-
-bool operator==(const ComponentVersion &lhs, const ComponentVersion &rhs)
-{
- return lhs.version().majorVersion() == rhs.version().majorVersion()
- && lhs.version().minorVersion() == rhs.version().minorVersion();
-}
-
-bool operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs)
-{
- return !(lhs == rhs);
-}
diff --git a/tools/shared/componentversion.h b/tools/shared/componentversion.h
deleted file mode 100644
index bbb039fc40..0000000000
--- a/tools/shared/componentversion.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef COMPONENTVERSION_H
-#define COMPONENTVERSION_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qversionnumber.h>
-
-class ComponentVersion
-{
-public:
- ComponentVersion() = default;
- ComponentVersion(QTypeRevision version) : m_version(version) {}
- explicit ComponentVersion(const QString &versionString);
-
- QTypeRevision version() const { return m_version; }
- bool isValid() const { return m_version.hasMajorVersion() && m_version.hasMinorVersion(); }
-
-private:
- QTypeRevision m_version;
-};
-
-bool operator<(const ComponentVersion &lhs, const ComponentVersion &rhs);
-bool operator<=(const ComponentVersion &lhs, const ComponentVersion &rhs);
-bool operator>(const ComponentVersion &lhs, const ComponentVersion &rhs);
-bool operator>=(const ComponentVersion &lhs, const ComponentVersion &rhs);
-bool operator==(const ComponentVersion &lhs, const ComponentVersion &rhs);
-bool operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs);
-
-#endif // COMPONENTVERSION_H
diff --git a/tools/shared/qmljsimporter.cpp b/tools/shared/qmljsimporter.cpp
index b7de18e818..f2e8453c7c 100644
--- a/tools/shared/qmljsimporter.cpp
+++ b/tools/shared/qmljsimporter.cpp
@@ -98,9 +98,7 @@ QmlJSImporter::Import QmlJSImporter::readQmldir(const QString &path)
if (mo == qmlComponents.end())
mo = qmlComponents.insert(it.key(), localFile2ScopeTree(filePath));
- (*mo)->addExport(
- it.key(), reader.typeNamespace(),
- ComponentVersion(it->version));
+ (*mo)->addExport(it.key(), reader.typeNamespace(), it->version);
}
for (auto it = qmlComponents.begin(), end = qmlComponents.end(); it != end; ++it)
result.objects.insert(it.key(), it.value());
diff --git a/tools/shared/scopetree.cpp b/tools/shared/scopetree.cpp
index f55fd7d845..e7ce631b1d 100644
--- a/tools/shared/scopetree.cpp
+++ b/tools/shared/scopetree.cpp
@@ -168,8 +168,7 @@ ScopeTree::ConstPtr ScopeTree::findCurrentQMLScope(const ScopeTree::ConstPtr &sc
return qmlScope;
}
-void ScopeTree::addExport(const QString &name, const QString &package,
- const ComponentVersion &version)
+void ScopeTree::addExport(const QString &name, const QString &package, const QTypeRevision &version)
{
m_exports.append(Export(package, name, version, 0));
}
@@ -179,7 +178,7 @@ void ScopeTree::setExportMetaObjectRevision(int exportIndex, int metaObjectRevis
m_exports[exportIndex].setMetaObjectRevision(metaObjectRevision);
}
-ScopeTree::Export::Export(QString package, QString type, const ComponentVersion &version,
+ScopeTree::Export::Export(QString package, QString type, const QTypeRevision &version,
int metaObjectRevision) :
m_package(std::move(package)),
m_type(std::move(type)),
diff --git a/tools/shared/scopetree.h b/tools/shared/scopetree.h
index d87422224c..37eee26d16 100644
--- a/tools/shared/scopetree.h
+++ b/tools/shared/scopetree.h
@@ -40,13 +40,13 @@
// We mean it.
#include "metatypes.h"
-#include "componentversion.h"
#include <QtQml/private/qqmljssourcelocation_p.h>
#include <QtCore/qset.h>
#include <QtCore/qhash.h>
#include <QtCore/qstring.h>
+#include <QtCore/qversionnumber.h>
enum class ScopeType
{
@@ -88,7 +88,7 @@ public:
class Export {
public:
Export() = default;
- Export(QString package, QString type, const ComponentVersion &version,
+ Export(QString package, QString type, const QTypeRevision &version,
int metaObjectRevision);
bool isValid() const;
@@ -105,7 +105,7 @@ public:
private:
QString m_package;
QString m_type;
- ComponentVersion m_version;
+ QTypeRevision m_version;
int m_metaObjectRevision = 0;
};
@@ -145,7 +145,7 @@ public:
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 addExport(const QString &name, const QString &package, const QTypeRevision &version);
void setExportMetaObjectRevision(int exportIndex, int metaObjectRevision);
QList<Export> exports() const { return m_exports; }
diff --git a/tools/shared/shared.pri b/tools/shared/shared.pri
index b7eb2ec6c1..181cda3e8b 100644
--- a/tools/shared/shared.pri
+++ b/tools/shared/shared.pri
@@ -10,7 +10,6 @@ RESOURCEFILEMAPPER_HEADERS = \
$$PWD/resourcefilemapper.h
METATYPEREADER_SOURCES = \
- $$PWD/componentversion.cpp \
$$PWD/importedmembersvisitor.cpp \
$$PWD/qmljsimporter.cpp \
$$PWD/qmljstypereader.cpp \
@@ -18,7 +17,6 @@ METATYPEREADER_SOURCES = \
$$PWD/typedescriptionreader.cpp
METATYPEREADER_HEADERS = \
- $$PWD/componentversion.h \
$$PWD/importedmembersvisitor.h \
$$PWD/qmljsimporter.h \
$$PWD/qmljstypereader.h \
diff --git a/tools/shared/typedescriptionreader.cpp b/tools/shared/typedescriptionreader.cpp
index 3691fa080c..f95e4453b3 100644
--- a/tools/shared/typedescriptionreader.cpp
+++ b/tools/shared/typedescriptionreader.cpp
@@ -492,9 +492,24 @@ double TypeDescriptionReader::readNumericBinding(UiScriptBinding *ast)
return numericLit->value;
}
-ComponentVersion TypeDescriptionReader::readNumericVersionBinding(UiScriptBinding *ast)
+static QTypeRevision parseVersion(const QString &versionString)
{
- ComponentVersion invalidVersion;
+ const int dotIdx = versionString.indexOf(QLatin1Char('.'));
+ if (dotIdx == -1)
+ return QTypeRevision();
+ bool ok = false;
+ const int maybeMajor = QStringView{versionString}.left(dotIdx).toInt(&ok);
+ if (!ok)
+ return QTypeRevision();
+ const int maybeMinor = QStringView{versionString}.mid(dotIdx + 1).toInt(&ok);
+ if (!ok)
+ return QTypeRevision();
+ return QTypeRevision::fromVersion(maybeMajor, maybeMinor);
+}
+
+QTypeRevision TypeDescriptionReader::readNumericVersionBinding(UiScriptBinding *ast)
+{
+ QTypeRevision invalidVersion;
if (!ast || !ast->statement) {
addError((ast ? ast->colonToken : SourceLocation()),
@@ -515,8 +530,8 @@ ComponentVersion TypeDescriptionReader::readNumericVersionBinding(UiScriptBindin
return invalidVersion;
}
- return ComponentVersion(m_source.mid(numericLit->literalToken.begin(),
- numericLit->literalToken.length));
+ return parseVersion(m_source.mid(numericLit->literalToken.begin(),
+ numericLit->literalToken.length));
}
int TypeDescriptionReader::readIntBinding(UiScriptBinding *ast)
@@ -564,7 +579,7 @@ void TypeDescriptionReader::readExports(UiScriptBinding *ast, const ScopeTree::P
QString exp = stringLit->value.toString();
int slashIdx = exp.indexOf(QLatin1Char('/'));
int spaceIdx = exp.indexOf(QLatin1Char(' '));
- ComponentVersion version(exp.mid(spaceIdx + 1));
+ const QTypeRevision version = parseVersion(exp.mid(spaceIdx + 1));
if (spaceIdx == -1 || !version.isValid()) {
addError(stringLit->firstSourceLocation(),
diff --git a/tools/shared/typedescriptionreader.h b/tools/shared/typedescriptionreader.h
index bf0fd43eae..8395f09bc4 100644
--- a/tools/shared/typedescriptionreader.h
+++ b/tools/shared/typedescriptionreader.h
@@ -75,7 +75,7 @@ private:
QString readStringBinding(QQmlJS::AST::UiScriptBinding *ast);
bool readBoolBinding(QQmlJS::AST::UiScriptBinding *ast);
double readNumericBinding(QQmlJS::AST::UiScriptBinding *ast);
- ComponentVersion readNumericVersionBinding(QQmlJS::AST::UiScriptBinding *ast);
+ QTypeRevision readNumericVersionBinding(QQmlJS::AST::UiScriptBinding *ast);
int readIntBinding(QQmlJS::AST::UiScriptBinding *ast);
void readExports(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope);
void readMetaObjectRevisions(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope);