aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsimportvisitor_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-09 12:02:22 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-15 10:44:25 +0200
commit678d4ec4b68d43d0c748a8ec62a13716f83a27cf (patch)
tree863c228d5f0c46d494f2aee24e65f7ef21ee9e77 /src/qmlcompiler/qqmljsimportvisitor_p.h
parentf98c961da6d039621ae40ab6c1a79c4b06efb83f (diff)
Unify QQmlJSImportVisitor and FindWarningsVisitor
They are both pretty much doing the same thing, except that the import visitor is not as thorough. We need the full analysis in QtQmlCompiler, so we successively move the code over. Change-Id: If7fb47f88165fd8b61f4ccc408ccfbb7dad533e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor_p.h')
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor_p.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor_p.h b/src/qmlcompiler/qqmljsimportvisitor_p.h
index 8f0d937968..1d50881441 100644
--- a/src/qmlcompiler/qqmljsimportvisitor_p.h
+++ b/src/qmlcompiler/qqmljsimportvisitor_p.h
@@ -43,31 +43,51 @@
#include <private/qqmljsast_p.h>
#include <private/qqmljsdiagnosticmessage_p.h>
+#include <private/qqmljsimporter_p.h>
QT_BEGIN_NAMESPACE
class QQmlJSImportVisitor : public QQmlJS::AST::Visitor
{
public:
- QQmlJSScope::Ptr result(const QString &scopeName) const;
+ QQmlJSImportVisitor(QQmlJSImporter *importer, const QString &implicitImportDirectory,
+ const QStringList &qmltypesFiles = QStringList());
+
+ QQmlJSScope::Ptr result() const;
QList<QQmlJS::DiagnosticMessage> errors() const { return m_errors; }
-private:
+protected:
+ bool visit(QQmlJS::AST::UiProgram *) override;
bool visit(QQmlJS::AST::UiObjectDefinition *) override;
void endVisit(QQmlJS::AST::UiObjectDefinition *) override;
bool visit(QQmlJS::AST::UiPublicMember *) override;
- bool visit(QQmlJS::AST::UiSourceElement *) override;
bool visit(QQmlJS::AST::UiScriptBinding *) override;
bool visit(QQmlJS::AST::UiEnumDeclaration *uied) override;
+ bool visit(QQmlJS::AST::FunctionExpression *fexpr) override;
+ void endVisit(QQmlJS::AST::FunctionExpression *) override;
+ bool visit(QQmlJS::AST::FunctionDeclaration *fdecl) override;
+ void endVisit(QQmlJS::AST::FunctionDeclaration *) override;
+ bool visit(QQmlJS::AST::ClassExpression *ast) override;
+ void endVisit(QQmlJS::AST::ClassExpression *) override;
+ bool visit(QQmlJS::AST::UiImport *import) override;
void throwRecursionDepthError() override;
- QQmlJSScope::Ptr currentObject() const { return m_currentObjects.back(); }
-
- QVector<QQmlJSScope::Ptr> m_currentObjects;
- QQmlJSScope::ConstPtr m_rootObject;
- QHash<QString, QQmlJSScope::Ptr> m_objects;
+ QString m_implicitImportDirectory;
+ QStringList m_qmltypesFiles;
+ QQmlJSScope::Ptr m_currentScope;
+ QQmlJSScope::ConstPtr m_qmlRootScope;
+ QQmlJSScope::ConstPtr m_globalScope;
+ QHash<QString, QQmlJSScope::ConstPtr> m_scopesById;
+ QHash<QString, QQmlJSScope::ConstPtr> m_rootScopeImports;
+ QQmlJSImporter *m_importer;
QList<QQmlJS::DiagnosticMessage> m_errors;
+
+ void enterEnvironment(QQmlJSScope::ScopeType type, const QString &name);
+ void leaveEnvironment();
+
+private:
+ void visitFunctionExpressionHelper(QQmlJS::AST::FunctionExpression *fexpr);
};
QT_END_NAMESPACE