5#ifndef QUICKLINTPLUGIN_H
6#define QUICKLINTPLUGIN_H
8#include <QtCore/qplugin.h>
9#include <QtCore/qlist.h>
10#include <QtCore/qvarlengtharray.h>
11#include <QtCore/qhash.h>
13#include <QtQmlCompiler/qqmlsa.h>
27 Q_PLUGIN_METADATA(IID QmlLintPluginInterface_iid FILE
"plugin.json")
39 void addWarning(QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName,
40 QAnyStringView warning);
41 bool shouldRun(
const QQmlSA::Element &element)
override;
42 void run(
const QQmlSA::Element &element)
override;
60 bool allowInDelegate, QAnyStringView warning);
62 void onBinding(
const QQmlSA::Element &element,
const QString &propertyName,
63 const QQmlSA::Binding &binding,
const QQmlSA::Element &bindingScope,
64 const QQmlSA::Element &value)
override;
65 void onRead(
const QQmlSA::Element &element,
const QString &propertyName,
66 const QQmlSA::Element &readScope, QQmlSA::SourceLocation location)
override;
67 void onWrite(
const QQmlSA::Element &element,
const QString &propertyName,
68 const QQmlSA::Element &value,
const QQmlSA::Element &writeScope,
69 QQmlSA::SourceLocation location)
override;
72 void checkWarnings(
const QQmlSA::Element &element,
const QQmlSA::Element &scopeUsedIn,
73 const QQmlSA::SourceLocation &location);
77 QVarLengthArray<QQmlSA::Element, 4> allowedTypes;
78 bool allowInDelegate =
false;
81 QHash<QString, Warning> m_attachedTypes;
89 bool shouldRun(
const QQmlSA::Element &element)
override;
90 void run(
const QQmlSA::Element &element)
override;
96 QStringList restrictedProperties;
97 bool isInModuleControls =
true;
98 bool isControl =
false;
99 bool inheritsControl =
false;
100 QQmlSA::Element element = {};
103 QList<ControlElement> m_elements;
111 bool shouldRun(
const QQmlSA::Element &element)
override;
112 void run(
const QQmlSA::Element &element)
override;
115 QQmlSA::Element m_item;
123 bool shouldRun(
const QQmlSA::Element &element)
override;
124 void run(
const QQmlSA::Element &element)
override;
127 QQmlSA::Element m_swipeDelegate;
134 const QMultiHash<QString, TypeDescription> &expectedPropertyTypes);
136 void onBinding(
const QQmlSA::Element &element,
const QString &propertyName,
137 const QQmlSA::Binding &binding,
const QQmlSA::Element &bindingScope,
138 const QQmlSA::Element &value)
override;
141 QMultiHash<QString, QQmlSA::Element> m_expectedPropertyTypes;
149 bool shouldRun(
const QQmlSA::Element &element)
override;
150 void run(
const QQmlSA::Element &element)
override;
153 QQmlSA::Element m_propertyChanges;
168 void onRead(
const QQmlSA::Element &element,
const QString &propertyName,
169 const QQmlSA::Element &readScope, QQmlSA::SourceLocation location)
override;
170 void onWrite(
const QQmlSA::Element &element,
const QString &propertyName,
171 const QQmlSA::Element &value,
const QQmlSA::Element &writeScope,
172 QQmlSA::SourceLocation location)
override;
175 struct ElementAndLocation {
176 QQmlSA::Element element;
177 QQmlSA::SourceLocation location;
180 QMultiHash<QQmlSA::Element, ElementAndLocation> usedAttachedTypes;
181 QQmlSA::LoggerWarningId category;
189 bool shouldRun(
const QQmlSA::Element &element)
override;
190 void run(
const QQmlSA::Element &element)
override;
193 QQmlSA::Element m_state;
194 QQmlSA::Element m_anchorChanges;
195 QQmlSA::Element m_parentChanges;
196 QQmlSA::Element m_propertyChanges;
197 QQmlSA::Element m_stateChangeScript;
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)
ColorValidatorPass(QQmlSA::PassManager *manager)
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.
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.
void run(const QQmlSA::Element &element) override
Executes if shouldRun() returns true.
StateNoItemChildrenValidator(QQmlSA::PassManager *manager)
bool shouldRun(const QQmlSA::Element &element) override
Controls whether the run() function should be executed on the given element.
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.
static constexpr QQmlSA::LoggerWarningId quickControlsAttachedPropertyReuse
static constexpr QQmlSA::LoggerWarningId quickControlsNativeCustomize
static constexpr QQmlSA::LoggerWarningId quickStateNoChildItem
static constexpr QQmlSA::LoggerWarningId quickAttachedPropertyType
static constexpr QQmlSA::LoggerWarningId quickUnexpectedVarType
static constexpr QQmlSA::LoggerWarningId quickAttachedPropertyReuse
static constexpr QQmlSA::LoggerWarningId quickPropertyChangesParsed
static constexpr QQmlSA::LoggerWarningId quickAnchorCombinations
static constexpr QQmlSA::LoggerWarningId quickLayoutPositioning
static constexpr QQmlSA::LoggerWarningId quickColor