19template<
typename ScopeForId>
42 auto aliasExprBits = nextProperty.aliasExpression().split(u
'.');
44 if (aliasExprBits.size() < 1)
48 resultOwner = scopeForId(aliasExprBits[0], resultOwner);
54 aliasExprBits.removeFirst();
55 result.owner = resultOwner;
58 for (
const QString &bit : std::as_const(aliasExprBits)) {
59 nextProperty = resultOwner->
property(bit);
60 if (!nextProperty.isValid())
65 result.property = nextProperty;
66 result.owner = resultOwner;
69 resultOwner = nextProperty.type();
81 return ::resolveAlias(
93 return ::resolveAlias(
95 return idScopes.
scope(
id, referrer);
105 int shortestDistance = userInput.
size();
115 std::sort(candidates.begin(), candidates.end());
117 for (
const QString &candidate : candidates) {
126 std::iota(
v0.begin(),
v0.end(), 0);
131 int deletionCost =
v0[
j + 1] + 1;
132 int insertionCost =
v1[
j] + 1;
133 int substitutionCost = userInput[
i] == candidate[
j] ?
v0[
j] :
v0[
j] + 1;
134 v1[
j + 1] = std::min({ deletionCost, insertionCost, substitutionCost });
141 shortestDistanceWord = candidate;
149 u
"Did you mean \"%1\"?"_s.arg(shortestDistanceWord),
163std::variant<QString, QQmlJS::DiagnosticMessage>
166 const auto makeError = [](
const QString &msg) {
171 return makeError(u
"QQmlJSImporter::metaDataMapper() is nullptr"_s);
178 if (!
entry.isValid())
179 return makeError(u
"Failed to find meta data entry in QQmlJSImporter::metaDataMapper()"_s);
181 return makeError(u
"The module output directory does not match the build directory path"_s);
183 QString qrcPath = buildDirectoryPath;
190 if (sourceDirPaths.size() != 1) {
192 sourceDirPaths.isEmpty() ? u
"<none>"_s : sourceDirPaths.join(u
", ");
194 QStringLiteral(
"QRC path %1 (deduced from %2) has unexpected number of mappings "
195 "(%3). File paths that matched:\n%4")
199 return sourceDirPaths[0];
212 const auto varType = typeResolver->
varType();
213 const auto nullType = typeResolver->
nullType();
214 const auto voidType = typeResolver->
voidType();
217 const auto lhsType = typeResolver->
containedType(lhsContent);
218 const auto rhsType = typeResolver->
containedType(rhsContent);
220 return (typeResolver->
equals(lhsType, varType)
221 && (typeResolver->
equals(rhsType, nullType) || typeResolver->
equals(rhsType, voidType)))
222 || (typeResolver->
equals(rhsType, varType)
223 && (typeResolver->
equals(lhsType, nullType)
224 || typeResolver->
equals(lhsType, voidType)));
237 const auto lhsType = typeResolver->
containedType(lhsContent);
238 const auto rhsType = typeResolver->
containedType(rhsContent);
239 return (lhsType->isReferenceType()
240 && (rhsType->isReferenceType()
242 || (rhsType->isReferenceType()
243 && (lhsType->isReferenceType()
257 const auto lhsType = typeResolver->
containedType(lhsContent);
258 const auto rhsType = typeResolver->
containedType(rhsContent);
259 return typeResolver->
equals(lhsType, typeResolver->
urlType())
QQmlJSResourceFileMapper * resourceFileMapper() const
QQmlJSResourceFileMapper * metaDataMapper() const
QQmlJSMetaProperty property(const QString &name) const
QQmlJSScope::ConstPtr scope(const QString &id, const QQmlJSScope::ConstPtr &referrer) const
bool equals(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const
QQmlJSScope::ConstPtr nullType() const
QQmlJSScope::ConstPtr containedType(const QQmlJSRegisterContent &container) const
QQmlJSScope::ConstPtr scopeForId(const QString &id, const QQmlJSScope::ConstPtr &referrer) const
QQmlJSScope::ConstPtr voidType() const
QQmlJSScope::ConstPtr urlType() const
QQmlJSScope::ConstPtr varType() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QString & prepend(QChar c)
Combined button and popup list for selecting options.
GLsizei GLsizei GLfloat distance
bool canCompareWithQObject(const QQmlJSTypeResolver *typeResolver, const QQmlJSRegisterContent &lhsContent, const QQmlJSRegisterContent &rhsContent)
bool canCompareWithQUrl(const QQmlJSTypeResolver *typeResolver, const QQmlJSRegisterContent &lhsContent, const QQmlJSRegisterContent &rhsContent)
bool canStrictlyCompareWithVar(const QQmlJSTypeResolver *typeResolver, const QQmlJSRegisterContent &lhsContent, const QQmlJSRegisterContent &rhsContent)
static QQmlJSUtils::ResolvedAlias resolveAlias(ScopeForId scopeForId, const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &owner, const QQmlJSUtils::AliasResolutionVisitor &visitor)
#define QStringLiteral(str)
Entry entry(const Filter &filter) const
static Filter resourceFileFilter(const QString &file)
QStringList filePaths(const Filter &filter) const
std::function< void()> reset
std::function< void(const QQmlJSMetaProperty &, const QQmlJSScope::ConstPtr &)> processResolvedProperty
std::function< void(const QQmlJSScope::ConstPtr &)> processResolvedId
QQmlJSScope::ConstPtr owner
static std::variant< QString, QQmlJS::DiagnosticMessage > sourceDirectoryPath(const QQmlJSImporter *importer, const QString &buildDirectoryPath)
static std::optional< QQmlJSFixSuggestion > didYouMean(const QString &userInput, QStringList candidates, QQmlJS::SourceLocation location)
static ResolvedAlias resolveAlias(const QQmlJSTypeResolver *typeResolver, const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &owner, const AliasResolutionVisitor &visitor)