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

(613fb99dacb54c32ca8c66fa4e7e6770e7fc6fb5)

#include "qqmllsutils_p.h"
#include <QtCore/qassert.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 <memory>
#include <optional>
#include <queue>
#include <utility>
Include dependency graph for qqmllsutils.cpp:

Go to the source code of this file.

Classes

struct  QQmlLSUtils::SignalOrProperty

Namespaces

namespace  QQmlLSUtils

Enumerations

enum  QQmlLSUtils::SearchOption { QQmlLSUtils::FindFirst , QQmlLSUtils::FindAll , QQmlLSUtils::FindFirst , QQmlLSUtils::FindAll }
enum  QQmlLSUtils::SearchOption { QQmlLSUtils::FindFirst , QQmlLSUtils::FindAll , QQmlLSUtils::FindFirst , QQmlLSUtils::FindAll }

Functions

QString QQmlLSUtils::qualifiersFrom (const DomItem &el)
bool QQmlLSUtils::isFieldMemberExpression (const DomItem &item)
bool QQmlLSUtils::isFieldMemberAccess (const DomItem &item)
bool QQmlLSUtils::isFieldMemberBase (const DomItem &item)
QStringList QQmlLSUtils::fieldMemberExpressionBits (const DomItem &item, const DomItem &stopAtChild={})
QByteArray QQmlLSUtils::lspUriToQmlUrl (const QByteArray &uri)
QByteArray QQmlLSUtils::qmlUrlToLspUri (const QByteArray &url)
QLspSpecification::Range QQmlLSUtils::qmlLocationToLspLocation (Location qmlLocation)
 Converts a QQmlJS::SourceLocation to a LSP Range.
qsizetype QQmlLSUtils::textOffsetFrom (const QString &text, int row, int column)
 Convert a text position from (line, column) into an offset.
TextPosition QQmlLSUtils::textRowAndColumnFrom (const QString &text, qsizetype offset)
 Convert a text position from an offset into (line, column).
static QList< ItemLocation >::const_iterator QQmlLSUtils::handlePropertyDefinitionAndBindingOverlap (const QList< ItemLocation > &items, qsizetype offsetInFile)
static QList< ItemLocationQQmlLSUtils::filterItemsFromTextLocation (const QList< ItemLocation > &items, qsizetype offsetInFile)
QList< ItemLocationQQmlLSUtils::itemsFromTextLocation (const DomItem &file, int line, int character)
 Find the DomItem representing the object situated in file at given line and character/column.
DomItem QQmlLSUtils::baseObject (const DomItem &qmlObject)
static std::optional< LocationQQmlLSUtils::locationFromDomItem (const DomItem &item, FileLocationRegion region)
std::optional< LocationQQmlLSUtils::findTypeDefinitionOf (const DomItem &object)
 Returns the location of the type definition pointed by object.
static bool QQmlLSUtils::findDefinitionFromItem (const DomItem &item, const QString &name)
static DomItem QQmlLSUtils::findJSIdentifierDefinition (const DomItem &item, const QString &name)
static std::optional< SignalOrPropertyQQmlLSUtils::resolveNameInQmlScope (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 QQmlLSUtils::namesOfPossibleUsages (const QString &name, const DomItem &item, const QQmlJSScope::ConstPtr &targetType)
template<typename Predicate>
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeIf (const QQmlJSScope::ConstPtr &referrerScope, Predicate &&check)
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForProperty (const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
 Finds the scope where a property is first defined.
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForBinding (const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForMethod (const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForEnumeration (const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForEnumerationKey (const QQmlJSScope::ConstPtr &referrerScope, const QString &nameToCheck)
static FieldFilter QQmlLSUtils::filterForFindUsages ()
 Filter away the parts of the Dom not needed for find usages, by following the profiler's information.
static void QQmlLSUtils::findUsagesOfNonJSIdentifiers (const DomItem &item, const QString &name, Usages &result)
static std::optional< LocationQQmlLSUtils::locationFromJSIdentifierDefinition (const DomItem &definitionOfItem, const QString &name)
static void QQmlLSUtils::findUsagesHelper (const DomItem &item, const QString &name, Usages &result)
Usages QQmlLSUtils::findUsagesOf (const DomItem &item)
static std::optional< IdentifierTypeQQmlLSUtils::hasMethodOrSignal (const QQmlJSScope::ConstPtr &scope, const QString &name)
static std::optional< ExpressionTypeQQmlLSUtils::methodFromReferrerScope (const QQmlJSScope::ConstPtr &referrerScope, const QString &name, ResolveOptions options)
static std::optional< ExpressionTypeQQmlLSUtils::propertyFromReferrerScope (const QQmlJSScope::ConstPtr &referrerScope, const QString &propertyName, ResolveOptions options)
static std::optional< ExpressionTypeQQmlLSUtils::propertyBindingFromReferrerScope (const QQmlJSScope::ConstPtr &referrerScope, const QString &name, ResolveOptions options, QQmlJSTypeResolver *resolverForIds)
static QQmlJSScope::ConstPtr QQmlLSUtils::findScopeOfSpecialItems (const QQmlJSScope::ConstPtr &scope, const DomItem &item)
static std::optional< ExpressionTypeQQmlLSUtils::resolveTypeName (const std::shared_ptr< QQmlJSTypeResolver > &resolver, const QString &name, const DomItem &item, ResolveOptions options)
 Distinguishes singleton types from attached types and "regular" qml components.
static std::optional< ExpressionTypeQQmlLSUtils::resolveFieldMemberExpressionType (const DomItem &item, ResolveOptions options)
static std::optional< ExpressionTypeQQmlLSUtils::resolveBindingIfSignalHandler (const DomItem &functionExpression)
static std::optional< ExpressionTypeQQmlLSUtils::resolveSignalHandlerParameterType (const DomItem &parameterDefinition, const QString &name, ResolveOptions options)
static std::optional< ExpressionTypeQQmlLSUtils::resolveIdentifierExpressionType (const DomItem &item, ResolveOptions options)
static std::optional< ExpressionTypeQQmlLSUtils::resolveSignalOrPropertyExpressionType (const QString &name, const QQmlJSScope::ConstPtr &scope, ResolveOptions options)
std::optional< ExpressionTypeQQmlLSUtils::resolveExpressionType (const QQmlJS::Dom::DomItem &item, ResolveOptions options)
 Resolves the type of the given DomItem, when possible (e.g., when there are enough type annotations).
DomItem QQmlLSUtils::sourceLocationToDomItem (const DomItem &file, const QQmlJS::SourceLocation &location)
static std::optional< LocationQQmlLSUtils::findEnumDefinitionOf (const DomItem &file, QQmlJS::SourceLocation location, const QString &name)
static std::optional< LocationQQmlLSUtils::findMethodDefinitionOf (const DomItem &file, QQmlJS::SourceLocation location, const QString &name)
static std::optional< LocationQQmlLSUtils::findPropertyDefinitionOf (const DomItem &file, QQmlJS::SourceLocation propertyDefinitionLocation, const QString &name)
static QQmlJS::SourceLocation QQmlLSUtils::sourceLocationOrDefault (const QQmlJS::SourceLocation &location)
static std::optional< LocationQQmlLSUtils::createCppTypeLocation (const QQmlJSScope::ConstPtr &type, const QStringList &headerLocations, const QQmlJS::SourceLocation &location)
static std::optional< LocationQQmlLSUtils::findDefinitionOfType (const QQmlJSScope::ConstPtr &scope, const DomItem &item, const QStringList &headerDirectories)
std::optional< LocationQQmlLSUtils::findDefinitionOf (const DomItem &item, const QStringList &headerDirectories)
static QQmlJSScope::ConstPtr QQmlLSUtils::propertyOwnerFrom (const QQmlJSScope::ConstPtr &type, const QString &name)
static QQmlJSScope::ConstPtr QQmlLSUtils::methodOwnerFrom (const QQmlJSScope::ConstPtr &type, const QString &name)
static QQmlJSScope::ConstPtr QQmlLSUtils::expressionTypeWithDefinition (const ExpressionType &ownerType)
std::optional< ErrorMessageQQmlLSUtils::checkNameForRename (const DomItem &item, const QString &newName, const std::optional< ExpressionType > &targetType=std::nullopt)
static std::optional< QStringQQmlLSUtils::oldNameFrom (const DomItem &item)
static std::optional< QStringQQmlLSUtils::newNameFrom (const QString &dirtyNewName, IdentifierType alternative)
RenameUsages QQmlLSUtils::renameUsagesOf (const DomItem &item, const QString &dirtyNewName, const std::optional< ExpressionType > &targetType)
 Rename the appearance of item to newName.
bool QQmlLSUtils::isValidEcmaScriptIdentifier (QStringView view)
std::pair< QString, QStringListQQmlLSUtils::cmakeBuildCommand (const QString &path)
static QStringList QQmlLSUtils::findFilePathsFromFileNamesImpl (const QStringList &rootDirs, const QStringList &fileNamesToSearch, SearchOption option, const QSet< QString > &ignoredFilePaths)
QStringList QQmlLSUtils::findFilePathsFromFileNames (const QString &rootDir, const QStringList &fileNamesToSearch, const QSet< QString > &ignoredPaths)
QString QQmlLSUtils::findFilePathFromFileName (const QStringList &rootDirs, const QString &fileNameToSearch, const QSet< QString > &ignoredPaths)