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(
85 return content.
type();
96 return ::resolveAlias(
98 return idScopes.scope(
id, referrer);
108 int shortestDistance = userInput.
size();
118 std::sort(candidates.begin(), candidates.end());
120 for (
const QString &candidate : candidates) {
126 QList<int>
v0(candidate.size() + 1);
127 QList<int>
v1(candidate.size() + 1);
129 std::iota(
v0.begin(),
v0.end(), 0);
134 int deletionCost =
v0[
j + 1] + 1;
135 int insertionCost =
v1[
j] + 1;
136 int substitutionCost = userInput[
i] == candidate[
j] ?
v0[
j] :
v0[
j] + 1;
137 v1[
j + 1] = std::min({ deletionCost, insertionCost, substitutionCost });
144 shortestDistanceWord = candidate;
150 < std::min(std::max(userInput.size() / 2,
qsizetype(3)), userInput.size())) {
152 u
"Did you mean \"%1\"?"_s.arg(shortestDistanceWord),
166std::variant<QString, QQmlJS::DiagnosticMessage>
169 const auto makeError = [](
const QString &msg) {
174 return makeError(u
"QQmlJSImporter::metaDataMapper() is nullptr"_s);
181 if (!
entry.isValid())
182 return makeError(u
"Failed to find meta data entry in QQmlJSImporter::metaDataMapper()"_s);
183 if (!buildDirectoryPath.startsWith(
entry.filePath))
184 return makeError(u
"The module output directory does not match the build directory path"_s);
186 QString qrcPath = buildDirectoryPath;
193 if (sourceDirPaths.size() != 1) {
195 sourceDirPaths.
isEmpty() ? u
"<none>"_s : sourceDirPaths.join(u
", ");
197 QStringLiteral(
"QRC path %1 (deduced from %2) has unexpected number of mappings "
198 "(%3). File paths that matched:\n%4")
202 return sourceDirPaths[0];
217 const bool leftIsVar = typeResolver->
equals(lhsType, varType);
218 const bool righttIsVar = typeResolver->
equals(rhsType, varType);
219 return leftIsVar != righttIsVar;
232 return (lhsType->isReferenceType()
233 && (rhsType->isReferenceType()
235 || (rhsType->isReferenceType()
236 && (lhsType->isReferenceType()
250 return typeResolver->
equals(lhsType, typeResolver->
urlType())
QQmlJSResourceFileMapper * resourceFileMapper() const
QQmlJSResourceFileMapper * metaDataMapper() const
ContentVariant variant() const
QQmlJSScope::ConstPtr type() const
QDeferredSharedPointer< const QQmlJSScope > ConstPtr
bool equals(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const
QQmlJSScope::ConstPtr nullType() const
QQmlJSScope::ConstPtr urlType() const
QQmlJSRegisterContent scopedType(const QQmlJSScope::ConstPtr &scope, const QString &name, int lookupIndex=QQmlJSRegisterContent::InvalidLookupIndex, QQmlJSScopesByIdOptions options=Default) const
QQmlJSScope::ConstPtr varType() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
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.
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.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLsizei GLsizei GLfloat distance
bool canStrictlyCompareWithVar(const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, const QQmlJSScope::ConstPtr &rhsType)
bool canCompareWithQObject(const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, const QQmlJSScope::ConstPtr &rhsType)
bool canCompareWithQUrl(const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, const QQmlJSScope::ConstPtr &rhsType)
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(const QQmlJSMetaProperty &, const QQmlJSScope::ConstPtr &) processResolvedProperty)
std::function< void(const QQmlJSScope::ConstPtr &) processResolvedId)
std::function< void()> reset
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)