![]() |
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>.
|
Classes | |
struct | Edit |
struct | ErrorMessage |
struct | ExpressionType |
struct | FileRename |
Represents a rename operation where the file itself needs to be renamed. More... | |
struct | ItemLocation |
struct | Location |
class | RenameUsages |
Represents the locations where a renaming should take place. More... | |
struct | SignalOrProperty |
struct | TextPosition |
class | Usages |
Represents the locations where some highlighting should take place, like in the "find all
references" feature of the LSP. More... | |
Typedefs | |
using | DomItem = QQmlJS::Dom::DomItem |
Definition at line 229 of file qqmllsutils_p.h.
enum QQmlLSUtils::IdentifierType : char |
Definition at line 44 of file qqmllsutils_p.h.
Choose whether to resolve the owner type or the entire type (the latter is only required to resolve the types of qualified names and property accesses).
For properties, methods, enums and co: ResolveOwnerType returns the base type of the owner that owns the property, method, enum and co. For example, resolving "x" in "myRectangle.x" will return the Item as the owner, as Item is the base type of Rectangle that defines the "x" property. ResolveActualTypeForFieldMemberExpression is used to resolve field member expressions, and might lose some information about the owner. For example, resolving "x" in "myRectangle.x" will return the JS type for float that was used to define the "x" property.
Enumerator | |
---|---|
ResolveOwnerType | |
ResolveActualTypeForFieldMemberExpression |
Definition at line 224 of file qqmllsutils_p.h.
Definition at line 389 of file qqmllsutils.cpp.
References base, baseObject(), QQmlJS::Dom::DomItem::component(), QQmlJS::Dom::DomItem::field(), QQmlJS::Dom::DomItem::index(), qDebug, and QQmlJS::Dom::DomItem::qmlObject().
Referenced by baseObject(), and findTypeDefinitionOf().
std::optional< ErrorMessage > QQmlLSUtils::checkNameForRename | ( | const DomItem & | item, |
const QString & | dirtyNewName, | ||
const std::optional< ExpressionType > & | ownerType ) |
Definition at line 1870 of file qqmllsutils.cpp.
References checkNameForRename(), expressionTypeWithDefinition(), QQmlSignalNames::isChangedHandlerName(), QQmlSignalNames::isChangedSignalName(), QQmlSignalNames::isHandlerName(), isValidEcmaScriptIdentifier(), item, JavaScriptIdentifier, MethodIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, QmlObjectIdIdentifier, resolveExpressionType(), ResolveOwnerType, SignalHandlerIdentifier, and SignalIdentifier.
Referenced by checkNameForRename(), and QQmlRenameSymbolSupport::process().
QPair< QString, QStringList > QQmlLSUtils::cmakeBuildCommand | ( | const QString & | path | ) |
Returns the name of the cmake program along with the arguments needed to build the qmltyperegistration. This command generates the .qmltypes, qmldir and .qrc files required for qmlls to provide correct information on C++ defined QML elements.
We assume here that CMake is available in the path. This should be the case for linux and macOS by default. For windows, having CMake in the path is not too unrealistic, for example, https://doc.qt.io/qt-6/windows-building.html#step-2-install-build-requirements claims that you need to have CMake in your path to build Qt. So a developer machine running qmlls has a high chance of having CMake in their path, if CMake is installed and used.
Definition at line 2152 of file qqmllsutils.cpp.
References cmakeBuildCommand().
Referenced by cmakeBuildCommand().
|
static |
Definition at line 1835 of file qqmllsutils.cpp.
References AttachedTypeIdentifier, QQmlSignalNames::changedHandlerNameToPropertyName(), QQmlSignalNames::changedSignalNameToPropertyName(), EnumeratorIdentifier, EnumeratorValueIdentifier, expressionTypeWithDefinition(), GroupedPropertyIdentifier, QQmlSignalNames::handlerNameToSignalName(), JavaScriptIdentifier, MethodIdentifier, methodOwnerFrom(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, propertyOwnerFrom(), QmlComponentIdentifier, QmlObjectIdIdentifier, SignalHandlerIdentifier, SignalIdentifier, and SingletonIdentifier.
Referenced by checkNameForRename(), and expressionTypeWithDefinition().
QStringList QQmlLSUtils::fieldMemberExpressionBits | ( | const DomItem & | item, |
const DomItem & | stopAtChild ) |
Get the bits of a field member expression, like {a},
{b} and
{c} for
{a.b.c}.
stopAtChild can either be an FieldMemberExpression, a ScriptIdentifierExpression or a default constructed DomItem: This exits early before processing Field::right of an FieldMemberExpression stopAtChild, or before processing a ScriptIdentifierExpression stopAtChild. No early exits if stopAtChild is default constructed.
Definition at line 89 of file qqmllsutils.cpp.
References QQmlJS::Dom::DomItem::field(), fieldMemberExpressionBits(), isFieldMemberAccess(), isFieldMemberExpression(), item, QCborValue::toString(), and QQmlJS::Dom::DomItem::value().
Referenced by fieldMemberExpressionBits(), findTypeDefinitionOf(), and qualifiersFrom().
|
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 806 of file qqmllsutils.cpp.
References filterForFindUsages(), and QString::fromUtf16().
Referenced by filterForFindUsages(), findUsagesHelper(), and findUsagesOfNonJSIdentifiers().
|
static |
Definition at line 279 of file qqmllsutils.cpp.
References QList< T >::begin(), QSet< T >::begin(), QQmlJS::SourceLocation::begin(), QList< T >::end(), filterItemsFromTextLocation(), handlePropertyDefinitionAndBindingOverlap(), it, items, and QList< T >::size().
Referenced by filterItemsFromTextLocation(), and itemsFromTextLocation().
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForBinding | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Special case: you can also bind to a signal handler.
Definition at line 751 of file qqmllsutils.cpp.
References findDefiningScopeForBinding(), findDefiningScopeIf(), QQmlJSScope::hasOwnMethod(), and QQmlJSScope::hasOwnProperty().
Referenced by findDefiningScopeForBinding(), and resolveExpressionType().
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForEnumeration | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Definition at line 775 of file qqmllsutils.cpp.
References findDefiningScopeForEnumeration(), findDefiningScopeIf(), and QQmlJSScope::hasOwnEnumeration().
Referenced by findDefiningScopeForEnumeration(), and resolveExpressionType().
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForEnumerationKey | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Definition at line 787 of file qqmllsutils.cpp.
References findDefiningScopeForEnumerationKey(), findDefiningScopeIf(), and QQmlJSScope::hasOwnEnumerationKey().
Referenced by findDefiningScopeForEnumerationKey(), and resolveExpressionType().
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForMethod | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Definition at line 763 of file qqmllsutils.cpp.
References findDefiningScopeForMethod(), findDefiningScopeIf(), and QQmlJSScope::hasOwnMethod().
Referenced by findDefiningScopeForMethod(), methodFromReferrerScope(), resolveExpressionType(), and resolveSignalOrPropertyExpressionType().
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForProperty | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
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 737 of file qqmllsutils.cpp.
References findDefiningScopeForProperty(), findDefiningScopeIf(), and QQmlJSScope::hasOwnProperty().
Referenced by findDefiningScopeForProperty(), propertyBindingFromReferrerScope(), propertyFromReferrerScope(), resolveExpressionType(), and resolveSignalOrPropertyExpressionType().
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeIf | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
Predicate && | check ) |
Definition at line 714 of file qqmllsutils.cpp.
References findDefiningScopeIf(), and QQmlJSUtils::searchBaseAndExtensionTypes().
Referenced by findDefiningScopeForBinding(), findDefiningScopeForEnumeration(), findDefiningScopeForEnumerationKey(), findDefiningScopeForMethod(), findDefiningScopeForProperty(), and findDefiningScopeIf().
|
static |
Definition at line 546 of file qqmllsutils.cpp.
References findDefinitionFromItem(), item, and qCDebug.
Referenced by findDefinitionFromItem(), and findJSIdentifierDefinition().
Definition at line 1724 of file qqmllsutils.cpp.
References AttachedTypeIdentifier, QQmlJS::Dom::DomItem::component(), EnumeratorIdentifier, EnumeratorValueIdentifier, QQmlJS::Dom::DomItem::field(), findDefinitionOf(), findMethodDefinitionOf(), findPropertyDefinitionOf(), GroupedPropertyIdentifier, QQmlJS::Dom::DomItem::index(), item, JavaScriptIdentifier, QQmlJS::Dom::DomItem::key(), MethodIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, qCDebug, QmlComponentIdentifier, QmlObjectIdIdentifier, resolveExpressionType(), SignalHandlerIdentifier, SignalIdentifier, SingletonIdentifier, sourceLocationToDomItem(), and QQmlJS::Dom::FileLocations::treeOf().
Referenced by findDefinitionOf(), and QmlGoToDefinitionSupport::process().
|
static |
Definition at line 558 of file qqmllsutils.cpp.
References QQmlJS::Dom::DomItem::field(), findDefinitionFromItem(), findJSIdentifierDefinition(), i, and item.
Referenced by findJSIdentifierDefinition(), findUsagesHelper(), and resolveIdentifierExpressionType().
|
static |
Definition at line 1681 of file qqmllsutils.cpp.
References QSet< T >::constEnd(), QSet< T >::constFind(), QQmlJS::Dom::DomItem::field(), file, findMethodDefinitionOf(), QQmlJS::Dom::IdentifierRegion, QQmlJS::Dom::DomItem::index(), it, QQmlJS::Dom::DomItem::key(), method, QQmlJS::Dom::DomItem::qmlObject(), sourceLocationToDomItem(), and QQmlJS::Dom::FileLocations::treeOf().
Referenced by findDefinitionOf(), and findMethodDefinitionOf().
|
static |
Definition at line 1702 of file qqmllsutils.cpp.
References QSet< T >::constEnd(), QSet< T >::constFind(), QQmlJS::Dom::DomItem::field(), file, findPropertyDefinitionOf(), QQmlJS::Dom::IdentifierRegion, QQmlJS::Dom::DomItem::index(), it, QQmlJS::Dom::DomItem::key(), QQmlJS::Dom::DomItem::qmlObject(), sourceLocationToDomItem(), and QQmlJS::Dom::FileLocations::treeOf().
Referenced by findDefinitionOf(), and findPropertyDefinitionOf().
|
static |
Finds the scope within the special elements like Connections, PropertyChanges, Bindings or AnchorChanges.
Definition at line 1191 of file qqmllsutils.cpp.
References QQmlJS::Dom::DomItem::bindings(), findScopeOfSpecialItems(), QQmlJSScope::hasOwnPropertyBindings(), QQmlJS::Dom::DomItem::index(), QString::isEmpty(), item, QQmlJS::Dom::DomItem::key(), QQmlJSScope::parentScope(), QQmlJSUtils::searchBaseAndExtensionTypes(), and typeName.
Referenced by findScopeOfSpecialItems(), and resolveExpressionType().
Returns the location of the type definition pointed by object.
For a PropertyDefinition
, return the location of the type of the property. For a Binding
, return the bound item's type location if an QmlObject is bound, and otherwise the type of the property. For a QmlObject
, return the location of the QmlObject's base. For an Id
, return the location of the object to which the id resolves. For a Methodparameter
, return the location of the type of the parameter. Otherwise, return std::nullopt.
Definition at line 444 of file qqmllsutils.cpp.
References baseObject(), QQmlJS::Dom::Binding, QQmlJS::Dom::DomItem::field(), fieldMemberExpressionBits(), findTypeDefinitionOf(), QQmlJS::Dom::Id, QQmlJS::Dom::DomItem::index(), item, locationFromDomItem(), QQmlJS::Dom::Paths::lookupTypePath(), QQmlJS::Dom::MethodInfo, QQmlJS::Dom::MethodParameter, QQmlJS::Dom::PropertyDefinition, Q_ASSERT, qDebug, QQmlJS::Dom::QmlComponent, QQmlJS::Dom::QmlObject, QmlObjectIdIdentifier, resolveExpressionType(), QQmlJS::Dom::ScriptIdentifierExpression, QQmlLSUtils::Location::sourceLocation, and sourceLocationToDomItem().
Referenced by findTypeDefinitionOf(), and QmlGoToTypeDefinitionSupport::process().
|
static |
Definition at line 941 of file qqmllsutils.cpp.
References QQmlJS::Dom::emptyChildrenVisitor(), fileName, filterForFindUsages(), findJSIdentifierDefinition(), findUsagesHelper(), findUsagesOfNonJSIdentifiers(), item, locationFromJSIdentifierDefinition(), qCDebug, qCWarning, and QQmlJS::Dom::FileLocations::treeOf().
Referenced by findUsagesHelper(), and findUsagesOf().
Definition at line 982 of file qqmllsutils.cpp.
References findUsagesHelper(), findUsagesOf(), item, and qCDebug.
Referenced by findUsagesOf(), QQmlFindUsagesSupport::process(), and renameUsagesOf().
|
static |
Definition at line 817 of file qqmllsutils.cpp.
References QQmlJS::Dom::emptyChildrenVisitor(), QQmlJS::Dom::DomItem::field(), file, filterForFindUsages(), findUsagesOfNonJSIdentifiers(), QQmlJS::Dom::IdentifierRegion, QQmlJS::SourceLocation::isValid(), item, QQmlJS::Dom::DomItem::key(), QQmlJS::Dom::DomItem::keys(), QQmlJS::Dom::MainRegion, namesOfPossibleUsages(), QmlComponentIdentifier, QQmlJS::Dom::FileLocations::region(), resolveExpressionType(), ResolveOwnerType, QQmlJS::Dom::FileLocations::treeOf(), and QQmlJS::Dom::DomItem::visitTree().
Referenced by findUsagesHelper(), and findUsagesOfNonJSIdentifiers().
|
static |
Definition at line 230 of file qqmllsutils.cpp.
References QList< T >::begin(), QQmlJS::Dom::ColonTokenRegion, QList< T >::end(), handlePropertyDefinitionAndBindingOverlap(), and items.
Referenced by filterItemsFromTextLocation(), and handlePropertyDefinitionAndBindingOverlap().
|
static |
Definition at line 1038 of file qqmllsutils.cpp.
References hasMethodOrSignal(), QQmlJSScope::methods(), and methods.
Referenced by hasMethodOrSignal(), and methodFromReferrerScope().
bool QQmlLSUtils::isFieldMemberAccess | ( | const DomItem & | item | ) |
Helper to check if item is a Field Member Access memberAccess
in {
<someExpression>.memberAccess}.
Definition at line 70 of file qqmllsutils.cpp.
References QQmlJS::Dom::DomItem::field(), isFieldMemberAccess(), isFieldMemberExpression(), and item.
Referenced by fieldMemberExpressionBits(), isFieldMemberAccess(), qualifiersFrom(), and resolveIdentifierExpressionType().
bool QQmlLSUtils::isFieldMemberExpression | ( | const DomItem & | item | ) |
Helper to check if item is a Field Member Expression {
<someExpression>.propertyName}.
Definition at line 58 of file qqmllsutils.cpp.
References QQmlJS::Dom::ScriptElements::BinaryExpression::FieldMemberAccess, isFieldMemberExpression(), and item.
Referenced by fieldMemberExpressionBits(), isFieldMemberAccess(), isFieldMemberExpression(), qualifiersFrom(), and resolveExpressionType().
bool QQmlLSUtils::isValidEcmaScriptIdentifier | ( | QStringView | identifier | ) |
Definition at line 2126 of file qqmllsutils.cpp.
References isValidEcmaScriptIdentifier(), QQmlJS::Lexer::lex(), QQmlJS::Lexer::setCode(), token, and QStringView::toString().
Referenced by checkNameForRename(), and isValidEcmaScriptIdentifier().
QList< ItemLocation > QQmlLSUtils::itemsFromTextLocation | ( | const DomItem & | file, |
int | line, | ||
int | character ) |
Find the DomItem representing the object situated in file at given line and character/column.
If line and character point between two objects, two objects might be returned. If line and character point to whitespace, it might return an inner node of the QmlDom-Tree.
Definition at line 323 of file qqmllsutils.cpp.
References QSet< T >::begin(), QQmlLSUtils::ItemLocation::domItem, QSet< T >::end(), file, QQmlLSUtils::ItemLocation::fileLocation, QQmlJS::Dom::QmlFile::fileLocationsTree(), filterItemsFromTextLocation(), it, itemsFromTextLocation(), line, QQmlJS::Dom::DomItem::path(), Q_ASSERT, qCDebug, and textOffsetFrom().
Referenced by CompletionRequest::completions(), HelpManager::documentationForItem(), QQmlBaseModule< RequestType >::itemsForRequest(), itemsFromTextLocation(), and sourceLocationToDomItem().
|
static |
Definition at line 416 of file qqmllsutils.cpp.
References QQmlLSUtils::Location::filename, item, locationFromDomItem(), QQmlJS::Dom::MainRegion, QQmlJS::Dom::FileLocations::region(), and QQmlJS::Dom::FileLocations::treeOf().
Referenced by findTypeDefinitionOf(), and locationFromDomItem().
|
static |
Definition at line 926 of file qqmllsutils.cpp.
References locationFromJSIdentifierDefinition(), and Q_ASSERT_X.
Referenced by findUsagesHelper(), and locationFromJSIdentifierDefinition().
QByteArray QQmlLSUtils::lspUriToQmlUrl | ( | const QByteArray & | uri | ) |
The language server protocol calls "URI" what QML calls "URL". According to RFC 3986, a URL is a special case of URI that not only identifies a resource but also shows how to access it. In QML, however, URIs are distinct from URLs. URIs are the identifiers of modules, for example "QtQuick.Controls". In order to not confuse the terms we interpret language server URIs as URLs in the QML code model. This method marks a point of translation between the terms, but does not have to change the actual URI/URL.
Definition at line 130 of file qqmllsutils.cpp.
References lspUriToQmlUrl().
Referenced by WorkspaceHandlers::clientInitialized(), TextSynchronization::didCloseTextDocument(), TextSynchronization::didDidChangeTextDocument(), TextSynchronization::didOpenTextDocument(), QQmlBaseModule< RequestType >::itemsForRequest(), lspUriToQmlUrl(), SemanticTokenDeltaHandler::process(), SemanticTokenRangeHandler::process(), SemanticTokenFullHandler::process(), QQmlDocumentFormatting::process(), QQmlHover::process(), QQmlRangeFormatting::process(), WorkspaceHandlers::registerHandlers(), and QQmlBaseModule< RequestType >::requestHandler().
|
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 1062 of file qqmllsutils.cpp.
References findDefiningScopeForMethod(), QQmlSignalNames::handlerNameToSignalName(), hasMethodOrSignal(), methodFromReferrerScope(), QQmlJSScope::parentScope(), ResolveActualTypeForFieldMemberExpression, ResolveOwnerType, and SignalHandlerIdentifier.
Referenced by methodFromReferrerScope(), resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().
|
static |
Definition at line 1816 of file qqmllsutils.cpp.
References QQmlJSScope::baseType(), methodOwnerFrom(), Q_ASSERT, and qCDebug.
Referenced by expressionTypeWithDefinition(), and methodOwnerFrom().
|
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 658 of file qqmllsutils.cpp.
References item, namesOfPossibleUsages(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, QQmlSignalNames::propertyNameToChangedHandlerName(), QQmlSignalNames::propertyNameToChangedSignalName(), resolveNameInQmlScope(), SignalHandlerIdentifier, SignalIdentifier, and QQmlSignalNames::signalNameToHandlerName().
Referenced by findUsagesOfNonJSIdentifiers(), and namesOfPossibleUsages().
|
static |
Definition at line 1972 of file qqmllsutils.cpp.
References QQmlSignalNames::changedHandlerNameToPropertyName(), QQmlSignalNames::changedSignalNameToPropertyName(), QQmlSignalNames::handlerNameToSignalName(), newNameFrom(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, SignalHandlerIdentifier, and SignalIdentifier.
Referenced by newNameFrom(), and renameUsagesOf().
Definition at line 1950 of file qqmllsutils.cpp.
References item, oldNameFrom(), and qCDebug.
Referenced by oldNameFrom(), and 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 1132 of file qqmllsutils.cpp.
References AssumeComponentsAreBound, QQmlSA::AttachedProperty, AttachedTypeIdentifier, findDefiningScopeForProperty(), getScope(), GroupedPropertyIdentifier, QQmlSA::GroupProperty, propertyBindingFromReferrerScope(), QmlObjectIdIdentifier, ResolveActualTypeForFieldMemberExpression, and ResolveOwnerType.
Referenced by propertyBindingFromReferrerScope(), resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().
|
static |
See comment on methodFromReferrerScope: the same applies to properties.
Definition at line 1102 of file qqmllsutils.cpp.
References findDefiningScopeForProperty(), QQmlJSScope::parentScope(), property, propertyFromReferrerScope(), ResolveActualTypeForFieldMemberExpression, resolveNameInQmlScope(), and ResolveOwnerType.
Referenced by propertyFromReferrerScope(), resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().
|
static |
Definition at line 1797 of file qqmllsutils.cpp.
References QQmlJSScope::baseType(), propertyOwnerFrom(), Q_ASSERT, and qCDebug.
Referenced by expressionTypeWithDefinition(), and propertyOwnerFrom().
QLspSpecification::Range QQmlLSUtils::qmlLocationToLspLocation | ( | const QString & | code, |
QQmlJS::SourceLocation | qmlLocation ) |
Converts a QQmlJS::SourceLocation to a LSP Range.
QQmlJS::SourceLocation starts counting lines and rows at 1, but the LSP Range starts at 0. Also, the QQmlJS::SourceLocation contains startLine, startColumn and length while the LSP Range contains startLine, startColumn, endLine and endColumn, which must be computed from the actual qml code.
Definition at line 149 of file qqmllsutils.cpp.
References QString::end(), qmlLocationToLspLocation(), and textRowAndColumnFrom().
Referenced by QQmlFindUsagesSupport::process(), QmlGoToDefinitionSupport::process(), QmlGoToTypeDefinitionSupport::process(), QQmlRenameSymbolSupport::process(), and qmlLocationToLspLocation().
QByteArray QQmlLSUtils::qmlUrlToLspUri | ( | const QByteArray & | url | ) |
Definition at line 135 of file qqmllsutils.cpp.
References qmlUrlToLspUri(), and url.
Referenced by qmlUrlToLspUri().
Definition at line 36 of file qqmllsutils.cpp.
References el, fieldMemberExpressionBits(), isFieldMemberAccess(), isFieldMemberExpression(), item, and qualifiersFrom().
Referenced by qualifiersFrom(), QQmlLSQuickCompletionPlugin::suggestSnippetsForLeftHandSideOfBinding(), and QQmlLSQuickCompletionPlugin::suggestSnippetsForRightHandSideOfBinding().
RenameUsages QQmlLSUtils::renameUsagesOf | ( | const DomItem & | item, |
const QString & | dirtyNewName, | ||
const std::optional< ExpressionType > & | targetType ) |
Rename the appearance of item to newName.
Special cases: \list
All of the chopping operations are done using the static helpers from QQmlSignalNames. \endlist
Definition at line 2013 of file qqmllsutils.cpp.
References QDir::cleanPath(), edit, extension(), findUsagesOf(), info, item, newNameFrom(), oldNameFrom(), QQmlSignalNames::propertyNameToChangedHandlerName(), QQmlSignalNames::propertyNameToChangedSignalName(), qCDebug, renameUsagesOf(), resolveExpressionType(), resolveNameInQmlScope(), and QQmlSignalNames::signalNameToHandlerName().
Referenced by QQmlRenameSymbolSupport::process(), and renameUsagesOf().
std::optional< ExpressionType > QQmlLSUtils::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).
Definition at line 1431 of file qqmllsutils.cpp.
References component(), EnumeratorIdentifier, EnumeratorValueIdentifier, findDefiningScopeForBinding(), findDefiningScopeForEnumeration(), findDefiningScopeForEnumerationKey(), findDefiningScopeForMethod(), findDefiningScopeForProperty(), findScopeOfSpecialItems(), GroupedPropertyIdentifier, isFieldMemberExpression(), item, QQmlLSUtils::ExpressionType::name, PropertyIdentifier, qCDebug, qDebug, QmlComponentIdentifier, QmlObjectIdIdentifier, ResolveActualTypeForFieldMemberExpression, resolveExpressionType(), resolveIdentifierExpressionType(), resolveNameInQmlScope(), ResolveOwnerType, resolveSignalOrPropertyExpressionType(), and QQmlJS::Dom::AttributeInfo::semanticScope().
Referenced by checkNameForRename(), findDefinitionOf(), findTypeDefinitionOf(), findUsagesOfNonJSIdentifiers(), QQmlRenameSymbolSupport::process(), renameUsagesOf(), resolveExpressionType(), and resolveFieldMemberExpressionType().
|
static |
Definition at line 1251 of file qqmllsutils.cpp.
References EnumeratorIdentifier, EnumeratorValueIdentifier, QQmlJS::Dom::DomItem::field(), it, item, methodFromReferrerScope(), propertyBindingFromReferrerScope(), propertyFromReferrerScope(), qCDebug, QmlComponentIdentifier, resolveExpressionType(), and resolveFieldMemberExpressionType().
Referenced by resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().
|
static |
Definition at line 1302 of file qqmllsutils.cpp.
References AssumeComponentsAreBound, findJSIdentifierDefinition(), isFieldMemberAccess(), item, methodFromReferrerScope(), propertyBindingFromReferrerScope(), propertyFromReferrerScope(), Q_ASSERT_X, QmlComponentIdentifier, QmlObjectIdIdentifier, resolveFieldMemberExpressionType(), and resolveIdentifierExpressionType().
Referenced by resolveExpressionType(), and resolveIdentifierExpressionType().
|
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 617 of file qqmllsutils.cpp.
References QQmlSignalNames::changedHandlerNameToPropertyName(), QQmlSignalNames::changedSignalNameToPropertyName(), QQmlSignalNames::handlerNameToSignalName(), QQmlJSScope::hasProperty(), MethodIdentifier, QQmlJSScope::methods(), methods, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, resolveNameInQmlScope(), SignalHandlerIdentifier, and SignalIdentifier.
Referenced by namesOfPossibleUsages(), propertyFromReferrerScope(), renameUsagesOf(), resolveExpressionType(), resolveNameInQmlScope(), and resolveSignalOrPropertyExpressionType().
|
static |
Definition at line 1379 of file qqmllsutils.cpp.
References findDefiningScopeForMethod(), findDefiningScopeForProperty(), MethodIdentifier, QQmlJSScope::property(), PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, ResolveActualTypeForFieldMemberExpression, resolveNameInQmlScope(), ResolveOwnerType, resolveSignalOrPropertyExpressionType(), SignalHandlerIdentifier, SignalIdentifier, and QQmlJSMetaProperty::type().
Referenced by resolveExpressionType(), and resolveSignalOrPropertyExpressionType().
DomItem QQmlLSUtils::sourceLocationToDomItem | ( | const DomItem & | file, |
const QQmlJS::SourceLocation & | location ) |
Definition at line 1645 of file qqmllsutils.cpp.
References QList< T >::back(), file, QList< T >::front(), items, itemsFromTextLocation(), Q_ASSERT_X, qDebug, QList< T >::size(), and sourceLocationToDomItem().
Referenced by findDefinitionOf(), findMethodDefinitionOf(), findPropertyDefinitionOf(), findTypeDefinitionOf(), and sourceLocationToDomItem().
Convert a text position from (line, column) into an offset.
Row, Column and the offset are all 0-based. For example, {s[textOffsetFrom(s, 5, 55)]} returns the character of s at line 5 and column 55.
Definition at line 172 of file qqmllsutils.cpp.
References QString::at(), i, QString::size(), text, and textOffsetFrom().
Referenced by CompletionRequest::completions(), QQmlLSUtils::Location::from(), itemsFromTextLocation(), SemanticTokenRangeHandler::process(), QQmlRangeFormatting::process(), and textOffsetFrom().
TextPosition QQmlLSUtils::textRowAndColumnFrom | ( | const QString & | text, |
qsizetype | offset ) |
Convert a text position from an offset into (line, column).
Row, Column and the offset are all 0-based. For example, {textRowAndColumnFrom(s, 55)} returns the line and columns of the character at
{s
[55]}.
Definition at line 209 of file qqmllsutils.cpp.
References i, text, and textRowAndColumnFrom().
Referenced by QQmlDocumentFormatting::process(), QQmlRangeFormatting::process(), qmlLocationToLspLocation(), and textRowAndColumnFrom().