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
qqmllsutils.cpp File Reference

(1bcb8587ab6b7068d1af8897804820853e7bc9d0)

#include "qqmllsutils_p.h"
#include <QtLanguageServer/private/qlanguageserverspectypes_p.h>
#include <QtCore/qthreadpool.h>
#include <QtCore/private/qduplicatetracker_p.h>
#include <QtCore/QRegularExpression>
#include <QtQmlDom/private/qqmldomexternalitems_p.h>
#include <QtQmlDom/private/qqmldomtop_p.h>
#include <QtQmlDom/private/qqmldomscriptelements_p.h>
#include <QtQmlDom/private/qqmldom_utils_p.h>
#include <QtQml/private/qqmlsignalnames_p.h>
#include <QtQml/private/qqmljslexer_p.h>
#include <QtQmlCompiler/private/qqmljsutils_p.h>
#include <algorithm>
#include <iterator>
#include <memory>
#include <optional>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <variant>
+ Include dependency graph for qqmllsutils.cpp:

Go to the source code of this file.

Classes

struct  SignalOrProperty
 

Functions

static QList< QQmlLSUtilsItemLocation >::const_iterator handlePropertyDefinitionAndBindingOverlap (const QList< QQmlLSUtilsItemLocation > &items, qsizetype offsetInFile)
 
static QList< QQmlLSUtilsItemLocationfilterItemsFromTextLocation (const QList< QQmlLSUtilsItemLocation > &items, qsizetype offsetInFile)
 
static std::optional< QQmlLSUtilsLocationlocationFromDomItem (const DomItem &item, FileLocationRegion region)
 
static bool findDefinitionFromItem (const DomItem &item, const QString &name)
 
static DomItem findJSIdentifierDefinition (const DomItem &item, const QString &name)
 
static std::optional< SignalOrPropertyresolveNameInQmlScope (const QString &name, const QQmlJSScope::ConstPtr &owner)
 Find out if {name} is a signal, signal handler, property, property changed signal, or a property changed handler in the given QQmlJSScope.
 
static QStringList namesOfPossibleUsages (const QString &name, const DomItem &item, const QQmlJSScope::ConstPtr &targetType)
 
template<typename Predicate >
QQmlJSScope::ConstPtr findDefiningScopeIf (QQmlJSScope::ConstPtr referrerScope, Predicate &&check)
 
static QQmlJSScope::ConstPtr findDefiningScopeForProperty (QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
 Finds the scope where a property is first defined.
 
static QQmlJSScope::ConstPtr findDefiningScopeForBinding (QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
 
static QQmlJSScope::ConstPtr findDefiningScopeForMethod (QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
 
static QQmlJSScope::ConstPtr findDefiningScopeForEnumeration (QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
 
static QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey (QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
 
static FieldFilter filterForFindUsages ()
 Filter away the parts of the Dom not needed for find usages, by following the profiler's information.
 
static void findUsagesOfNonJSIdentifiers (const DomItem &item, const QString &name, QList< QQmlLSUtilsLocation > &result)
 
static QQmlLSUtilsLocation locationFromJSIdentifierDefinition (const DomItem &definitionOfItem, const QString &name)
 
static void findUsagesHelper (const DomItem &item, const QString &name, QList< QQmlLSUtilsLocation > &result)
 
static std::optional< QQmlLSUtilsIdentifierTypehasMethodOrSignal (const QQmlJSScope::ConstPtr &scope, const QString &name)
 
static std::optional< QQmlLSUtilsExpressionTypemethodFromReferrerScope (const QQmlJSScope::ConstPtr &referrerScope, const QString &name, QQmlLSUtilsResolveOptions options)
 
static std::optional< QQmlLSUtilsExpressionTypepropertyFromReferrerScope (const QQmlJSScope::ConstPtr &referrerScope, const QString &propertyName, QQmlLSUtilsResolveOptions options)
 
static std::optional< QQmlLSUtilsExpressionTypepropertyBindingFromReferrerScope (const QQmlJSScope::ConstPtr &referrerScope, const QString &name, QQmlLSUtilsResolveOptions options, QQmlJSTypeResolver *resolverForIds)
 
static QQmlJSScope::ConstPtr findScopeOfSpecialItems (QQmlJSScope::ConstPtr scope, const DomItem &item)
 
static std::optional< QQmlLSUtilsExpressionTyperesolveFieldMemberExpressionType (const DomItem &item, QQmlLSUtilsResolveOptions options)
 
static std::optional< QQmlLSUtilsExpressionTyperesolveIdentifierExpressionType (const DomItem &item, QQmlLSUtilsResolveOptions options)
 
static std::optional< QQmlLSUtilsExpressionTyperesolveSignalOrPropertyExpressionType (const QString &name, const QQmlJSScope::ConstPtr &scope, QQmlLSUtilsResolveOptions options)
 
static std::optional< QQmlLSUtilsLocationfindMethodDefinitionOf (const DomItem &file, QQmlJS::SourceLocation location, const QString &name)
 
static std::optional< QQmlLSUtilsLocationfindPropertyDefinitionOf (const DomItem &file, QQmlJS::SourceLocation propertyDefinitionLocation, const QString &name)
 
static QQmlJSScope::ConstPtr propertyOwnerFrom (const QQmlJSScope::ConstPtr &type, const QString &name)
 
static QQmlJSScope::ConstPtr methodOwnerFrom (const QQmlJSScope::ConstPtr &type, const QString &name)
 
static QQmlJSScope::ConstPtr expressionTypeWithDefinition (const QQmlLSUtilsExpressionType &ownerType)
 
static std::optional< QStringoldNameFrom (const DomItem &item)
 
static std::optional< QStringnewNameFrom (const QString &dirtyNewName, QQmlLSUtilsIdentifierType alternative)
 

Function Documentation

◆ expressionTypeWithDefinition()

static QQmlJSScope::ConstPtr expressionTypeWithDefinition ( const QQmlLSUtilsExpressionType & ownerType)
static

Definition at line 1854 of file qqmllsutils.cpp.

References AttachedTypeIdentifier, QQmlSignalNames::changedHandlerNameToPropertyName(), QQmlSignalNames::changedSignalNameToPropertyName(), EnumeratorIdentifier, EnumeratorValueIdentifier, GroupedPropertyIdentifier, QQmlSignalNames::handlerNameToSignalName(), JavaScriptIdentifier, MethodIdentifier, methodOwnerFrom(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, propertyOwnerFrom(), QmlComponentIdentifier, QmlObjectIdIdentifier, SignalHandlerIdentifier, SignalIdentifier, and SingletonIdentifier.

Referenced by QQmlLSUtils::checkNameForRename().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterForFindUsages()

static FieldFilter filterForFindUsages ( )
static

Filter away the parts of the Dom not needed for find usages, by following the profiler's information.

  1. "propertyInfos" tries to require all inherited properties of some QmlObject. That is super slow (profiler says it eats 90% of the time needed by tst_qmlls_utils findUsages!) and is not needed for usages.
  2. "get" tries to resolve references, like base types saved in prototypes for example, and is not needed to find usages. Profiler says it eats 70% of the time needed by tst_qmlls_utils findUsages.
  3. "defaultPropertyName" also recurses through base types and is not needed to find usages.

Definition at line 809 of file qqmllsutils.cpp.

References QString::fromUtf16().

Referenced by findUsagesHelper(), and findUsagesOfNonJSIdentifiers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterItemsFromTextLocation()

static QList< QQmlLSUtilsItemLocation > filterItemsFromTextLocation ( const QList< QQmlLSUtilsItemLocation > & items,
qsizetype offsetInFile )
static

Definition at line 283 of file qqmllsutils.cpp.

References QList< T >::begin(), QSet< T >::begin(), QQmlJS::SourceLocation::begin(), QList< T >::end(), handlePropertyDefinitionAndBindingOverlap(), it, items, and QList< T >::size().

Referenced by QQmlLSUtils::itemsFromTextLocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefiningScopeForBinding()

static QQmlJSScope::ConstPtr findDefiningScopeForBinding ( QQmlJSScope::ConstPtr referrerScope,
const QString & nameToCheck )
static

See also findDefiningScopeForProperty().

Special case: you can also bind to a signal handler.

Definition at line 754 of file qqmllsutils.cpp.

References findDefiningScopeIf(), QQmlJSScope::hasOwnMethod(), and QQmlJSScope::hasOwnProperty().

Referenced by QQmlLSUtils::resolveExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefiningScopeForEnumeration()

static QQmlJSScope::ConstPtr findDefiningScopeForEnumeration ( QQmlJSScope::ConstPtr referrerScope,
const QString & nameToCheck )
static

See also findDefiningScopeForProperty().

Definition at line 778 of file qqmllsutils.cpp.

References findDefiningScopeIf(), and QQmlJSScope::hasOwnEnumeration().

Referenced by QQmlLSUtils::resolveExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefiningScopeForEnumerationKey()

static QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey ( QQmlJSScope::ConstPtr referrerScope,
const QString & nameToCheck )
static

See also findDefiningScopeForProperty().

Definition at line 790 of file qqmllsutils.cpp.

References findDefiningScopeIf(), and QQmlJSScope::hasOwnEnumerationKey().

Referenced by QQmlLSUtils::resolveExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefiningScopeForMethod()

static QQmlJSScope::ConstPtr findDefiningScopeForMethod ( QQmlJSScope::ConstPtr referrerScope,
const QString & nameToCheck )
static

See also findDefiningScopeForProperty().

Definition at line 766 of file qqmllsutils.cpp.

References findDefiningScopeIf(), and QQmlJSScope::hasOwnMethod().

Referenced by methodFromReferrerScope(), QQmlLSUtils::resolveExpressionType(), and resolveSignalOrPropertyExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefiningScopeForProperty()

static QQmlJSScope::ConstPtr findDefiningScopeForProperty ( QQmlJSScope::ConstPtr referrerScope,
const QString & nameToCheck )
static

Finds the scope where a property is first defined.

Starts looking for the name starting from the given scope and traverse through base and extension types.

Definition at line 740 of file qqmllsutils.cpp.

References findDefiningScopeIf(), and QQmlJSScope::hasOwnProperty().

Referenced by propertyBindingFromReferrerScope(), propertyFromReferrerScope(), QQmlLSUtils::resolveExpressionType(), and resolveSignalOrPropertyExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefiningScopeIf()

template<typename Predicate >
QQmlJSScope::ConstPtr findDefiningScopeIf ( QQmlJSScope::ConstPtr referrerScope,
Predicate && check )

Definition at line 719 of file qqmllsutils.cpp.

References QQmlJSUtils::searchBaseAndExtensionTypes().

Referenced by findDefiningScopeForBinding(), findDefiningScopeForEnumeration(), findDefiningScopeForEnumerationKey(), findDefiningScopeForMethod(), and findDefiningScopeForProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDefinitionFromItem()

static bool findDefinitionFromItem ( const DomItem & item,
const QString & name )
static

Definition at line 551 of file qqmllsutils.cpp.

References item, and qCDebug.

Referenced by findJSIdentifierDefinition().

+ Here is the caller graph for this function:

◆ findJSIdentifierDefinition()

static DomItem findJSIdentifierDefinition ( const DomItem & item,
const QString & name )
static

Definition at line 563 of file qqmllsutils.cpp.

References findDefinitionFromItem(), i, and item.

Referenced by findUsagesHelper(), and resolveIdentifierExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findMethodDefinitionOf()

static std::optional< QQmlLSUtilsLocation > findMethodDefinitionOf ( const DomItem & file,
QQmlJS::SourceLocation location,
const QString & name )
static

Definition at line 1698 of file qqmllsutils.cpp.

References QSet< T >::constEnd(), QSet< T >::constFind(), file, QQmlJS::Dom::IdentifierRegion, it, method, QQmlLSUtils::sourceLocationToDomItem(), and QQmlJS::Dom::FileLocations::treeOf().

Referenced by QQmlLSUtils::findDefinitionOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findPropertyDefinitionOf()

static std::optional< QQmlLSUtilsLocation > findPropertyDefinitionOf ( const DomItem & file,
QQmlJS::SourceLocation propertyDefinitionLocation,
const QString & name )
static

Definition at line 1719 of file qqmllsutils.cpp.

References QSet< T >::constEnd(), QSet< T >::constFind(), file, QQmlJS::Dom::IdentifierRegion, it, QQmlLSUtils::sourceLocationToDomItem(), and QQmlJS::Dom::FileLocations::treeOf().

Referenced by QQmlLSUtils::findDefinitionOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findScopeOfSpecialItems()

static QQmlJSScope::ConstPtr findScopeOfSpecialItems ( QQmlJSScope::ConstPtr scope,
const DomItem & item )
static

Finds the scope within the special elements like Connections, PropertyChanges, Bindings or AnchorChanges.

Definition at line 1203 of file qqmllsutils.cpp.

References QQmlJSScope::hasOwnPropertyBindings(), QString::isEmpty(), item, QQmlJSScope::parentScope(), QQmlJSUtils::searchBaseAndExtensionTypes(), and typeName.

Referenced by QQmlLSUtils::resolveExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findUsagesHelper()

static void findUsagesHelper ( const DomItem & item,
const QString & name,
QList< QQmlLSUtilsLocation > & result )
static

Definition at line 941 of file qqmllsutils.cpp.

References QQmlJS::Dom::emptyChildrenVisitor(), fileName, filterForFindUsages(), findJSIdentifierDefinition(), findUsagesOfNonJSIdentifiers(), item, locationFromJSIdentifierDefinition(), qCDebug, qCWarning, and QQmlJS::Dom::FileLocations::treeOf().

Referenced by QQmlLSUtils::findUsagesOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findUsagesOfNonJSIdentifiers()

static void findUsagesOfNonJSIdentifiers ( const DomItem & item,
const QString & name,
QList< QQmlLSUtilsLocation > & result )
static

Definition at line 820 of file qqmllsutils.cpp.

References QQmlJS::Dom::emptyChildrenVisitor(), file, filterForFindUsages(), QQmlJS::Dom::IdentifierRegion, QQmlJS::SourceLocation::isValid(), item, QQmlJS::Dom::MainRegion, namesOfPossibleUsages(), QQmlJS::Dom::FileLocations::region(), QQmlLSUtils::resolveExpressionType(), ResolveOwnerType, and QQmlJS::Dom::FileLocations::treeOf().

Referenced by findUsagesHelper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePropertyDefinitionAndBindingOverlap()

static QList< QQmlLSUtilsItemLocation >::const_iterator handlePropertyDefinitionAndBindingOverlap ( const QList< QQmlLSUtilsItemLocation > & items,
qsizetype offsetInFile )
static

Definition at line 230 of file qqmllsutils.cpp.

References QList< T >::begin(), QQmlJS::Dom::ColonTokenRegion, QList< T >::end(), and items.

Referenced by filterItemsFromTextLocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasMethodOrSignal()

static std::optional< QQmlLSUtilsIdentifierType > hasMethodOrSignal ( const QQmlJSScope::ConstPtr & scope,
const QString & name )
static

Definition at line 1040 of file qqmllsutils.cpp.

References MethodIdentifier, QQmlJSScope::methods(), methods, and SignalIdentifier.

Referenced by methodFromReferrerScope().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ locationFromDomItem()

static std::optional< QQmlLSUtilsLocation > locationFromDomItem ( const DomItem & item,
FileLocationRegion region )
static

Definition at line 420 of file qqmllsutils.cpp.

References QQmlLSUtilsLocation::filename, item, QQmlJS::Dom::MainRegion, QQmlJS::Dom::FileLocations::region(), and QQmlJS::Dom::FileLocations::treeOf().

Referenced by QQmlLSUtils::findTypeDefinitionOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ locationFromJSIdentifierDefinition()

static QQmlLSUtilsLocation locationFromJSIdentifierDefinition ( const DomItem & definitionOfItem,
const QString & name )
static

Definition at line 926 of file qqmllsutils.cpp.

References Q_ASSERT_X.

Referenced by findUsagesHelper().

+ Here is the caller graph for this function:

◆ methodFromReferrerScope()

static std::optional< QQmlLSUtilsExpressionType > methodFromReferrerScope ( const QQmlJSScope::ConstPtr & referrerScope,
const QString & name,
QQmlLSUtilsResolveOptions options )
static

Searches for a method by traversing the parent scopes.

We assume here that it is possible to call methods from parent scope to simplify things, as the linting module already warns about calling methods from parent scopes.

Note: in QML, one can only call methods from the current scope, and from the QML file root scope. Everything else needs a qualifier.

Definition at line 1063 of file qqmllsutils.cpp.

References findDefiningScopeForMethod(), QQmlSignalNames::handlerNameToSignalName(), hasMethodOrSignal(), QQmlJSScope::parentScope(), ResolveActualTypeForFieldMemberExpression, ResolveOwnerType, and SignalHandlerIdentifier.

Referenced by resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ methodOwnerFrom()

static QQmlJSScope::ConstPtr methodOwnerFrom ( const QQmlJSScope::ConstPtr & type,
const QString & name )
static

Definition at line 1834 of file qqmllsutils.cpp.

References QQmlJSScope::baseType(), Q_ASSERT, and qCDebug.

Referenced by expressionTypeWithDefinition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ namesOfPossibleUsages()

static QStringList namesOfPossibleUsages ( const QString & name,
const DomItem & item,
const QQmlJSScope::ConstPtr & targetType )
static

Returns a list of names, that when belonging to the same targetType, should be considered equal. This is used to find signal handlers as usages of their corresponding signals, for example.

Definition at line 663 of file qqmllsutils.cpp.

References item, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, QQmlSignalNames::propertyNameToChangedHandlerName(), QQmlSignalNames::propertyNameToChangedSignalName(), resolveNameInQmlScope(), SignalHandlerIdentifier, SignalIdentifier, and QQmlSignalNames::signalNameToHandlerName().

Referenced by findUsagesOfNonJSIdentifiers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newNameFrom()

static std::optional< QString > newNameFrom ( const QString & dirtyNewName,
QQmlLSUtilsIdentifierType alternative )
static

Definition at line 1996 of file qqmllsutils.cpp.

References QQmlSignalNames::changedHandlerNameToPropertyName(), QQmlSignalNames::changedSignalNameToPropertyName(), QQmlSignalNames::handlerNameToSignalName(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, SignalHandlerIdentifier, and SignalIdentifier.

Referenced by QQmlLSUtils::renameUsagesOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oldNameFrom()

static std::optional< QString > oldNameFrom ( const DomItem & item)
static

Definition at line 1974 of file qqmllsutils.cpp.

References item, and qCDebug.

Referenced by QQmlLSUtils::renameUsagesOf().

+ Here is the caller graph for this function:

◆ propertyBindingFromReferrerScope()

static std::optional< QQmlLSUtilsExpressionType > propertyBindingFromReferrerScope ( const QQmlJSScope::ConstPtr & referrerScope,
const QString & name,
QQmlLSUtilsResolveOptions options,
QQmlJSTypeResolver * resolverForIds )
static

See comment on methodFromReferrerScope: the same applies to property bindings.

If resolver is not null then it is used to resolve the id with which a generalized grouped properties starts.

Definition at line 1139 of file qqmllsutils.cpp.

References AssumeComponentsAreBound, QQmlSA::AttachedProperty, AttachedTypeIdentifier, findDefiningScopeForProperty(), getScope(), GroupedPropertyIdentifier, QQmlSA::GroupProperty, QQmlJSRegisterContent::InvalidLookupIndex, QQmlJSRegisterContent::ObjectById, QmlObjectIdIdentifier, ResolveActualTypeForFieldMemberExpression, ResolveOwnerType, QQmlJSRegisterContent::type(), and QQmlJSRegisterContent::variant().

Referenced by resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ propertyFromReferrerScope()

static std::optional< QQmlLSUtilsExpressionType > propertyFromReferrerScope ( const QQmlJSScope::ConstPtr & referrerScope,
const QString & propertyName,
QQmlLSUtilsResolveOptions options )
static

See comment on methodFromReferrerScope: the same applies to properties.

Definition at line 1107 of file qqmllsutils.cpp.

References findDefiningScopeForProperty(), QQmlJSScope::parentScope(), property, ResolveActualTypeForFieldMemberExpression, resolveNameInQmlScope(), and ResolveOwnerType.

Referenced by resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ propertyOwnerFrom()

static QQmlJSScope::ConstPtr propertyOwnerFrom ( const QQmlJSScope::ConstPtr & type,
const QString & name )
static

Definition at line 1815 of file qqmllsutils.cpp.

References QQmlJSScope::baseType(), Q_ASSERT, and qCDebug.

Referenced by expressionTypeWithDefinition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveFieldMemberExpressionType()

static std::optional< QQmlLSUtilsExpressionType > resolveFieldMemberExpressionType ( const DomItem & item,
QQmlLSUtilsResolveOptions options )
static

Definition at line 1263 of file qqmllsutils.cpp.

References EnumeratorIdentifier, EnumeratorValueIdentifier, it, item, methodFromReferrerScope(), propertyBindingFromReferrerScope(), propertyFromReferrerScope(), qCDebug, QmlComponentIdentifier, ResolveActualTypeForFieldMemberExpression, and QQmlLSUtils::resolveExpressionType().

Referenced by resolveIdentifierExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveIdentifierExpressionType()

static std::optional< QQmlLSUtilsExpressionType > resolveIdentifierExpressionType ( const DomItem & item,
QQmlLSUtilsResolveOptions options )
static

Definition at line 1315 of file qqmllsutils.cpp.

References AssumeComponentsAreBound, AttachedTypeIdentifier, findJSIdentifierDefinition(), QQmlJSRegisterContent::InvalidLookupIndex, QQmlLSUtils::isFieldMemberAccess(), item, JavaScriptIdentifier, methodFromReferrerScope(), QQmlJSRegisterContent::ObjectById, propertyBindingFromReferrerScope(), propertyFromReferrerScope(), Q_ASSERT_X, QmlComponentIdentifier, QmlObjectIdIdentifier, resolveFieldMemberExpressionType(), SingletonIdentifier, QQmlJSRegisterContent::type(), and QQmlJSRegisterContent::variant().

Referenced by QQmlLSUtils::resolveExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveNameInQmlScope()

static std::optional< SignalOrProperty > resolveNameInQmlScope ( const QString & name,
const QQmlJSScope::ConstPtr & owner )
static

Find out if {name} is a signal, signal handler, property, property changed signal, or a property changed handler in the given QQmlJSScope.

Heuristic to find if name is a property, property changed signal, .... because those can appear under different names, for example {mySignal} and {onMySignal} for a signal. This will give incorrect results as soon as properties/signals/methods are called {onMySignal}, {on<some already existing property>Changed}, ..., but the good news is that the engine also will act weird in these cases (e.g. one cannot bind to a property called like an already existing signal or a property changed handler). For future reference: you can always add additional checks to check the existence of those buggy properties/signals/methods by looking if they exist in the QQmlJSScope.

Definition at line 622 of file qqmllsutils.cpp.

References QQmlSignalNames::changedHandlerNameToPropertyName(), QQmlSignalNames::changedSignalNameToPropertyName(), QQmlSignalNames::handlerNameToSignalName(), QQmlJSScope::hasProperty(), MethodIdentifier, QQmlJSScope::methods(), methods, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, SignalHandlerIdentifier, and SignalIdentifier.

Referenced by namesOfPossibleUsages(), propertyFromReferrerScope(), QQmlLSUtils::renameUsagesOf(), QQmlLSUtils::resolveExpressionType(), and resolveSignalOrPropertyExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveSignalOrPropertyExpressionType()

static std::optional< QQmlLSUtilsExpressionType > resolveSignalOrPropertyExpressionType ( const QString & name,
const QQmlJSScope::ConstPtr & scope,
QQmlLSUtilsResolveOptions options )
static

Definition at line 1396 of file qqmllsutils.cpp.

References findDefiningScopeForMethod(), findDefiningScopeForProperty(), MethodIdentifier, QQmlJSScope::property(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, ResolveActualTypeForFieldMemberExpression, resolveNameInQmlScope(), ResolveOwnerType, SignalHandlerIdentifier, SignalIdentifier, and QQmlJSMetaProperty::type().

Referenced by QQmlLSUtils::resolveExpressionType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: