Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
quicklintplugin.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QUICKLINTPLUGIN_H
5#define QUICKLINTPLUGIN_H
6
7#include <QtCore/qplugin.h>
8#include <QtCore/qlist.h>
9#include <QtCore/qvarlengtharray.h>
10#include <QtCore/qhash.h>
11
12#include <QtQmlCompiler/qqmlsa.h>
13#include "qqmlsaconstants.h"
14
16
18{
19 QString module;
21};
22
24{
28
29public:
30 void registerPasses(QQmlSA::PassManager *manager, const QQmlSA::Element &rootElement) override;
31};
32
34{
35public:
37
38 void addWarning(QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName,
40 bool shouldRun(const QQmlSA::Element &element) override;
41 void run(const QQmlSA::Element &element) override;
42
43private:
44 struct Warning
45 {
46 QString propertyName;
48 };
49
50 QHash<QQmlSA::Element, QVarLengthArray<Warning, 8>> m_types;
51};
52
54{
55public:
57
58 QString addWarning(TypeDescription attachType, QList<TypeDescription> allowedTypes,
59 bool allowInDelegate, QAnyStringView warning);
60
61 void onBinding(const QQmlSA::Element &element, const QString &propertyName,
62 const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope,
63 const QQmlSA::Element &value) override;
64 void onRead(const QQmlSA::Element &element, const QString &propertyName,
65 const QQmlSA::Element &readScope, QQmlSA::SourceLocation location) override;
66 void onWrite(const QQmlSA::Element &element, const QString &propertyName,
67 const QQmlSA::Element &value, const QQmlSA::Element &writeScope,
69
70private:
71 void checkWarnings(const QQmlSA::Element &element, const QQmlSA::Element &scopeUsedIn,
73
74 struct Warning
75 {
76 QVarLengthArray<QQmlSA::Element, 4> allowedTypes;
77 bool allowInDelegate = false;
79 };
80 QHash<QString, Warning> m_attachedTypes;
81};
82
84{
85public:
87
88 bool shouldRun(const QQmlSA::Element &element) override;
89 void run(const QQmlSA::Element &element) override;
90
91private:
92 struct ControlElement
93 {
95 QStringList restrictedProperties;
96 bool isInModuleControls = true;
97 bool isControl = false;
98 bool inheritsControl = false;
99 QQmlSA::Element element = {};
100 };
101
102 QList<ControlElement> m_elements;
103};
104
106{
107public:
109
110 bool shouldRun(const QQmlSA::Element &element) override;
111 void run(const QQmlSA::Element &element) override;
112
113private:
114 QQmlSA::Element m_item;
115};
116
118{
119public:
121
122 bool shouldRun(const QQmlSA::Element &element) override;
123 void run(const QQmlSA::Element &element) override;
124
125private:
126 QQmlSA::Element m_swipeDelegate;
127};
128
130{
131public:
133 const QMultiHash<QString, TypeDescription> &expectedPropertyTypes);
134
135 void onBinding(const QQmlSA::Element &element, const QString &propertyName,
136 const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope,
137 const QQmlSA::Element &value) override;
138
139private:
140 QMultiHash<QString, QQmlSA::Element> m_expectedPropertyTypes;
141};
142
144{
145public:
147
148 bool shouldRun(const QQmlSA::Element &element) override;
149 void run(const QQmlSA::Element &element) override;
150
151private:
152 QQmlSA::Element m_propertyChanges;
153};
154
156{
157public:
162
166
167 void onRead(const QQmlSA::Element &element, const QString &propertyName,
168 const QQmlSA::Element &readScope, QQmlSA::SourceLocation location) override;
169 void onWrite(const QQmlSA::Element &element, const QString &propertyName,
170 const QQmlSA::Element &value, const QQmlSA::Element &writeScope,
172
173private:
174 struct ElementAndLocation {
175 QQmlSA::Element element;
177 };
178
179 QMultiHash<QQmlSA::Element, ElementAndLocation> usedAttachedTypes;
181};
182
184
185#endif // QUICKLINTPLUGIN_H
bool shouldRun(const QQmlSA::Element &element) override
Controls whether the run() function should be executed on the given element.
AnchorsValidatorPass(QQmlSA::PassManager *manager)
void run(const QQmlSA::Element &element) override
Executes if shouldRun() returns true.
void onRead(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &readScope, QQmlSA::SourceLocation location) override
Executes whenever a property is read.
AttachedPropertyReuse(QQmlSA::PassManager *manager, QQmlSA::LoggerWarningId category)
void onWrite(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &value, const QQmlSA::Element &writeScope, QQmlSA::SourceLocation location) override
Executes whenever a property is written to.
void onRead(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &readScope, QQmlSA::SourceLocation location) override
Executes whenever a property is read.
AttachedPropertyTypeValidatorPass(QQmlSA::PassManager *manager)
void onWrite(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &value, const QQmlSA::Element &writeScope, QQmlSA::SourceLocation location) override
Executes whenever a property is written to.
void onBinding(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, const QQmlSA::Element &value) override
Executes whenever a property gets bound to a value.
QString addWarning(TypeDescription attachType, QList< TypeDescription > allowedTypes, bool allowInDelegate, QAnyStringView warning)
ControlsNativeValidatorPass(QQmlSA::PassManager *manager)
void run(const QQmlSA::Element &element) override
Executes if shouldRun() returns true.
bool shouldRun(const QQmlSA::Element &element) override
Controls whether the run() function should be executed on the given element.
bool shouldRun(const QQmlSA::Element &element) override
Controls whether the run() function should be executed on the given element.
ControlsSwipeDelegateValidatorPass(QQmlSA::PassManager *manager)
void run(const QQmlSA::Element &element) override
Executes if shouldRun() returns true.
void addWarning(QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName, QAnyStringView warning)
ForbiddenChildrenPropertyValidatorPass(QQmlSA::PassManager *manager)
void run(const QQmlSA::Element &element) override
Executes if shouldRun() returns true.
bool shouldRun(const QQmlSA::Element &element) override
Controls whether the run() function should be executed on the given element.
void run(const QQmlSA::Element &element) override
Executes if shouldRun() returns true.
PropertyChangesValidatorPass(QQmlSA::PassManager *manager)
bool shouldRun(const QQmlSA::Element &element) override
Controls whether the run() function should be executed on the given element.
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtQmlCompiler
Definition qqmlsa.h:52
\inmodule QtQmlCompiler
Definition qqmlsa.h:357
\inmodule QtQmlCompiler
Definition qqmlsa.h:193
\inmodule QtQmlCompiler
Definition qqmlsa.h:331
\inmodule QtQmlCompiler
\inmodule QtQmlCompiler
Definition qqmlsa.h:303
\inmodule QtQmlCompiler
Definition qqmlsa.h:342
PropertyPass(PassManager *manager)
Definition qqmlsa.cpp:1435
\inmodule QtQmlCompiler
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void registerPasses(QQmlSA::PassManager *manager, const QQmlSA::Element &rootElement) override
Adds a pass manager that will be executed on rootElement.
VarBindingTypeValidatorPass(QQmlSA::PassManager *manager, const QMultiHash< QString, TypeDescription > &expectedPropertyTypes)
void onBinding(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, const QQmlSA::Element &value) override
Executes whenever a property gets bound to a value.
const QLoggingCategory & category()
[1]
\inmodule QtQmlCompiler
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
const char * typeName
GLint location
GLuint GLsizei const GLchar * message
GLuint name
#define QmlLintPluginInterface_iid
Definition qqmlsa.h:429
QDebug warning(QAnyStringView fileName, int lineNumber)
#define Q_OBJECT
#define Q_PLUGIN_METADATA(x)
#define Q_INTERFACES(x)
QNetworkAccessManager manager
QString QString name