aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsscope_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-14 12:55:08 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-15 10:44:20 +0200
commitf98c961da6d039621ae40ab6c1a79c4b06efb83f (patch)
tree0eca1d6c2e19e54795da143ecb65279acd972572 /src/qmlcompiler/qqmljsscope_p.h
parented9ffa109eb2f242b59443ad430204a90c8028c4 (diff)
qmllint: Defer resolution of types read from QML files
When importing a directory we most likely don't need all of the files in the directory. Therefore we now parse them only when they are accessed. This speeds up the execution and will allow us to process imports recursively without running into infinite recursion. Change-Id: I0c79313de792249e6bb86144b5014a7787dbdc5b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsscope_p.h')
-rw-r--r--src/qmlcompiler/qqmljsscope_p.h41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h
index 4cf1d4cd6c..df7aad840d 100644
--- a/src/qmlcompiler/qqmljsscope_p.h
+++ b/src/qmlcompiler/qqmljsscope_p.h
@@ -40,6 +40,7 @@
// We mean it.
#include "qqmljsmetatypes_p.h"
+#include "qdeferredpointer_p.h"
#include <QtQml/private/qqmljssourcelocation_p.h>
@@ -52,15 +53,45 @@
QT_BEGIN_NAMESPACE
+class QQmlJSImporter;
+class QQmlJSScope;
+
+template<>
+class QDeferredFactory<QQmlJSScope>
+{
+public:
+ QDeferredFactory(QQmlJSImporter *importer, const QString &filePath) :
+ m_filePath(filePath), m_importer(importer)
+ {}
+
+ QQmlJSScope create() const;
+
+ bool isValid() const
+ {
+ return !m_filePath.isEmpty() && m_importer != nullptr;
+ }
+
+ void clear() {
+ m_filePath.clear();
+ m_importer = nullptr;
+ }
+
+private:
+ QString m_filePath;
+ QQmlJSImporter *m_importer = nullptr;
+};
class QQmlJSScope
{
- Q_DISABLE_COPY_MOVE(QQmlJSScope)
+ Q_DISABLE_COPY(QQmlJSScope)
public:
- using Ptr = QSharedPointer<QQmlJSScope>;
- using WeakPtr = QWeakPointer<QQmlJSScope>;
- using ConstPtr = QSharedPointer<const QQmlJSScope>;
- using WeakConstPtr = QWeakPointer<const QQmlJSScope>;
+ QQmlJSScope(QQmlJSScope &&) = default;
+ QQmlJSScope &operator=(QQmlJSScope &&) = default;
+
+ using Ptr = QDeferredSharedPointer<QQmlJSScope>;
+ using WeakPtr = QDeferredWeakPointer<QQmlJSScope>;
+ using ConstPtr = QDeferredSharedPointer<const QQmlJSScope>;
+ using WeakConstPtr = QDeferredWeakPointer<const QQmlJSScope>;
enum ScopeType
{