diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-06-22 18:38:43 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-06-24 18:28:20 +0200 |
commit | 437b04e6ec5c767907a97af115d82b4cd7db93ae (patch) | |
tree | 6a6cb79149488e214a0068e69f9580ea3a5b572d /tools/qmllint/findwarnings.h | |
parent | 36df81b3bc6d721d5598d5163b0a9659de4a69ee (diff) |
qmllint: Properly process qmldir imports and dependencies
We don't want to pick the dependencies from the qmltypes files. Rather,
parse them directly from the qmldir. Do process versions, too.
Also, import explicitly given qmltypes files only once, and don't expose
QML types from dependencies as actual types. Hide them behind an
inaccessible prefix.
For the inaccessible prefix to work, we need to import the C++ class
names without the prefix. The prefix doesn't make sense for C++ names
anyway.
In addition, properly process version-less imports.
Change-Id: If582ad271db35351d219332c319571a814628fe0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint/findwarnings.h')
-rw-r--r-- | tools/qmllint/findwarnings.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h index ee019b440d..87423db589 100644 --- a/tools/qmllint/findwarnings.h +++ b/tools/qmllint/findwarnings.h @@ -43,6 +43,7 @@ #include "scopetree.h" #include "qcoloroutput.h" +#include <QtQml/private/qqmldirparser_p.h> #include <QtQml/private/qqmljsastvisitor_p.h> #include <QtQml/private/qqmljsast_p.h> @@ -52,25 +53,25 @@ class FindWarningVisitor : public QQmlJS::AST::Visitor { Q_DISABLE_COPY_MOVE(FindWarningVisitor) public: - explicit FindWarningVisitor(QStringList qmltypeDirs, QStringList qmltypeFiles, QString code, - QString fileName, bool silent, bool warnUnqualified, - bool warnWithStatement, bool warnInheritanceCycle); + explicit FindWarningVisitor( + QStringList qmltypeDirs, QStringList qmltypesFiles, QString code, QString fileName, + bool silent, bool warnUnqualified, bool warnWithStatement, bool warnInheritanceCycle); ~FindWarningVisitor() override = default; bool check(); private: struct Import { QHash<QString, ScopeTree::ConstPtr> objects; - QStringList dependencies; + QList<QQmlDirParser::Import> imports; + QList<QQmlDirParser::Component> dependencies; }; ScopeTree::Ptr m_rootScope; ScopeTree::Ptr m_currentScope; QQmlJS::AST::ExpressionNode *m_fieldMemberBase = nullptr; - QHash<QString, ScopeTree::ConstPtr> m_types; QHash<QString, ScopeTree::ConstPtr> m_exportedName2Scope; - QStringList m_qmltypeDirs; - QStringList m_qmltypeFiles; + QStringList m_qmltypesDirs; + QStringList m_qmltypesFiles; QString m_code; QHash<QString, ScopeTree::ConstPtr> m_qmlid2scope; QString m_rootId; @@ -95,13 +96,14 @@ private: void enterEnvironment(ScopeType type, const QString &name); void leaveEnvironment(); + + void importBareQmlTypes(); void importHelper(const QString &module, const QString &prefix = QString(), QTypeRevision version = QTypeRevision()); - void readQmltypes(const QString &filename, QHash<QString, ScopeTree::ConstPtr> *objects, - QStringList *dependencies); + void readQmltypes(const QString &filename, QHash<QString, ScopeTree::ConstPtr> *objects); Import readQmldir(const QString &dirname); - void processImport(const QString &prefix, const Import &import); + void processImport(const QString &prefix, const Import &import, QTypeRevision version); ScopeTree::Ptr localFile2ScopeTree(const QString &filePath); |