aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsloggingutils_p.h
diff options
context:
space:
mode:
authorOlivier De Cannière <[email protected]>2023-05-05 09:30:27 +0200
committerOlivier De Cannière <[email protected]>2023-05-30 13:42:35 +0200
commitcdd7fe05f676ed1664a156beaf63093237a3beac (patch)
tree8f7adccde1adc0e8404a96a895c5170b84f3f0cc /src/qmlcompiler/qqmljsloggingutils_p.h
parent65cb77165ba18442a524faf44f712ae26661965c (diff)
QQmlSA: Create an abstraction layer for static analysis
This patch adds abstractions for QML Elements, Bindings, Methods and Properties. This abstraction layer avoids exposing internal details and should be more suited for static analysis tasks. It is now possible to write qmllint plugins without including private headers. As a drive-by, change tst_qmllint:verifyJsRoot to open files in text mode instead of binary. This fixes an issue where line endings cause issues on Windows. Fixes: QTBUG-102276 Change-Id: I6b6e53f1e0078734a18f3aa51807fbe875b375f0 Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qmlcompiler/qqmljsloggingutils_p.h')
-rw-r--r--src/qmlcompiler/qqmljsloggingutils_p.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsloggingutils_p.h b/src/qmlcompiler/qqmljsloggingutils_p.h
new file mode 100644
index 0000000000..06957c2ad1
--- /dev/null
+++ b/src/qmlcompiler/qqmljsloggingutils_p.h
@@ -0,0 +1,73 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef QQMLJSLOGGINGUTILS_P_H
+#define QQMLJSLOGGINGUTILS_P_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 <private/qtqmlcompilerexports_p.h>
+
+#include "qqmljsloggingutils.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class LoggerCategoryPrivate
+{
+ friend class QT_PREPEND_NAMESPACE(QQmlJS::LoggerCategory);
+
+public:
+ LoggerWarningId id() const { return LoggerWarningId(m_name); }
+
+ void setLevel(QtMsgType);
+ void setIgnored(bool);
+
+ QString name() const;
+ QString settingsName() const;
+ QString description() const;
+ QtMsgType level() const;
+ bool isIgnored() const;
+ bool isDefault() const;
+ bool hasChanged() const;
+
+ static LoggerCategoryPrivate *get(LoggerCategory *);
+
+ friend bool operator==(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
+ {
+ return operatorEqualsImpl(lhs, rhs);
+ }
+ friend bool operator!=(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
+ {
+ return !operatorEqualsImpl(lhs, rhs);
+ }
+
+ bool operator==(const LoggerWarningId warningId) const { return warningId.name() == m_name; }
+
+private:
+ static bool operatorEqualsImpl(const LoggerCategoryPrivate &, const LoggerCategoryPrivate &);
+
+ QString m_name;
+ QString m_settingsName;
+ QString m_description;
+ QtMsgType m_level;
+ bool m_ignored = false;
+ bool m_isDefault = false; // Whether or not the category can be disabled
+ bool m_changed = false;
+};
+
+} // namespace QQmlJS
+
+QT_END_NAMESPACE
+
+#endif // QQMLJSLOGGINGUTILS_P_H