Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQmlJSUtils Namespace Reference

Classes

struct  ResolvedAlias
struct  AliasResolutionVisitor

Enumerations

enum  PropertyAccessor { PropertyAccessor_Read , PropertyAccessor_Write }
enum  ResolvedAliasTarget { AliasTarget_Invalid , AliasTarget_Property , AliasTarget_Object }
enum  FilterType { LocalFileFilter , ResourceFileFilter , LocalFileFilter , ResourceFileFilter }
enum  FilterType { LocalFileFilter , ResourceFileFilter , LocalFileFilter , ResourceFileFilter }

Functions

template<typename String, typename CharacterLiteral, typename StringView>
String escapeString (String s)
template<typename String = QString, typename CharacterLiteral = QLatin1Char, typename StringView = QLatin1StringView>
String toLiteral (const String &s, StringView ctor=StringView("QStringLiteral"))
QString constRefify (QString type)
std::optional< QQmlJSMetaPropertychangeHandlerProperty (const QQmlJSScope::ConstPtr &scope, QStringView signalName)
std::optional< QQmlJSMetaPropertypropertyFromChangedHandler (const QQmlJSScope::ConstPtr &scope, QStringView changedHandler)
bool hasCompositeBase (const QQmlJSScope::ConstPtr &scope)
bool bindablePropertyHasDefaultAccessor (const QQmlJSMetaProperty &p, PropertyAccessor accessor)
ResolvedAlias Q_QMLCOMPILER_EXPORT resolveAlias (const QQmlJSTypeResolver *typeResolver, const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &owner, const AliasResolutionVisitor &visitor)
ResolvedAlias Q_QMLCOMPILER_EXPORT resolveAlias (const QQmlJSScopesById &idScopes, const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &owner, const AliasResolutionVisitor &visitor)
template<typename QQmlJSScopePtr, typename Action>
bool searchBaseAndExtensionTypes (const QQmlJSScopePtr &type, const Action &check)
template<typename Action>
void traverseFollowingQmlIrObjectStructure (const QQmlJSScope::Ptr &root, Action act)
template<typename Action>
void traverseFollowingMetaObjectHierarchy (const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &start, Action act)
std::optional< QQmlJSFixSuggestion > Q_QMLCOMPILER_EXPORT didYouMean (const QString &userInput, QStringList candidates, const QString &filename, const QQmlJS::SourceLocation &location)
std::variant< QString, QQmlJS::DiagnosticMessage > Q_QMLCOMPILER_EXPORT sourceDirectoryPath (const QQmlJSImporter *importer, const QString &buildDirectoryPath)
template<typename Container>
void deduplicate (Container &container)
QStringList cleanPaths (QStringList &&paths)
QStringList Q_QMLCOMPILER_EXPORT resourceFilesFromBuildFolders (const QStringList &buildFolders)
QString Q_QMLCOMPILER_EXPORT qmlSourcePathFromBuildPath (const QQmlJSResourceFileMapper *mapper, const QString &pathInBuildFolder)
QString Q_QMLCOMPILER_EXPORT qmlBuildPathFromSourcePath (const QQmlJSResourceFileMapper *mapper, const QString &pathInBuildFolder)
QString Q_QMLCOMPILER_EXPORT getScopeName (const QQmlJSScope::ConstPtr &scope, QQmlJSScope::ScopeType type)
QString Q_QMLCOMPILER_EXPORT fileSelectorFor (const QQmlJSScope::ConstPtr &scope1)
bool Q_QMLCOMPILER_EXPORT canStrictlyCompareWithVar (const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, const QQmlJSScope::ConstPtr &rhsType)
bool Q_QMLCOMPILER_EXPORT canCompareWithQObject (const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, const QQmlJSScope::ConstPtr &rhsType)
bool Q_QMLCOMPILER_EXPORT canCompareWithQUrl (const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, const QQmlJSScope::ConstPtr &rhsType)
template<typename ScopeForId>
static ResolvedAlias resolveAlias (ScopeForId scopeForId, const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &owner, const AliasResolutionVisitor &visitor)
static QQmlJSResourceFileMapper::Entry qmlModuleEntryFromBuildPath (const QQmlJSResourceFileMapper *mapper, const QString &pathInBuildFolder, FilterType type)

Variables

constexpr std::array cppFileFilters

Enumeration Type Documentation

◆ FilterType [1/2]

Enumerator
LocalFileFilter 
ResourceFileFilter 
LocalFileFilter 
ResourceFileFilter 

Definition at line 272 of file qqmljsutils.cpp.

◆ FilterType [2/2]

Enumerator
LocalFileFilter 
ResourceFileFilter 
LocalFileFilter 
ResourceFileFilter 

Definition at line 272 of file qqmljsutils.cpp.

◆ PropertyAccessor

Enumerator
PropertyAccessor_Read 
PropertyAccessor_Write 

Definition at line 151 of file qqmljsutils_p.h.

◆ ResolvedAliasTarget

Enumerator
AliasTarget_Invalid 
AliasTarget_Property 
AliasTarget_Object 

Definition at line 178 of file qqmljsutils_p.h.

Function Documentation

◆ bindablePropertyHasDefaultAccessor()

bool QQmlJSUtils::bindablePropertyHasDefaultAccessor ( const QQmlJSMetaProperty & p,
PropertyAccessor accessor )
inline

Returns true if p is bindable and property accessor specified by accessor is equal to "default". Returns false otherwise.

Note
This function follows BINDABLE-only properties logic (e.g. in moc)

Definition at line 162 of file qqmljsutils_p.h.

References PropertyAccessor_Read, and PropertyAccessor_Write.

◆ canCompareWithQObject()

bool QQmlJSUtils::canCompareWithQObject ( const QQmlJSTypeResolver * typeResolver,
const QQmlJSScope::ConstPtr & lhsType,
const QQmlJSScope::ConstPtr & rhsType )

Utility method that checks if one of the registers is qobject, and the other can be efficiently compared to it

Definition at line 228 of file qqmljsutils.cpp.

◆ canCompareWithQUrl()

bool QQmlJSUtils::canCompareWithQUrl ( const QQmlJSTypeResolver * typeResolver,
const QQmlJSScope::ConstPtr & lhsType,
const QQmlJSScope::ConstPtr & rhsType )

Utility method that checks if both sides are QUrl type. In future, that might be extended to support comparison with other types i.e QUrl vs string

Definition at line 244 of file qqmljsutils.cpp.

◆ canStrictlyCompareWithVar()

bool QQmlJSUtils::canStrictlyCompareWithVar ( const QQmlJSTypeResolver * typeResolver,
const QQmlJSScope::ConstPtr & lhsType,
const QQmlJSScope::ConstPtr & rhsType )

Utility method that checks if one of the registers is var, and the other can be efficiently compared to it

Definition at line 211 of file qqmljsutils.cpp.

◆ changeHandlerProperty()

std::optional< QQmlJSMetaProperty > QQmlJSUtils::changeHandlerProperty ( const QQmlJSScope::ConstPtr & scope,
QStringView signalName )
inline

Definition at line 111 of file qqmljsutils_p.h.

◆ cleanPaths()

QStringList QQmlJSUtils::cleanPaths ( QStringList && paths)
inline

Definition at line 390 of file qqmljsutils_p.h.

◆ constRefify()

QString QQmlJSUtils::constRefify ( QString type)
inline

Returns type string conditionally wrapped into {const} and {&}. This function is mostly useful for code generators.

Definition at line 104 of file qqmljsutils_p.h.

◆ deduplicate()

template<typename Container>
void QQmlJSUtils::deduplicate ( Container & container)
inline

Definition at line 383 of file qqmljsutils_p.h.

◆ didYouMean()

std::optional< QQmlJSFixSuggestion > QQmlJSUtils::didYouMean ( const QString & userInput,
QStringList candidates,
const QString & filename,
const QQmlJS::SourceLocation & location )

Definition at line 104 of file qqmljsutils.cpp.

◆ escapeString()

template<typename String, typename CharacterLiteral, typename StringView>
String QQmlJSUtils::escapeString ( String s)

Returns escaped version of s. This function is mostly useful for code generators.

Definition at line 77 of file qqmljsutils_p.h.

◆ fileSelectorFor()

QString QQmlJSUtils::fileSelectorFor ( const QQmlJSScope::ConstPtr & scope1)

Definition at line 393 of file qqmljsutils.cpp.

◆ getScopeName()

QString QQmlJSUtils::getScopeName ( const QQmlJSScope::ConstPtr & scope,
QQmlJSScope::ScopeType type )

Returns the name of scope based on type.

Definition at line 374 of file qqmljsutils.cpp.

References QQmlSA::AttachedPropertyScope, and QQmlSA::GroupedPropertyScope.

◆ hasCompositeBase()

bool QQmlJSUtils::hasCompositeBase ( const QQmlJSScope::ConstPtr & scope)
inline

Definition at line 141 of file qqmljsutils_p.h.

References QQmlSA::QMLScope.

◆ propertyFromChangedHandler()

std::optional< QQmlJSMetaProperty > QQmlJSUtils::propertyFromChangedHandler ( const QQmlJSScope::ConstPtr & scope,
QStringView changedHandler )
inline

Definition at line 127 of file qqmljsutils_p.h.

◆ qmlBuildPathFromSourcePath()

QString QQmlJSUtils::qmlBuildPathFromSourcePath ( const QQmlJSResourceFileMapper * mapper,
const QString & pathInSourceFolder )

Obtains the source folder path from a build folder QML file path via the passed mapper, see also \l QQmlJSUtils::qmlSourcePathFromBuildPath.

Definition at line 341 of file qqmljsutils.cpp.

◆ qmlModuleEntryFromBuildPath()

QQmlJSResourceFileMapper::Entry QQmlJSUtils::qmlModuleEntryFromBuildPath ( const QQmlJSResourceFileMapper * mapper,
const QString & pathInBuildFolder,
FilterType type )
static

Obtain a QML module qrc entry from its qmldir entry.

Contains a heuristic for QML modules without nested-qml-module-with-prefer-feature that tries to find a parent directory that contains a qmldir entry in the qrc.

Definition at line 285 of file qqmljsutils.cpp.

References LocalFileFilter.

◆ qmlSourcePathFromBuildPath()

QString QQmlJSUtils::qmlSourcePathFromBuildPath ( const QQmlJSResourceFileMapper * mapper,
const QString & pathInBuildFolder )

Obtains the source folder path from a build folder QML file path via the passed mapper.

This works on proper QML modules when using the nested-qml-module-with-prefer-feature from 6.8 and uses a heuristic when the qmldir with the prefer entry is missing.

Definition at line 319 of file qqmljsutils.cpp.

◆ resolveAlias() [1/3]

ResolvedAlias QQmlJSUtils::resolveAlias ( const QQmlJSScopesById & idScopes,
const QQmlJSMetaProperty & property,
const QQmlJSScope::ConstPtr & owner,
const AliasResolutionVisitor & visitor )

Definition at line 93 of file qqmljsutils.cpp.

◆ resolveAlias() [2/3]

ResolvedAlias QQmlJSUtils::resolveAlias ( const QQmlJSTypeResolver * typeResolver,
const QQmlJSMetaProperty & property,
const QQmlJSScope::ConstPtr & owner,
const AliasResolutionVisitor & visitor )

Definition at line 82 of file qqmljsutils.cpp.

◆ resolveAlias() [3/3]

template<typename ScopeForId>
ResolvedAlias QQmlJSUtils::resolveAlias ( ScopeForId scopeForId,
const QQmlJSMetaProperty & property,
const QQmlJSScope::ConstPtr & owner,
const AliasResolutionVisitor & visitor )
static

Fully resolves alias property and returns the information about the origin, which is not an alias.

Definition at line 27 of file qqmljsutils.cpp.

References AliasTarget_Object, QQmlJSMetaProperty::isAlias(), and QQmlJSUtils::ResolvedAlias::kind.

Here is the call graph for this function:

◆ resourceFilesFromBuildFolders()

QStringList QQmlJSUtils::resourceFilesFromBuildFolders ( const QStringList & buildFolders)

Utility method that searches qrc files in given folders. Do not use this when the order or selection of the returned qrc files matters.

Definition at line 258 of file qqmljsutils.cpp.

◆ searchBaseAndExtensionTypes()

template<typename QQmlJSScopePtr, typename Action>
bool QQmlJSUtils::searchBaseAndExtensionTypes ( const QQmlJSScopePtr & type,
const Action & check )

Definition at line 208 of file qqmljsutils_p.h.

◆ sourceDirectoryPath()

std::variant< QString, QQmlJS::DiagnosticMessage > QQmlJSUtils::sourceDirectoryPath ( const QQmlJSImporter * importer,
const QString & buildDirectoryPath )

Returns a corresponding source directory path for buildDirectoryPath Returns empty string on error

Definition at line 168 of file qqmljsutils.cpp.

◆ toLiteral()

template<typename String = QString, typename CharacterLiteral = QLatin1Char, typename StringView = QLatin1StringView>
String QQmlJSUtils::toLiteral ( const String & s,
StringView ctor = StringView("QStringLiteral") )

Returns s wrapped into a literal macro specified by ctor. By default, returns a QStringLiteral-wrapped literal. This function is mostly useful for code generators.

Note
This function escapes s before wrapping it.

Definition at line 94 of file qqmljsutils_p.h.

◆ traverseFollowingMetaObjectHierarchy()

template<typename Action>
void QQmlJSUtils::traverseFollowingMetaObjectHierarchy ( const QQmlJSScope::ConstPtr & scope,
const QQmlJSScope::ConstPtr & start,
Action act )

Traverses the base types and extensions of scope in the order aligned with QMetaObjects created at run time for these types and extensions (except that QQmlVMEMetaObject is ignored). start is the starting type in the hierarchy where act is applied.

Note
To call act for every type in the hierarchy, use scope->extensionType().scope as start

Definition at line 311 of file qqmljsutils_p.h.

◆ traverseFollowingQmlIrObjectStructure()

template<typename Action>
void QQmlJSUtils::traverseFollowingQmlIrObjectStructure ( const QQmlJSScope::Ptr & root,
Action act )

Definition at line 279 of file qqmljsutils_p.h.

Variable Documentation

◆ cppFileFilters

std::array QQmlJSUtils::cppFileFilters
inlineconstexpr
Initial value:
{
QLatin1String("*.cpp"), QLatin1String("*.cxx"), QLatin1String("*.cc"), QLatin1String("*.c"),
QLatin1String("*.c++"), QLatin1String("*.hpp"), QLatin1String("*.hxx"), QLatin1String("*.hh"),
QLatin1String("*.h"), QLatin1String("*.h++"),
}
QLatin1StringView QLatin1String
Definition qstringfwd.h:34

Definition at line 409 of file qqmljsutils_p.h.