4#ifndef QQMLJSLOGGINGUTILS_P_H
5#define QQMLJSLOGGINGUTILS_P_H
18#include <QtCore/qstring.h>
19#include <qtqmlcompilerexports.h>
25class QQmlToolingSettings;
26class QCommandLineParser;
32class LoggerCategoryPrivate;
40 LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level,
41 bool ignored =
false,
bool isDefault =
false);
86 return operatorEqualsImpl(lhs, rhs);
90 return !operatorEqualsImpl(lhs, rhs);
93 bool operator==(
const LoggerWarningId warningId)
const {
return warningId.name() == m_name; }
99 QString m_settingsName;
100 QString m_description;
102 bool m_ignored =
false;
103 bool m_isDefault =
false;
104 bool m_changed =
false;
107namespace LoggingUtils {
108Q_QMLCOMPILER_EXPORT
void updateLogLevels(QList<LoggerCategory> &categories,
109 const QQmlToolingSettings &settings,
110 QCommandLineParser *parser);
112Q_QMLCOMPILER_EXPORT QString levelToString(
const QQmlJS::LoggerCategory &category);
113Q_QMLCOMPILER_EXPORT
bool applyLevelToCategory(
const QStringView level, LoggerCategory &category);
std::optional< QQmlJSFixSuggestion > fixSuggestion
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
friend bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are different, otherwise returns false.
QScopedPointer< QImageIOHandlerPrivate > d_ptr
QString fileName() const
If the currently assigned device is a QFile, or if setFileName() has been called, this function retur...
void setFileName(const QString &fileName)
Sets the file name of QImageReader to fileName.
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
void setCategoryFatal(QQmlJS::LoggerWarningId id, bool error)
qsizetype numErrors() const
bool isCategoryIgnored(QQmlJS::LoggerWarningId id) const
void setCode(const QString &code)
void setFilePath(const QString &filePath)
bool currentFunctionHasCompileError() const
void logCompileError(const QString &message, const QQmlJS::SourceLocation &srcLocation)
void setSilent(bool silent)
void setCompileErrorLevel(QtMsgType level)
bool wasCategoryChanged(QQmlJS::LoggerWarningId id) const
void setCategoryIgnored(QQmlJS::LoggerWarningId id, bool error)
QString currentFunctionCompileErrorMessage() const
void processMessages(const QList< QQmlJS::DiagnosticMessage > &messages, const QQmlJS::LoggerWarningId id, const QQmlJS::SourceLocation &sourceLocation=QQmlJS::SourceLocation{})
bool isCategoryFatal(QQmlJS::LoggerWarningId id) const
void iterateCurrentFunctionMessages(F &&f) const
QString compileErrorPrefix() const
void setCategoryLevel(QQmlJS::LoggerWarningId id, QtMsgType level)
QtMsgType compileErrorLevel() const
void iterateAllMessages(F &&f) const
qsizetype numWarnings() const
static const QList< QQmlJS::LoggerCategory > & defaultCategories()
void setIsDisabled(bool isDisabled)
void setCompileErrorPrefix(const QString &prefix)
void log(const QString &message, QQmlJS::LoggerWarningId id, const QQmlJS::SourceLocation &srcLocation, bool showContext=true, bool showFileName=true, const std::optional< QQmlJSFixSuggestion > &suggestion={}, const QString overrideFileName=QString())
QtMsgType categoryLevel(QQmlJS::LoggerWarningId id) const
void registerCategory(const QQmlJS::LoggerCategory &category)
void ignoreWarnings(uint32_t line, const QSet< QString > &categories)
QQmlJSRegisterContent createMethod(const QList< QQmlJSMetaMethod > &methods, const QQmlJSScope::ConstPtr &methodType, ContentVariant variant, QQmlJSRegisterContent scope)
QQmlJSRegisterContent createImportNamespace(uint importNamespaceStringId, const QQmlJSScope::ConstPtr &importNamespaceType, ContentVariant variant, QQmlJSRegisterContent scope)
QQmlJSRegisterContent createProperty(const QQmlJSMetaProperty &property, int baseLookupIndex, int resultLookupIndex, ContentVariant variant, QQmlJSRegisterContent scope)
void adjustType(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &adjusted)
void generalizeType(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &generalized)
void storeType(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &stored)
QQmlJSRegisterContent castTo(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &newContainedType)
QQmlJSRegisterContent createEnumeration(const QQmlJSMetaEnum &enumeration, const QString &enumMember, ContentVariant variant, QQmlJSRegisterContent scope)
void setAllocationMode(AllocationMode mode)
QQmlJSRegisterContent storedIn(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &newStoredType)
QQmlJSRegisterContent clone(QQmlJSRegisterContent from)
QQmlJSRegisterContentPool()
QQmlJSRegisterContent createType(const QQmlJSScope::ConstPtr &type, int resultLookupIndex, ContentVariant variant, QQmlJSRegisterContent scope={})
QQmlJSRegisterContent createConversion(const QList< QQmlJSRegisterContent > &origins, const QQmlJSScope::ConstPtr &conversion, QQmlJSRegisterContent conversionScope, ContentVariant variant, QQmlJSRegisterContent scope)
QQmlJSRegisterContent createMethodCall(const QQmlJSMetaMethod &method, const QQmlJSScope::ConstPtr &returnType, QQmlJSRegisterContent scope)
Tracks the types for the QmlCompiler.
ConstPtrWrapperIterator(QList< Ptr >::const_iterator iterator)
friend bool operator==(const ConstPtrWrapperIterator &a, const ConstPtrWrapperIterator &b)
ConstPtrWrapperIterator & operator++()
friend bool operator!=(const ConstPtrWrapperIterator &a, const ConstPtrWrapperIterator &b)
ConstPtrWrapperIterator operator++(int)
QTypeRevision revision() const
QTypeRevision version() const
Export(QString package, QString type, QTypeRevision version, QTypeRevision revision)
friend bool operator!=(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
friend class QT_PREPEND_NAMESPACE(QQmlJS::LoggerCategory)
LoggerWarningId id() const
bool operator==(const LoggerWarningId warningId) const
QString settingsName() const
QString description() const
static LoggerCategoryPrivate * get(LoggerCategory *)
friend bool operator==(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
LoggerCategory(const LoggerCategory &)
LoggerCategory & operator=(const LoggerCategory &)
LoggerCategory & operator=(LoggerCategory &&) noexcept
LoggerWarningId id() const
LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level, bool ignored=false, bool isDefault=false)
QString settingsName() const
QString description() const
virtual QQmlSourceLocation sourceLocation() const
static BindingPrivate * get(Binding *binding)
static QQmlJSMetaPropertyBinding binding(QQmlSA::Binding &binding)
Element bindingScope() const
void setPropertyName(QString name)
static QQmlSA::Binding createBinding(const QQmlJSMetaPropertyBinding &)
static const QQmlJSMetaPropertyBinding binding(const QQmlSA::Binding &binding)
void setIsAttached(bool isAttached)
BindingPrivate(Binding *, const BindingPrivate &)
void setBindingScope(Element bindingScope)
static const BindingPrivate * get(const Binding *binding)
Element attachedType() const
Returns the attached type if the content type of this binding is AttachedProperty,...
BindingType bindingType() const
Returns the type of this binding.
Element bindingScope() const
Returns the Element scope in which the binding is defined.
friend bool operator!=(const Binding &lhs, const Binding &rhs)
Returns true if lhs and rhs are not equal, and false otherwise.
bool hasUndefinedScriptValue() const
Returns whether this binding has script value type undefined like when it is assigned undefined.
Binding(const Binding &)
Creates a copy of other.
Binding & operator=(const Binding &)
Assigns other to this Binding instance.
bool isAttached() const
Returns true if this type is attached to another one, false otherwise.
bool hasObject() const
Returns true if this binding has an objects, otherwise returns false.
friend bool operator==(const Binding &lhs, const Binding &rhs)
Returns true if lhs and rhs are equal, and false otherwise.
static bool isLiteralBinding(BindingType)
Returns true if bindingType is a literal type, and false otherwise.
QString propertyName() const
Returns the name of the property bound with this binding.
Binding()
Constructs a new Binding object.
QString stringValue() const
Returns the associated string literal if the content type of this binding is StringLiteral,...
Element objectType() const
Returns the type of the associated object if the content type of this binding is Object,...
Binding & operator=(Binding &&) noexcept
Move-assigns other to this Binding instance.
QQmlSA::SourceLocation sourceLocation() const
Returns the location in the QML code where this binding is defined.
ScriptBindingKind scriptKind() const
Returns the kind of the associated script if the content type of this binding is Script,...
double numberValue() const
Returns the associated number if the content type of this binding is NumberLiteral,...
Element groupType() const
Returns the type of the property of this binding if it is a group property, otherwise returns an inva...
~BindingsPrivate()=default
QMultiHash< QString, Binding >::const_iterator constBegin() const
BindingsPrivate(QQmlSA::Binding::Bindings *, const BindingsPrivate &)
friend class QT_PREPEND_NAMESPACE(QQmlJSMetaPropertyBinding)
QMultiHash< QString, Binding >::const_iterator constEnd() const
QQmlSA::SourceLocation location() const
FixSuggestionPrivate(FixSuggestion *, const QString &fixDescription, const QQmlSA::SourceLocation &location, const QString &replacement)
void setHint(const QString &)
void setFileName(const QString &)
QString fixDescription() const
FixSuggestionPrivate(FixSuggestion *)
bool isAutoApplicable() const
void setAutoApplicable(bool autoApplicable=true)
static const QQmlJSFixSuggestion & fixSuggestion(const QQmlSA::FixSuggestion &)
FixSuggestionPrivate(FixSuggestion *, FixSuggestionPrivate &&)
~FixSuggestionPrivate()=default
QString replacement() const
static QQmlJSFixSuggestion & fixSuggestion(QQmlSA::FixSuggestion &)
FixSuggestionPrivate(FixSuggestion *, const FixSuggestionPrivate &)
void setHint(const QString &)
Sets hint as the hint for this fix suggestion.
FixSuggestion(const FixSuggestion &)
Creates a copy of other.
QString hint() const
Returns the hint for this fix suggestion.
QString replacement() const
Returns the fix that will replace the problematic source code.
QString fixDescription() const
Returns the description of the fix.
bool isAutoApplicable() const
Returns whether this suggested fix can be applied automatically.
void setAutoApplicable(bool autoApplicable=true)
Sets autoApplicable to determine whether this suggested fix can be applied automatically.
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id)
Emits a warning message diagnostic about an issue of type id.
Element resolveLiteralType(const Binding &binding)
Returns the element representing the type of literal in binding.
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id, QQmlSA::SourceLocation srcLocation, const QQmlSA::FixSuggestion &fix)
Emits a warning message diagnostic about an issue of type id located at srcLocation and with suggeste...
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id, QQmlSA::SourceLocation srcLocation)
Emits warning message diagnostic about an issue of type id located at srcLocation.
Element resolveBuiltinType(QAnyStringView typeName) const
Returns the type of the built-in type identified by typeName.
Element resolveAttached(QAnyStringView moduleName, QAnyStringView typeName)
Returns the attached type of typeName defined in module moduleName.
QString resolveElementToId(const Element &element, const Element &context)
Returns the id of element in a given context.
Element resolveTypeInFileScope(QAnyStringView typeName)
Returns the type corresponding to typeName inside the currently analysed file.
QString sourceCode(QQmlSA::SourceLocation location)
Returns the source code located within location.
Element resolveAttachedInFileScope(QAnyStringView typeName)
Returns the attached type corresponding to typeName used inside the currently analysed file.
Element resolveIdToElement(QAnyStringView id, const Element &context)
Returns the element in context that has id id.
Element resolveType(QAnyStringView moduleName, QAnyStringView typeName)
Returns the type of typeName defined in module moduleName.
MethodPrivate(Method *, const MethodPrivate &)
QQmlSA::SourceLocation sourceLocation() const
static QQmlSA::Method createMethod(const QQmlJSMetaMethod &)
MethodType methodType() const
static QQmlJSMetaMethod method(const QQmlSA::Method &)
QString methodName() const
Method & operator=(Method &&) noexcept
Move-assigns other to this Method instance.
MethodType methodType() const
Returns the type of this method.
Method(const Method &)
Creates a copy of other.
Method()
Constructs a new Method object.
Method & operator=(const Method &)
Assigns other to this Method instance.
QString methodName() const
Returns the name of the this method.
MethodsPrivate(QQmlSA::Method::Methods *, MethodsPrivate &&)
static QQmlSA::Method::Methods createMethods(const QMultiHash< QString, QQmlJSMetaMethod > &)
QMultiHash< QString, Method >::const_iterator constEnd() const
~MethodsPrivate()=default
MethodsPrivate(QQmlSA::Method::Methods *, const MethodsPrivate &)
QMultiHash< QString, Method >::const_iterator constBegin() const
void analyze(const Element &root)
Runs the element passes over root and all its children.
bool isCategoryEnabled(LoggerWarningId category) const
Returns true if warnings of category are enabled, false otherwise.
std::unordered_map< quint32, Binding > bindingsByLocation() const
Returns bindings by their source location.
bool hasImportedModule(QAnyStringView name) const
Returns true if the module named module has been imported by the QML to be analyzed,...
~PropertyPrivate()=default
static QQmlSA::Property createProperty(const QQmlJSMetaProperty &)
PropertyPrivate(Property *, const PropertyPrivate &)
PropertyPrivate(Property *, PropertyPrivate &&)
static QQmlJSMetaProperty property(const QQmlSA::Property &property)
QQmlSA::Element type() const
Returns the type that this property was defined with.
bool isReadonly() const
Returns whether this property is readonly.
Property(const Property &)
Creates a copy of other.
QString typeName() const
Returns the name of the type of this property.
bool isReadonly() const
Returns true if this property is read-only, false otherwise.
@ WrappedInImplicitComponent
Combined button and popup list for selecting options.
static auto getQQmlJSScopeFromSmartPtr(const From &p) -> From
Q_DECLARE_INTERFACE(QNetworkAccessBackendFactory, QNetworkAccessBackendFactory_iid)
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
static QString toNumericString(double value)
static QString messageTypeForMethod(const QString &method)
#define BYTECODE_UNIMPLEMENTED()
#define INJECT_TRACE_INFO(function)
static QString minExpression(int argc)
static QString maxExpression(int argc)
static bool isTypeStorable(const QQmlJSTypeResolver *resolver, const QQmlJSScope::ConstPtr &type)
#define QmlLintPluginInterface_iid
std::shared_ptr< QQmlSA::PropertyPass > pass