![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
Classes | |
struct | Edit |
struct | ErrorMessage |
struct | ExpressionType |
struct | FileRename |
Represents a rename operation where the file itself needs to be renamed. More... | |
struct | ItemLocation |
class | 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 259 of file qqmllsutils_p.h.
Definition at line 45 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 254 of file qqmllsutils_p.h.
Enumerator | |
---|---|
FindFirst | |
FindAll | |
FindFirst | |
FindAll |
Definition at line 2554 of file qqmllsutils.cpp.
Enumerator | |
---|---|
FindFirst | |
FindAll | |
FindFirst | |
FindAll |
Definition at line 2554 of file qqmllsutils.cpp.
Definition at line 394 of file qqmllsutils.cpp.
std::optional< ErrorMessage > QQmlLSUtils::checkNameForRename | ( | const DomItem & | item, |
const QString & | newName, | ||
const std::optional< ExpressionType > & | targetType = std::nullopt ) |
Definition at line 2221 of file qqmllsutils.cpp.
References JavaScriptIdentifier, MethodIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, QmlObjectIdIdentifier, SignalHandlerIdentifier, and SignalIdentifier.
std::pair< 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 2520 of file qqmllsutils.cpp.
|
static |
Definition at line 1994 of file qqmllsutils.cpp.
|
static |
Definition at line 2182 of file qqmllsutils.cpp.
References AttachedTypeIdentifier, AttachedTypeIdentifierInBindingTarget, EnumeratorIdentifier, EnumeratorValueIdentifier, GroupedPropertyIdentifier, JavaScriptIdentifier, LambdaMethodIdentifier, NotAnIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, QmlComponentIdentifier, QmlObjectIdIdentifier, QualifiedModuleIdentifier, SignalHandlerIdentifier, SingletonIdentifier, and QQmlLSUtils::ExpressionType::type.
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 112 of file qqmllsutils.cpp.
|
static |
Filter away the parts of the Dom not needed for find usages, by following the profiler's information.
Definition at line 825 of file qqmllsutils.cpp.
|
static |
Definition at line 266 of file qqmllsutils.cpp.
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 770 of file qqmllsutils.cpp.
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForEnumeration | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Definition at line 794 of file qqmllsutils.cpp.
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForEnumerationKey | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Definition at line 806 of file qqmllsutils.cpp.
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeForMethod | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
const QString & | nameToCheck ) |
See also findDefiningScopeForProperty().
Definition at line 782 of file qqmllsutils.cpp.
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 756 of file qqmllsutils.cpp.
QQmlJSScope::ConstPtr QQmlLSUtils::findDefiningScopeIf | ( | const QQmlJSScope::ConstPtr & | referrerScope, |
Predicate && | check ) |
Definition at line 733 of file qqmllsutils.cpp.
Definition at line 549 of file qqmllsutils.cpp.
std::optional< Location > QQmlLSUtils::findDefinitionOf | ( | const DomItem & | item, |
const QStringList & | headerDirectories ) |
Definition at line 2021 of file qqmllsutils.cpp.
References EnumeratorIdentifier, EnumeratorValueIdentifier, GroupedPropertyIdentifier, JavaScriptIdentifier, MethodIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, QmlObjectIdIdentifier, QualifiedModuleIdentifier, SignalHandlerIdentifier, and SignalIdentifier.
|
static |
Definition at line 2008 of file qqmllsutils.cpp.
|
static |
Definition at line 1915 of file qqmllsutils.cpp.
QString QQmlLSUtils::findFilePathFromFileName | ( | const QStringList & | rootDirs, |
const QString & | fileNameToSearch, | ||
const QSet< QString > & | ignoredPaths ) |
Definition at line 2619 of file qqmllsutils.cpp.
QStringList QQmlLSUtils::findFilePathsFromFileNames | ( | const QString & | rootDir, |
const QStringList & | fileNamesToSearch, | ||
const QSet< QString > & | ignoredPaths ) |
Definition at line 2612 of file qqmllsutils.cpp.
|
static |
Definition at line 2555 of file qqmllsutils.cpp.
|
static |
Definition at line 561 of file qqmllsutils.cpp.
|
static |
Definition at line 1952 of file qqmllsutils.cpp.
|
static |
Definition at line 1970 of file qqmllsutils.cpp.
|
static |
Finds the scope within the special elements like Connections, PropertyChanges, Bindings or AnchorChanges.
Definition at line 1218 of file qqmllsutils.cpp.
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 447 of file qqmllsutils.cpp.
References QmlObjectIdIdentifier.
|
static |
Definition at line 961 of file qqmllsutils.cpp.
References QQmlLSUtils::Usages::appendUsage().
Definition at line 1009 of file qqmllsutils.cpp.
References QQmlLSUtils::Usages::sort().
|
static |
Definition at line 836 of file qqmllsutils.cpp.
References QQmlLSUtils::Usages::appendUsage(), and QmlComponentIdentifier.
|
static |
Definition at line 217 of file qqmllsutils.cpp.
|
static |
Definition at line 1065 of file qqmllsutils.cpp.
References MethodIdentifier, and SignalIdentifier.
bool QQmlLSUtils::isFieldMemberAccess | ( | const DomItem & | item | ) |
Helper to check if item is a Field Member Access memberAccess
in {
<someExpression>.memberAccess}.
Definition at line 68 of file qqmllsutils.cpp.
bool QQmlLSUtils::isFieldMemberBase | ( | const DomItem & | item | ) |
Helper to check if item is a Field Member Base base
in {base.memberAccess}
.
Definition at line 83 of file qqmllsutils.cpp.
bool QQmlLSUtils::isFieldMemberExpression | ( | const DomItem & | item | ) |
Helper to check if item is a Field Member Expression {
<someExpression>.propertyName}.
Definition at line 56 of file qqmllsutils.cpp.
bool QQmlLSUtils::isValidEcmaScriptIdentifier | ( | QStringView | view | ) |
Definition at line 2494 of file qqmllsutils.cpp.
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.
We usually assume that sourcelocations have inclusive ends, for example we assume that auto-completion on \n in someName\n wants suggestions for someName, even if its technically one position "outside" the sourcelocation of someName. This is not true for ScriptBinaryExpressions, where auto-completion on . in someName. should not return suggestions for someName. The same also applies to all other binary expressions +, -, and so on.
Definition at line 318 of file qqmllsutils.cpp.
|
static |
Definition at line 421 of file qqmllsutils.cpp.
|
static |
Definition at line 947 of file qqmllsutils.cpp.
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 153 of file qqmllsutils.cpp.
|
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 1089 of file qqmllsutils.cpp.
References ResolveActualTypeForFieldMemberExpression, and SignalHandlerIdentifier.
|
static |
Definition at line 2163 of file qqmllsutils.cpp.
|
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 677 of file qqmllsutils.cpp.
References PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, SignalHandlerIdentifier, and SignalIdentifier.
|
static |
Definition at line 2323 of file qqmllsutils.cpp.
References PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, SignalHandlerIdentifier, and SignalIdentifier.
Definition at line 2301 of file qqmllsutils.cpp.
|
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 1159 of file qqmllsutils.cpp.
References AttachedTypeIdentifierInBindingTarget, GroupedPropertyIdentifier, ResolveActualTypeForFieldMemberExpression, and ResolveOwnerType.
|
static |
See comment on methodFromReferrerScope: the same applies to properties.
Definition at line 1129 of file qqmllsutils.cpp.
References ResolveActualTypeForFieldMemberExpression.
|
static |
Definition at line 2144 of file qqmllsutils.cpp.
QLspSpecification::Range QQmlLSUtils::qmlLocationToLspLocation | ( | Location | 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.
Definition at line 169 of file qqmllsutils.cpp.
References QQmlLSUtils::TextPosition::character, QQmlLSUtils::Location::end(), and QQmlLSUtils::TextPosition::line.
QByteArray QQmlLSUtils::qmlUrlToLspUri | ( | const QByteArray & | url | ) |
Definition at line 158 of file qqmllsutils.cpp.
Definition at line 34 of file qqmllsutils.cpp.
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 2364 of file qqmllsutils.cpp.
References QQmlLSUtils::Usages::isEmpty().
|
static |
Resolves the expression type of a binding for signal handlers, like the function expression {(x) => ...} in
\qml onHelloSignal: (x) => ... \endqml
would be resolved to the {onHelloSignal} expression type, for example.
Definition at line 1405 of file qqmllsutils.cpp.
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).
Might return an ExpressionType without(!) semantic scope when no type information is available, for example resolving the type of x in someJSObject.x (where let someJSObject = { x: 42 };) then the name and type of x is known but no semantic scope can be obtained.
Definition at line 1633 of file qqmllsutils.cpp.
References GroupedPropertyIdentifier, JavaScriptIdentifier, LambdaMethodIdentifier, MethodIdentifier, NotAnIdentifier, PropertyIdentifier, QmlComponentIdentifier, QmlObjectIdIdentifier, ResolveActualTypeForFieldMemberExpression, and ResolveOwnerType.
|
static |
Definition at line 1320 of file qqmllsutils.cpp.
References EnumeratorIdentifier, EnumeratorValueIdentifier, JavaScriptIdentifier, QmlComponentIdentifier, and QualifiedModuleIdentifier.
|
static |
Definition at line 1494 of file qqmllsutils.cpp.
References JavaScriptIdentifier, QmlObjectIdIdentifier, and QualifiedModuleIdentifier.
|
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 629 of file qqmllsutils.cpp.
References MethodIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, SignalHandlerIdentifier, and SignalIdentifier.
|
static |
In a signal handler
\qml onSomeSignal: (x, y, z) => .... \endqml
the parameters x
, y
and z
are not allowed to have type annotations: instead, their type is defined by the signal definition itself.
This code detects signal handler parameters and resolves their type using the signal's definition.
Definition at line 1436 of file qqmllsutils.cpp.
References JavaScriptIdentifier, PropertyChangedHandlerIdentifier, ResolveOwnerType, and SignalHandlerIdentifier.
|
static |
Definition at line 1576 of file qqmllsutils.cpp.
References MethodIdentifier, PropertyChangedHandlerIdentifier, PropertyChangedSignalIdentifier, PropertyIdentifier, ResolveActualTypeForFieldMemberExpression, ResolveOwnerType, SignalHandlerIdentifier, and SignalIdentifier.
|
static |
Distinguishes singleton types from attached types and "regular" qml components.
Definition at line 1281 of file qqmllsutils.cpp.
References AttachedTypeIdentifier, QmlComponentIdentifier, ResolveOwnerType, and SingletonIdentifier.
|
static |
Definition at line 1989 of file qqmllsutils.cpp.
DomItem QQmlLSUtils::sourceLocationToDomItem | ( | const DomItem & | file, |
const QQmlJS::SourceLocation & | location ) |
Definition at line 1879 of file qqmllsutils.cpp.
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 190 of file qqmllsutils.cpp.
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 205 of file qqmllsutils.cpp.