6#include <QtLanguageServer/private/qlanguageserverspectypes_p.h>
7#include <QtCore/qthreadpool.h>
8#include <QtCore/private/qduplicatetracker_p.h>
9#include <QtCore/QRegularExpression>
10#include <QtQmlDom/private/qqmldomexternalitems_p.h>
11#include <QtQmlDom/private/qqmldomtop_p.h>
12#include <QtQmlDom/private/qqmldomscriptelements_p.h>
13#include <QtQmlDom/private/qqmldom_utils_p.h>
14#include <QtQml/private/qqmlsignalnames_p.h>
15#include <QtQml/private/qqmljslexer_p.h>
16#include <QtQmlCompiler/private/qqmljsutils_p.h>
42 const DomItem fieldMemberExpressionBeginning =
el.filterUp(
44 FilterUpOptions::ReturnOuter);
49 for (
const QString &qualifier : qualifiers)
60 return item.internalKind() == DomType::ScriptBinaryExpression
61 &&
item.field(Fields::operation).value().toInteger()
72 auto parent =
item.directParent();
77 return item == rightHandSide;
95 if (!isAccess && !isExpression)
96 return {
item.value().toString() };
108 if (current == stopMarker)
154 range.start.line = qmlLocation.startLine - 1;
155 range.start.character = qmlLocation.startColumn - 1;
159 range.end.character =
end.character;
174 int targetLine =
row;
176 while (
i !=
text.
size() && targetLine != 0) {
190 if (
c == u
'\n' ||
c == u
'\r')
193 if (!
c.isLowSurrogate())
218 currentLineOffset =
i + 1;
219 }
else if (
c == u
'\r') {
220 if (
i > 0 &&
text[
i - 1] == u
'\n')
233 auto smallest = std::min_element(
236 return a.fileLocation->info().fullRegion.length
237 < b.fileLocation->info().fullRegion.length;
240 if (smallest->domItem.internalKind() == DomType::Binding) {
252 auto smallestPropertyDefinition = std::min_element(
257 const bool aIsPropertyDefinition =
258 a.domItem.internalKind() == DomType::PropertyDefinition;
259 const bool bIsPropertyDefinition =
260 b.domItem.internalKind() == DomType::PropertyDefinition;
261 return aIsPropertyDefinition > bIsPropertyDefinition
262 && a.fileLocation->info().fullRegion.length
263 < b.fileLocation->info().fullRegion.length;
266 if (smallestPropertyDefinition->domItem.internalKind() != DomType::PropertyDefinition)
269 const auto propertyDefinitionColon =
271 const auto smallestColon = smallest->fileLocation->info().regions[
ColonTokenRegion];
274 if (propertyDefinitionColon.isValid() && propertyDefinitionColon == smallestColon
275 && offsetInFile < smallestColon.offset) {
276 return smallestPropertyDefinition;
282static QList<QQmlLSUtilsItemLocation>
294 QList<QQmlLSUtilsItemLocation> filteredItems;
298 filteredItems.append(*smallest);
302 const quint32 smallestEnd = smallestLoc.end();
310 const quint32 itEnd = itLoc.end();
311 if (itBegin == smallestEnd || smallestBegin == itEnd) {
312 filteredItems.append(*
it);
315 return filteredItems;
329 QList<QQmlLSUtilsItemLocation> itemsFound;
330 std::shared_ptr<QmlFile> filePtr =
file.ownerAs<
QmlFile>();
335 QString code = filePtr->code();
336 QList<QQmlLSUtilsItemLocation> toDo;
341 return l.begin() <=
quint32(targetPos) &&
quint32(targetPos) <= l.end();
343 return l.begin() <= targetPos && targetPos <= l.end();
346 if (containsTarget(
t->info().fullRegion)) {
352 while (!toDo.isEmpty()) {
356 bool inParentButOutsideChildren =
true;
358 auto subEls = iLoc.fileLocation->subItems();
360 auto subLoc = std::static_pointer_cast<AttachedInfoT<FileLocations>>(
it.value());
363 if (containsTarget(subLoc->info().fullRegion)) {
366 if (!subItem.domItem) {
368 <<
"A DomItem child is missing or the FileLocationsTree structure does "
369 "not follow the DomItem Structure.";
374 if (subItem.domItem.internalKind() == DomType::ScriptExpression
375 && subLoc->info().fullRegion.length == 0) {
378 subItem.fileLocation = subLoc;
379 toDo.append(subItem);
380 inParentButOutsideChildren =
false;
383 if (inParentButOutsideChildren) {
384 itemsFound.append(iLoc);
398 if (
object.internalKind() == DomType::QmlComponent || !qmlObject) {
400 .
field(Fields::objects)
402 .
field(QQmlJS::Dom::Fields::prototypes);
405 prototypes = qmlObject.
field(QQmlJS::Dom::Fields::prototypes);
407 switch (prototypes.indexes()) {
413 qDebug() <<
"Multiple prototypes found for " <<
object.name() <<
", taking the first one.";
453 switch (
object.internalKind()) {
455 typeDefinition =
object.
field(Fields::objects).
index(0);
461 auto binding =
object.as<
Binding>();
465 if (binding->valueKind() == BindingValueKind::Object) {
466 typeDefinition =
baseObject(
object.field(Fields::value));
471 const QString bindingName = binding->name();
472 object.containingObject().visitLookup(
476 propertyDefinition = item;
481 LookupType::PropertyDef);
482 typeDefinition = propertyDefinition.field(Fields::type).proceedToScope();
488 typeDefinition =
object.field(Fields::referredObject).proceedToScope();
493 typeDefinition =
object.field(Fields::type).proceedToScope();
497 [](
DomType k,
const DomItem &) {
return k == DomType::ScriptType; },
498 FilterUpOptions::ReturnOuter)) {
501 switch (
type.directParent().internalKind()) {
502 case DomType::QmlObject:
506 case DomType::QmlComponent:
507 typeDefinition =
type.directParent();
513 if (typeDefinition.internalKind() == DomType::Export) {
514 typeDefinition = typeDefinition.field(Fields::type).get();
519 if (
DomItem id =
object.filterUp(
521 FilterUpOptions::ReturnOuter)) {
523 typeDefinition =
id.field(Fields::referredObject).proceedToScope();
538 object.containingFile(), scope->semanticScope->sourceLocation());
540 FileLocationRegion::IdentifierRegion);
543 qDebug() <<
"QQmlLSUtils::findTypeDefinitionOf: Found unimplemented Type"
544 <<
object.internalKindStr();
554 qCDebug(QQmlLSUtilsLog) <<
"Searching for definition in" <<
item.internalKindStr();
555 if (
auto jsIdentifier = scope->ownJSIdentifier(
name)) {
556 qCDebug(QQmlLSUtilsLog) <<
"Found scope" << scope->baseTypeName();
568 definitionOfItem =
i;
572 if (
i.internalKind() == DomType::ScriptExpression)
577 if (definitionOfItem)
578 return definitionOfItem;
583 FilterUpOptions::ReturnOuter)) {
584 DomItem candidate =
res.field(Fields::body).field(Fields::scriptElement);
590 return definitionOfItem;
637 if (
methods.front().methodType() == QQmlJSMetaMethodType::Signal) {
650 if (
methods.front().methodType() == QQmlJSMetaMethodType::Signal) {
668 if (
item.internalKind() == DomType::EnumItem ||
item.internalKind() == DomType::EnumDecl)
674 switch (namings->type) {
678 const QString propertyChangedHandler =
680 namesToCheck.append(propertyChangedHandler);
682 const QString propertyChangedSignal =
684 namesToCheck.append(propertyChangedSignal);
690 namesToCheck.append(namings->name);
697 namesToCheck.append(namings->name);
708 namesToCheck.append(namings->name);
718template<
typename Predicate>
821 QList<QQmlLSUtilsLocation> &
result)
829 const auto addLocationIfTypeMatchesTarget = [&
result,
830 &expressionType](
const DomItem &toBeResolved,
853 auto findUsages = [&addLocationIfTypeMatchesTarget, &
name,
854 &namesToCheck](Path,
const DomItem ¤t, bool) ->
bool {
855 bool continueForChildren =
true;
856 if (
auto scope = current.semanticScope()) {
858 if (scope->ownJSIdentifier(
name)) {
862 switch (current.internalKind()) {
863 case DomType::QmlObject:
864 case DomType::Binding:
865 case DomType::MethodInfo:
866 case DomType::PropertyDefinition: {
867 const QString propertyName = current.field(Fields::name).value().toString();
868 if (namesToCheck.contains(propertyName))
870 return continueForChildren;
872 case DomType::ScriptIdentifierExpression: {
873 const QString identifierName = current.field(Fields::identifier).value().toString();
874 if (namesToCheck.contains(identifierName))
875 addLocationIfTypeMatchesTarget(current,
MainRegion);
876 return continueForChildren;
878 case DomType::ScriptLiteral: {
879 const QString literal = current.field(Fields::value).value().toString();
880 if (namesToCheck.contains(literal))
881 addLocationIfTypeMatchesTarget(current,
MainRegion);
882 return continueForChildren;
884 case DomType::EnumItem: {
887 const auto parentPath = current.containingObject().pathFromOwner();
888 const auto index = parentPath.last().headIndex();
890 return continueForChildren;
891 const QString enumValue = current.field(Fields::name).value().toString();
892 if (namesToCheck.contains(enumValue))
894 return continueForChildren;
896 case DomType::EnumDecl: {
899 const auto parentPath = current.pathFromOwner();
900 const auto index = parentPath.last().headIndex();
902 return continueForChildren;
903 const QString enumValue = current.field(Fields::name).value().toString();
904 if (namesToCheck.contains(enumValue))
906 return continueForChildren;
909 return continueForChildren;
912 Q_UNREACHABLE_RETURN(continueForChildren);
915 const DomItem qmlFiles =
item.top().field(Fields::qmlFileWithPath);
918 const DomItem currentFileComponents =
919 qmlFiles.key(
file).field(Fields::currentItem).field(Fields::components);
921 VisitOption::Recurse | VisitOption::VisitSelf, findUsages,
929 Q_ASSERT_X(!definitionOfItem.semanticScope().isNull()
930 && definitionOfItem.semanticScope()->ownJSIdentifier(
name).has_value(),
931 "QQmlLSUtils::locationFromJSIdentifierDefinition",
932 "JS definition does not actually define the JS identifier. "
933 "Did you obtain definitionOfItem from findJSIdentifierDefinition() ?");
935 definitionOfItem.semanticScope()->ownJSIdentifier(
name).value().location;
944 qCDebug(QQmlLSUtilsLog) <<
"Looking for JS identifier with name" <<
name;
948 if (!definitionOfItem) {
949 qCDebug(QQmlLSUtilsLog) <<
"No defining JS-Scope found!";
954 definitionOfItem.visitTree(
957 qCDebug(QQmlLSUtilsLog) <<
"Visiting a " <<
item.internalKindStr();
958 if (
item.internalKind() == DomType::ScriptIdentifierExpression
959 &&
item.field(Fields::identifier).value().toString() ==
name) {
963 qCWarning(QQmlLSUtilsLog) <<
"Failed finding filelocation of found usage";
971 scope && scope->ownJSIdentifier(
name)) {
981 if (!
result.contains(definition))
982 result.append(definition);
987 QList<QQmlLSUtilsLocation>
result;
989 switch (
item.internalKind()) {
990 case DomType::ScriptIdentifierExpression: {
991 const QString name =
item.field(Fields::identifier).value().toString();
995 case DomType::ScriptVariableDeclarationEntry: {
996 const QString name =
item.field(Fields::identifier).value().toString();
1000 case DomType::EnumDecl:
1001 case DomType::EnumItem:
1002 case DomType::QmlObject:
1003 case DomType::PropertyDefinition:
1004 case DomType::Binding:
1005 case DomType::MethodInfo: {
1010 case DomType::QmlComponent: {
1014 if (
const auto dotIndex =
name.indexOf(u
'.'); dotIndex != -1)
1021 <<
"was not implemented for QQmlLSUtils::findUsagesOf";
1027 if (QQmlLSUtilsLog().isDebugEnabled()) {
1028 qCDebug(QQmlLSUtilsLog) <<
"Found following usages:";
1031 <<
r.filename <<
" @ " <<
r.sourceLocation.startLine <<
":"
1032 <<
r.sourceLocation.startColumn <<
" with length " <<
r.sourceLocation.length;
1039static std::optional<QQmlLSUtilsIdentifierType>
1046 const bool isSignal =
methods.front().methodType() == QQmlJSMetaMethodType::Signal;
1062static std::optional<QQmlLSUtilsExpressionType>
1106static std::optional<QQmlLSUtilsExpressionType>
1115 if (
auto property = current->property(resolved->name);
property.isValid()) {
1138static std::optional<QQmlLSUtilsExpressionType>
1143 auto bindings = referrerScope->propertyBindings(
name);
1144 if (bindings.isEmpty())
1147 const auto binding = bindings.front();
1158 if (!bindingIsAttached && !referrerScope->hasProperty(
name)
1159 && referrerScope->isNameDeferred(
name)) {
1160 if (!resolverForIds)
1172 const auto typeIdentifier =
1176 if (bindingIsAttached)
1177 return binding.attachingType();
1179 return binding.groupType();
1196 Q_UNREACHABLE_RETURN({});
1208 const QSet<QString> specialItems = {u
"QQmlConnections"_s,
1209 u
"QQuickPropertyChanges"_s,
1211 u
"QQuickAnchorChanges"_s};
1215 const auto typeName = visitedScope->internalName();
1216 if (specialItems.contains(
typeName))
1231 auto target = current.bindings().key(u
"target"_s).index(0);
1233 targetName =
target.field(Fields::value)
1234 .field(Fields::scriptElement)
1235 .field(Fields::identifier)
1243 auto resolver =
item.containingFile().ownerAs<
QmlFile>()->typeResolver();
1248 return resolver->containedType(resolver->scopedType(scope, targetName));
1250 if (
item.internalKind() == DomType::Binding &&
1251 item.field(Fields::bindingType).value().toInteger() ==
int(BindingType::OnBinding)) {
1262static std::optional<QQmlLSUtilsExpressionType>
1265 const QString name =
item.field(Fields::identifier).value().toString();
1268 parent.field(Fields::left),
1288 const auto scope =
item.goToFile(owner->semanticScope->filePath())
1289 .rootQmlObject(GoTo::MostLikely)
1291 if (scope->hasEnumerationKey(
name)) {
1295 else if (scope->hasEnumeration(
name)) {
1300 for (
auto it = owner->semanticScope->childScopesBegin(),
1301 end = owner->semanticScope->childScopesEnd();
1303 if ((*it)->inlineComponentName() ==
name) {
1310 qCDebug(QQmlLSUtilsLog) <<
"Could not find identifier expression for" <<
item.internalKindStr();
1314static std::optional<QQmlLSUtilsExpressionType>
1321 const QString name =
item.field(Fields::identifier).value().toString();
1324 Q_ASSERT_X(!definitionOfItem.semanticScope().isNull()
1325 && definitionOfItem.semanticScope()->ownJSIdentifier(
name),
1326 "QQmlLSUtils::findDefinitionOf",
1327 "JS definition does not actually define the JS identifer. "
1328 "It should be empty.");
1329 auto scope = definitionOfItem.semanticScope();
1330 auto jsIdentifier = scope->ownJSIdentifier(
name);
1331 if (jsIdentifier->scope) {
1340 const auto referrerScope =
item.nearestSemanticScope();
1348 const auto resolver =
item.containingFile().ownerAs<
QmlFile>()->typeResolver();
1361 if (
auto scope = resolver->typeForName(
name)) {
1362 if (scope->isSingleton())
1366 if (
auto attachedScope = scope->attachedType()) {
1395static std::optional<QQmlLSUtilsExpressionType>
1400 if (!signalOrProperty)
1403 switch (signalOrProperty->type) {
1408 signalOrProperty->type };
1411 signalOrProperty->type };
1413 Q_UNREACHABLE_RETURN({});
1419 signalOrProperty->type
1423 Q_UNREACHABLE_RETURN({});
1425 Q_UNREACHABLE_RETURN({});
1433 signalOrProperty->type };
1437 Q_UNREACHABLE_RETURN({});
1439 Q_UNREACHABLE_RETURN({});
1441 Q_UNREACHABLE_RETURN({});
1450std::optional<QQmlLSUtilsExpressionType>
1454 switch (
item.internalKind()) {
1455 case DomType::ScriptIdentifierExpression: {
1458 case DomType::PropertyDefinition: {
1460 if (propertyDefinition && propertyDefinition->semanticScope()) {
1468 Q_UNREACHABLE_RETURN({});
1470 Q_UNREACHABLE_RETURN({});
1474 case DomType::Binding: {
1477 std::optional<QQmlJSScope::ConstPtr> owner =
item.qmlObject().semanticScope();
1487 if (!signalOrProperty)
1493 signalOrProperty->type
1497 Q_UNREACHABLE_RETURN({});
1503 qDebug(QQmlLSUtilsLog) <<
"QQmlLSUtils::resolveExpressionType() could not resolve the"
1504 "type of a Binding.";
1509 case DomType::QmlObject: {
1513 if (
auto scope =
object->semanticScope()) {
1515 const bool isComponent =
name.front().isUpper();
1517 scope = scope->baseType();
1529 case DomType::QmlComponent: {
1533 const auto scope =
component->semanticScope();
1538 if (
auto dotIndex =
name.indexOf(u
'.'); dotIndex != -1)
1546 Q_UNREACHABLE_RETURN({});
1548 case DomType::MethodInfo: {
1550 if (
object &&
object->semanticScope()) {
1551 std::optional<QQmlJSScope::ConstPtr> scope =
object->
semanticScope();
1558 if (!signalOrProperty)
1565 targetScope, signalOrProperty->name),
1566 signalOrProperty->type };
1575 if (scope.value()->scopeType() == QQmlJSScope::ScopeType::JSFunctionScope)
1576 scope = scope.value()->parentScope();
1582 qDebug(QQmlLSUtilsLog) <<
"QQmlLSUtils::resolveExpressionType() could not resolve the"
1583 "type of a MethodInfo.";
1588 case DomType::ScriptBinaryExpression: {
1594 case DomType::ScriptLiteral: {
1598 const auto scope =
item.qmlObject().semanticScope();
1599 const auto name =
item.field(Fields::value).value().toString();
1602 if (!signalOrProperty)
1608 signalOrProperty->type
1613 Q_UNREACHABLE_RETURN({});
1618 case DomType::EnumItem: {
1619 const QString enumValue =
item.field(Fields::name).value().toString();
1621 if (!referrerScope->hasEnumerationKey(enumValue))
1633 Q_UNREACHABLE_RETURN({});
1635 case DomType::EnumDecl: {
1636 const QString enumName =
item.field(Fields::name).value().toString();
1638 if (!referrerScope->hasEnumeration(enumName))
1650 Q_UNREACHABLE_RETURN({});
1653 qCDebug(QQmlLSUtilsLog) <<
"Type" <<
item.internalKindStr()
1654 <<
"is unimplemented in QQmlLSUtils::resolveExpressionType";
1680 == second.fileLocation->info().fullRegion.startLine,
1681 "QQmlLSUtils::findTypeDefinitionOf(DomItem)",
1682 "QQmlLSUtils::itemsFromTextLocation returned non-adjacent items.");
1683 if (
first.fileLocation->info().fullRegion.startColumn
1684 > second.fileLocation->info().fullRegion.startColumn)
1685 return first.domItem;
1687 return second.domItem;
1691 qDebug() <<
"Found multiple candidates for type of scriptidentifierexpression";
1697static std::optional<QQmlLSUtilsLocation>
1706 auto regions = fileLocation->info().regions;
1718static std::optional<QQmlLSUtilsLocation>
1724 DomItem propertyDefinition = propertyOwner.field(Fields::propertyDefs).key(
name).index(0);
1729 auto regions = fileLocation->info().regions;
1734 result.filename = propertyDefinition.canonicalFilePath();
1743 auto resolvedExpression =
1746 if (!resolvedExpression || !resolvedExpression->name || !resolvedExpression->semanticScope) {
1747 qCDebug(QQmlLSUtilsLog) <<
"QQmlLSUtils::findDefinitionOf: Type could not be resolved.";
1751 switch (resolvedExpression->type) {
1754 resolvedExpression->semanticScope->ownJSIdentifier(*resolvedExpression->name)
1762 const DomItem ownerFile =
item.goToFile(resolvedExpression->semanticScope->filePath());
1764 resolvedExpression->semanticScope->sourceLocation();
1772 const DomItem ownerFile =
item.goToFile(resolvedExpression->semanticScope->filePath());
1774 resolvedExpression->semanticScope->sourceLocation();
1779 item.containingFile(), resolvedExpression->semanticScope->sourceLocation());
1783 .
key(*resolvedExpression->name)
1785 .
field(Fields::value);
1788 <<
"QmlComponent in Dom structure has no id, was it misconstructed?";
1794 result.filename = domId.canonicalFilePath();
1799 result.sourceLocation = resolvedExpression->semanticScope->sourceLocation();
1800 result.filename = resolvedExpression->semanticScope->filePath();
1808 qCDebug(QQmlLSUtilsLog) <<
"QQmlLSUtils::findDefinitionOf was not implemented for type"
1809 << resolvedExpression->type;
1812 Q_UNREACHABLE_RETURN({});
1822 while (typeWithDefinition && !typeWithDefinition->hasOwnProperty(
name))
1823 typeWithDefinition = typeWithDefinition->
baseType();
1825 if (!typeWithDefinition) {
1827 <<
"QQmlLSUtils::checkNameForRename cannot find property definition,"
1831 return typeWithDefinition;
1841 while (typeWithDefinition && !typeWithDefinition->hasOwnMethod(
name))
1842 typeWithDefinition = typeWithDefinition->
baseType();
1844 if (!typeWithDefinition) {
1846 <<
"QQmlLSUtils::checkNameForRename cannot find method definition,"
1850 return typeWithDefinition;
1856 switch (ownerType.type) {
1860 const auto propertyName =
1884 return ownerType.semanticScope;
1891 const std::optional<QQmlLSUtilsExpressionType> &ownerType)
1902 const auto userSemanticScope =
item.nearestSemanticScope();
1904 if (!ownerType || !userSemanticScope) {
1909 switch (ownerType->type) {
1919 0, u
"Invalid name for a property changed handler identifier."_s
1932 if (dirtyNewName.front().isLetter() && !dirtyNewName.front().isLower()) {
1934 0, u
"Object id names cannot start with an upper case letter."_s
1948 if (!typeWithDefinition) {
1951 u
"Renaming has not been implemented for the requested item."_s,
1956 if (!typeWithDefinition->isComposite()) {
1961 const QString moduleOfDefinition = ownerType->semanticScope->moduleName();
1962 const QString moduleOfCurrentItem = userSemanticScope->moduleName();
1963 if (moduleOfDefinition != moduleOfCurrentItem) {
1966 u
"Cannot rename items defined in the %1 module fromits usage in the %2 module."_s
1967 .arg(moduleOfDefinition, moduleOfCurrentItem),
1976 switch (
item.internalKind()) {
1977 case DomType::ScriptIdentifierExpression: {
1978 return item.field(Fields::identifier).value().toString();
1980 case DomType::ScriptVariableDeclarationEntry: {
1981 return item.field(Fields::identifier).value().toString();
1983 case DomType::PropertyDefinition:
1984 case DomType::Binding:
1985 case DomType::MethodInfo: {
1986 return item.field(Fields::name).value().toString();
1990 <<
"was not implemented for QQmlLSUtils::renameUsagesOf";
1991 return std::nullopt;
1993 Q_UNREACHABLE_RETURN(std::nullopt);
2002 switch (alternative) {
2015 return std::nullopt;
2017 Q_UNREACHABLE_RETURN(std::nullopt);
2040 const std::optional<QQmlLSUtilsExpressionType> &targetType)
2042 QList<QQmlLSUtilsEdit>
results;
2053 semanticScope = targetType->semanticScope;
2056 semanticScope = resolved->semanticScope;
2063 newName =
newNameFrom(dirtyNewName, resolved->type).value_or(dirtyNewName);
2064 oldName = resolved->name;
2066 newName = dirtyNewName;
2069 const qsizetype oldNameLength = oldName->length();
2072 const qsizetype oldChangedSignalNameLength =
2074 const qsizetype oldChangedHandlerNameLength =
2079 const QString newChangedHandlerName =
2087 if (oldNameLength == currentLength) {
2089 edit.replacement = newName;
2091 }
else if (oldHandlerNameLength == currentLength) {
2093 edit.replacement = newHandlerName;
2095 }
else if (oldChangedSignalNameLength == currentLength) {
2097 edit.replacement = newChangedSignalName;
2099 }
else if (oldChangedHandlerNameLength == currentLength) {
2101 edit.replacement = newChangedHandlerName;
2104 qCDebug(QQmlLSUtilsLog) <<
"Found usage with wrong identifier length, ignoring...";
2140 if (
token !=
static_cast<int>(QQmlJS::Lexer::T_IDENTIFIER))
2143 const int eofToken = lexer.
lex();
2144 return eofToken ==
static_cast<int>(QQmlJS::Lexer::EOF_SYMBOL);
2163 const QPair<QString, QStringList>
result{
2164 u
"cmake"_s, { u
"--build"_s,
path, u
"-t"_s, u
"all_qmltyperegistrations"_s }
static JNINativeMethod methods[]
QString toString(const QString &defaultValue={}) const
Returns the string value stored in this QCborValue, if it is of the string type.
qsizetype size() const noexcept
void append(parameter_type t)
ContentVariant variant() const
QQmlJSScope::ConstPtr type() const
bool hasOwnPropertyBindings(const QString &name) const
QHash< QString, QQmlJSMetaMethod > methods() const
Returns all methods visible from this scope including those of base types and extensions.
QQmlJSScope::Ptr parentScope()
QQmlJSMetaProperty property(const QString &name) const
bool hasOwnEnumeration(const QString &name) const
bool hasOwnEnumerationKey(const QString &name) const
bool hasOwnProperty(const QString &name) const
QQmlJSScope::ConstPtr baseType() const
bool hasProperty(const QString &name) const
bool hasOwnMethod(const QString &name) const
QQmlJSScope::ConstPtr semanticScope() const
DomItem field(QStringView name) const
DomItem path(const Path &p, const ErrorHandler &h=&defaultErrorHandler) const
DomItem index(index_type) const
DomItem component(GoTo option=GoTo::Strict) const
DomItem qmlObject(GoTo option=GoTo::Strict, FilterUpOptions options=FilterUpOptions::ReturnOuter) const
DomItem key(const QString &name) const
static QQmlJS::SourceLocation region(const Tree &fLoc, FileLocationRegion region)
std::shared_ptr< AttachedInfoT< FileLocations > > Tree
static FileLocations::Tree treeOf(const DomItem &)
A QmlFile, when loaded in a DomEnvironment that has the DomCreationOption::WithSemanticAnalysis,...
FileLocations::Tree fileLocationsTree() const
void setCode(const QString &code, int lineno, bool qmlMode=true, CodeContinuation codeContinuation=CodeContinuation::Reset)
static QList< QQmlLSUtilsLocation > findUsagesOf(const DomItem &item)
static bool isValidEcmaScriptIdentifier(QStringView view)
static QPair< QString, QStringList > cmakeBuildCommand(const QString &path)
static QList< QQmlLSUtilsItemLocation > itemsFromTextLocation(const DomItem &file, int line, int character)
Find the DomItem representing the object situated in file at given line and character/column.
static std::optional< QQmlLSUtilsErrorMessage > checkNameForRename(const DomItem &item, const QString &newName, const std::optional< QQmlLSUtilsExpressionType > &targetType=std::nullopt)
static DomItem baseObject(const DomItem &qmlObject)
static QByteArray lspUriToQmlUrl(const QByteArray &uri)
static DomItem sourceLocationToDomItem(const DomItem &file, const QQmlJS::SourceLocation &location)
static std::optional< QQmlLSUtilsExpressionType > resolveExpressionType(const DomItem &item, QQmlLSUtilsResolveOptions)
static QStringList fieldMemberExpressionBits(const DomItem &item, const DomItem &stopAtChild={})
static QByteArray qmlUrlToLspUri(const QByteArray &url)
static bool isFieldMemberExpression(const DomItem &item)
static bool isFieldMemberAccess(const DomItem &item)
static QLspSpecification::Range qmlLocationToLspLocation(const QString &code, QQmlJS::SourceLocation qmlLocation)
Converts a QQmlJS::SourceLocation to a LSP Range.
static std::optional< QQmlLSUtilsLocation > findTypeDefinitionOf(const DomItem &item)
Returns the location of the type definition pointed by object.
static std::optional< QQmlLSUtilsLocation > findDefinitionOf(const DomItem &item)
static qsizetype textOffsetFrom(const QString &code, int row, int character)
Convert a text position from (line, column) into an offset.
static QList< QQmlLSUtilsEdit > renameUsagesOf(const DomItem &item, const QString &newName, const std::optional< QQmlLSUtilsExpressionType > &targetType=std::nullopt)
Rename the appearance of item to newName.
static QByteArray getDocumentationFromLocation(const DomItem &file, const QQmlLSUtilsTextPosition &position)
static QQmlLSUtilsTextPosition textRowAndColumnFrom(const QString &code, qsizetype offset)
Convert a text position from an offset into (line, column).
static std::optional< QString > changedSignalNameToPropertyName(QStringView changeSignal)
static QString signalNameToHandlerName(QAnyStringView signal)
static bool isChangedSignalName(QStringView signalName)
static std::optional< QString > changedHandlerNameToPropertyName(QStringView handler)
static QString propertyNameToChangedHandlerName(QStringView property)
static bool isHandlerName(QStringView signalName)
static std::optional< QString > handlerNameToSignalName(QStringView handler)
static QString propertyNameToChangedSignalName(QStringView property)
static bool isChangedHandlerName(QStringView signalName)
const_iterator constEnd() const noexcept
const_iterator constFind(const T &value) const
QString toString() const
Returns a deep copy of this string view's data as a QString.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf16(const char16_t *, qsizetype size=-1)
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
iterator end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the ...
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QSet< QString >::iterator it
Path lookupTypePath(const QString &name)
@ ScriptIdentifierExpression
bool emptyChildrenVisitor(Path, const DomItem &, bool)
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLenum GLuint GLintptr offset
GLenum GLenum GLsizei void GLsizei void * column
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void * row
GLuint const GLint * locations
static qreal component(const QPointF &point, unsigned int i)
@ AssumeComponentsAreBound
static std::optional< QString > newNameFrom(const QString &dirtyNewName, QQmlLSUtilsIdentifierType alternative)
static QQmlJSScope::ConstPtr methodOwnerFrom(const QQmlJSScope::ConstPtr &type, const QString &name)
static std::optional< SignalOrProperty > resolveNameInQmlScope(const QString &name, const QQmlJSScope::ConstPtr &owner)
Find out if {name} is a signal, signal handler, property, property changed signal,...
static std::optional< QQmlLSUtilsExpressionType > resolveFieldMemberExpressionType(const DomItem &item, QQmlLSUtilsResolveOptions options)
static QList< QQmlLSUtilsItemLocation >::const_iterator handlePropertyDefinitionAndBindingOverlap(const QList< QQmlLSUtilsItemLocation > &items, qsizetype offsetInFile)
static QQmlJSScope::ConstPtr findDefiningScopeForProperty(QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
Finds the scope where a property is first defined.
static QQmlJSScope::ConstPtr propertyOwnerFrom(const QQmlJSScope::ConstPtr &type, const QString &name)
static bool findDefinitionFromItem(const DomItem &item, const QString &name)
static std::optional< QQmlLSUtilsExpressionType > resolveIdentifierExpressionType(const DomItem &item, QQmlLSUtilsResolveOptions options)
static QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey(QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
static QList< QQmlLSUtilsItemLocation > filterItemsFromTextLocation(const QList< QQmlLSUtilsItemLocation > &items, qsizetype offsetInFile)
static QQmlJSScope::ConstPtr findDefiningScopeForMethod(QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
static std::optional< QQmlLSUtilsExpressionType > methodFromReferrerScope(const QQmlJSScope::ConstPtr &referrerScope, const QString &name, QQmlLSUtilsResolveOptions options)
static void findUsagesHelper(const DomItem &item, const QString &name, QList< QQmlLSUtilsLocation > &result)
static QQmlJSScope::ConstPtr findDefiningScopeForBinding(QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
static QQmlJSScope::ConstPtr findScopeOfSpecialItems(QQmlJSScope::ConstPtr scope, const DomItem &item)
static QQmlLSUtilsLocation locationFromJSIdentifierDefinition(const DomItem &definitionOfItem, const QString &name)
static QQmlJSScope::ConstPtr findDefiningScopeForEnumeration(QQmlJSScope::ConstPtr referrerScope, const QString &nameToCheck)
static std::optional< QQmlLSUtilsIdentifierType > hasMethodOrSignal(const QQmlJSScope::ConstPtr &scope, const QString &name)
static std::optional< QQmlLSUtilsExpressionType > propertyFromReferrerScope(const QQmlJSScope::ConstPtr &referrerScope, const QString &propertyName, QQmlLSUtilsResolveOptions options)
static std::optional< QQmlLSUtilsExpressionType > propertyBindingFromReferrerScope(const QQmlJSScope::ConstPtr &referrerScope, const QString &name, QQmlLSUtilsResolveOptions options, QQmlJSTypeResolver *resolverForIds)
static std::optional< QQmlLSUtilsLocation > locationFromDomItem(const DomItem &item, FileLocationRegion region)
static void findUsagesOfNonJSIdentifiers(const DomItem &item, const QString &name, QList< QQmlLSUtilsLocation > &result)
static FieldFilter filterForFindUsages()
Filter away the parts of the Dom not needed for find usages, by following the profiler's information.
QQmlJSScope::ConstPtr findDefiningScopeIf(QQmlJSScope::ConstPtr referrerScope, Predicate &&check)
static QStringList namesOfPossibleUsages(const QString &name, const DomItem &item, const QQmlJSScope::ConstPtr &targetType)
static DomItem findJSIdentifierDefinition(const DomItem &item, const QString &name)
static QQmlJSScope::ConstPtr expressionTypeWithDefinition(const QQmlLSUtilsExpressionType &ownerType)
static std::optional< QString > oldNameFrom(const DomItem &item)
static std::optional< QQmlLSUtilsLocation > findMethodDefinitionOf(const DomItem &file, QQmlJS::SourceLocation location, const QString &name)
static std::optional< QQmlLSUtilsLocation > findPropertyDefinitionOf(const DomItem &file, QQmlJS::SourceLocation propertyDefinitionLocation, const QString &name)
static std::optional< QQmlLSUtilsExpressionType > resolveSignalOrPropertyExpressionType(const QString &name, const QQmlJSScope::ConstPtr &scope, QQmlLSUtilsResolveOptions options)
QQmlLSUtilsIdentifierType
@ PropertyChangedSignalIdentifier
@ SignalHandlerIdentifier
@ PropertyChangedHandlerIdentifier
@ GroupedPropertyIdentifier
@ EnumeratorValueIdentifier
QQmlLSUtilsResolveOptions
@ ResolveActualTypeForFieldMemberExpression
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT_X(cond, x, msg)
static Heap::CallContext * getScope(QV4::Value *stack, int level)
QUrl url("example.com")
[constructor-url-reference]
static bool searchBaseAndExtensionTypes(QQmlJSScopePtr type, const Action &check)
QQmlLSUtilsLocation location
static QQmlLSUtilsEdit from(const QString &fileName, const QString &code, quint32 startLine, quint32 startCharacter, quint32 length, const QString &newName)
std::optional< QString > name
QQmlJS::Dom::DomItem domItem
QQmlJS::Dom::FileLocations::Tree fileLocation
QQmlJS::SourceLocation sourceLocation
static QQmlLSUtilsLocation from(const QString &fileName, const QString &code, quint32 startLine, quint32 startCharacter, quint32 length)
QQmlLSUtilsIdentifierType type