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>.
|
#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>
Go to the source code of this file.
Classes | |
struct | SignalOrProperty |
|
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().
|
static |
Filter away the parts of the Dom not needed for find usages, by following the profiler's information.
tst_qmlls_utils findUsages
!) and is not needed for usages.tst_qmlls_utils findUsages
.Definition at line 809 of file qqmllsutils.cpp.
References QString::fromUtf16().
Referenced by findUsagesHelper(), and findUsagesOfNonJSIdentifiers().
|
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().
|
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().
|
static |
See also findDefiningScopeForProperty().
Definition at line 778 of file qqmllsutils.cpp.
References findDefiningScopeIf(), and QQmlJSScope::hasOwnEnumeration().
Referenced by QQmlLSUtils::resolveExpressionType().
|
static |
See also findDefiningScopeForProperty().
Definition at line 790 of file qqmllsutils.cpp.
References findDefiningScopeIf(), and QQmlJSScope::hasOwnEnumerationKey().
Referenced by QQmlLSUtils::resolveExpressionType().
|
static |
See also findDefiningScopeForProperty().
Definition at line 766 of file qqmllsutils.cpp.
References findDefiningScopeIf(), and QQmlJSScope::hasOwnMethod().
Referenced by methodFromReferrerScope(), QQmlLSUtils::resolveExpressionType(), and resolveSignalOrPropertyExpressionType().
|
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().
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().
Definition at line 551 of file qqmllsutils.cpp.
Referenced by findJSIdentifierDefinition().
Definition at line 563 of file qqmllsutils.cpp.
References findDefinitionFromItem(), i, and item.
Referenced by findUsagesHelper(), and resolveIdentifierExpressionType().
|
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().
|
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().
|
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().
|
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().
|
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().
|
static |
Definition at line 230 of file qqmllsutils.cpp.
References QList< T >::begin(), QQmlJS::Dom::ColonTokenRegion, QList< T >::end(), and items.
Referenced by filterItemsFromTextLocation().
|
static |
Definition at line 1040 of file qqmllsutils.cpp.
References MethodIdentifier, QQmlJSScope::methods(), methods, and SignalIdentifier.
Referenced by methodFromReferrerScope().
|
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().
|
static |
Definition at line 926 of file qqmllsutils.cpp.
References Q_ASSERT_X.
Referenced by findUsagesHelper().
|
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().
|
static |
Definition at line 1834 of file qqmllsutils.cpp.
References QQmlJSScope::baseType(), Q_ASSERT, and qCDebug.
Referenced by expressionTypeWithDefinition().
|
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().
|
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().
Definition at line 1974 of file qqmllsutils.cpp.
Referenced by QQmlLSUtils::renameUsagesOf().
|
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().
|
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().
|
static |
Definition at line 1815 of file qqmllsutils.cpp.
References QQmlJSScope::baseType(), Q_ASSERT, and qCDebug.
Referenced by expressionTypeWithDefinition().
|
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().
|
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().
|
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().
|
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().