aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-08-04 14:57:29 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-08-05 11:44:41 +0200
commit8600202e7621164e30a28511ab92e926cba57d49 (patch)
tree3c4e8469b988f4b6d1d89a2dd778a157bb86706c
parent6901fb779a750949e0c436ff2fbfc15d0aae6319 (diff)
qmllint: Remove checkidentifiers
Since all of the warnings have been moved out of checkidentifiers we can now simply remove it. Change-Id: Ie59e306b69ca397c1e191a0fe379bc084f98cf73 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--tools/qmllint/CMakeLists.txt1
-rw-r--r--tools/qmllint/checkidentifiers.h72
-rw-r--r--tools/qmllint/findwarnings.cpp53
-rw-r--r--tools/qmllint/findwarnings.h8
4 files changed, 4 insertions, 130 deletions
diff --git a/tools/qmllint/CMakeLists.txt b/tools/qmllint/CMakeLists.txt
index fdfe0e4b2c..ba6eef92ef 100644
--- a/tools/qmllint/CMakeLists.txt
+++ b/tools/qmllint/CMakeLists.txt
@@ -9,7 +9,6 @@ qt_internal_add_tool(${target_name}
TARGET_DESCRIPTION "QML Syntax Verifier"
TOOLS_TARGET Qml # special case
SOURCES
- checkidentifiers.cpp checkidentifiers.h
findwarnings.cpp findwarnings.h
codegen.cpp codegen.h
codegenwarninginterface.cpp codegenwarninginterface.h
diff --git a/tools/qmllint/checkidentifiers.h b/tools/qmllint/checkidentifiers.h
deleted file mode 100644
index 81f86f7aeb..0000000000
--- a/tools/qmllint/checkidentifiers.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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 CHECKIDENTIFIERS_H
-#define CHECKIDENTIFIERS_H
-
-#include <QtQmlCompiler/private/qqmljslogger_p.h>
-#include <QtQmlCompiler/private/qqmljsscope_p.h>
-#include <QtQmlCompiler/private/qqmljsimporter_p.h>
-#include <QtQmlCompiler/private/qqmljsmetatypes_p.h>
-
-class QColorOutput;
-
-struct FieldMember
-{
- QString m_name;
- QString m_parentType;
- QQmlJS::SourceLocation m_location;
-};
-
-using MemberAccessChains = QHash<QQmlJSScope::ConstPtr, QVector<QVector<FieldMember>>>;
-
-class CheckIdentifiers
-{
-public:
- CheckIdentifiers(QQmlJSLogger *logger, const QString &code,
- const QQmlJSImporter::ImportedTypes &types, const QString &fileName) :
- m_logger(logger), m_code(code), m_types(types), m_fileName(fileName)
- {}
-
- void operator()(const QHash<QString, QQmlJSScope::ConstPtr> &qmlIDs,
- const QHash<QQmlJS::SourceLocation, QQmlJSMetaSignalHandler> &signalHandlers,
- const MemberAccessChains &memberAccessChains, const QQmlJSScope::ConstPtr &root,
- const QString &rootId) const;
-
-private:
- void checkMemberAccess(const QVector<FieldMember> &members,
- const QQmlJSScope::ConstPtr &outerScope,
- const QQmlJSMetaProperty *prop = nullptr) const;
-
- QQmlJSLogger *m_logger = nullptr;
- QString m_code;
- QQmlJSImporter::ImportedTypes m_types;
- QString m_fileName;
-};
-
-#endif // CHECKIDENTIFIERS_H
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 1e222b4716..baa5950641 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "findwarnings.h"
-#include "checkidentifiers.h"
#include <QtQmlCompiler/private/qqmljsscope_p.h>
#include <QtQmlCompiler/private/qqmljstypedescriptionreader_p.h>
@@ -139,9 +138,6 @@ bool FindWarningVisitor::visit(QQmlJS::AST::IdentifierExpression *idexp)
m_usedTypes.insert(name);
}
- m_memberAccessChains[m_currentScope].append(
- {{name, QString(), idexp->firstSourceLocation()}});
- m_fieldMemberBase = idexp;
return true;
}
@@ -249,9 +245,6 @@ bool FindWarningVisitor::check()
outstandingConnection.uiod->initializer->accept(this);
}
- CheckIdentifiers check(&m_logger, m_code, m_rootScopeImports, m_filePath);
- check(m_scopesById, m_signalHandlers, m_memberAccessChains, m_globalScope, m_rootId);
-
return !m_logger.hasWarnings() && !m_logger.hasErrors();
}
@@ -276,47 +269,9 @@ bool FindWarningVisitor::visit(QQmlJS::AST::PatternElement *element)
void FindWarningVisitor::endVisit(QQmlJS::AST::FieldMemberExpression *fieldMember)
{
- using namespace QQmlJS::AST;
- ExpressionNode *base = fieldMember->base;
-
- while (auto *nested = cast<NestedExpression *>(base))
- base = nested->expression;
-
- if (m_fieldMemberBase == base) {
- QString type;
- if (auto *binary = cast<BinaryExpression *>(base)) {
- if (binary->op == QSOperator::As) {
- if (auto *right = cast<TypeExpression *>(binary->right))
- type = right->m_type->toString();
- }
- }
-
-
- auto &chain = m_memberAccessChains[m_currentScope];
-
- Q_ASSERT(!chain.last().isEmpty());
-
- const QString name = fieldMember->name.toString();
- if (m_importTypeLocationMap.contains(name)) {
- if (auto it = m_rootScopeImports.find(name); it != m_rootScopeImports.end() && !*(it))
- m_usedTypes.insert(name);
- }
-
- chain.last().append(FieldMember {
- name, type, fieldMember->identifierToken
- });
- m_fieldMemberBase = fieldMember;
- } else {
- m_fieldMemberBase = nullptr;
- }
-}
-
-void FindWarningVisitor::endVisit(QQmlJS::AST::BinaryExpression *binExp)
-{
- if (binExp->op == QSOperator::As
- && (m_fieldMemberBase == binExp->left || m_fieldMemberBase == binExp->right)) {
- m_fieldMemberBase = binExp;
- } else {
- m_fieldMemberBase = nullptr;
+ const QString name = fieldMember->name.toString();
+ if (m_importTypeLocationMap.contains(name)) {
+ if (auto it = m_rootScopeImports.find(name); it != m_rootScopeImports.end() && !*(it))
+ m_usedTypes.insert(name);
}
}
diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h
index b558bcb2c2..bff8cd1f26 100644
--- a/tools/qmllint/findwarnings.h
+++ b/tools/qmllint/findwarnings.h
@@ -39,8 +39,6 @@
//
// We mean it.
-#include "checkidentifiers.h"
-
#include <QtQmlCompiler/private/qcoloroutput_p.h>
#include <QtQmlCompiler/private/qqmljstypedescriptionreader_p.h>
#include <QtQmlCompiler/private/qqmljsscope_p.h>
@@ -64,10 +62,6 @@ public:
bool check();
private:
- MemberAccessChains m_memberAccessChains;
-
- QQmlJS::AST::ExpressionNode *m_fieldMemberBase = nullptr;
-
void parseComments(const QList<QQmlJS::SourceLocation> &comments);
// work around compiler error in clang11
@@ -82,8 +76,6 @@ private:
bool visit(QQmlJS::AST::PatternElement *) override;
void endVisit(QQmlJS::AST::FieldMemberExpression *) override;
-
- void endVisit(QQmlJS::AST::BinaryExpression *) override;
};
#endif // FINDUNQUALIFIED_H