qmllint: Move 'type not found in namespace' warning to qmlcompiler
Change-Id: Ibe7ae9afbfb7754d16cd0ce13185961e9ae2c769 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
e1fa8df0da
commit
453bd25b49
|
@ -472,12 +472,17 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName)
|
|||
m_state.accumulatorOut =
|
||||
m_typeResolver->memberType(m_state.accumulatorIn, m_state.savedPrefix + propertyName);
|
||||
|
||||
if (!m_state.accumulatorOut.isValid() && m_typeResolver->isPrefix(propertyName)) {
|
||||
m_state.savedPrefix = propertyName + u"."_qs;
|
||||
m_state.accumulatorOut = m_state.accumulatorIn.isValid()
|
||||
? m_state.accumulatorIn
|
||||
: m_typeResolver->globalType(m_currentScope);
|
||||
return;
|
||||
if (!m_state.accumulatorOut.isValid()) {
|
||||
if (m_typeResolver->isPrefix(propertyName)) {
|
||||
m_state.savedPrefix = propertyName + u"."_qs;
|
||||
m_state.accumulatorOut = m_state.accumulatorIn.isValid()
|
||||
? m_state.accumulatorIn
|
||||
: m_typeResolver->globalType(m_currentScope);
|
||||
return;
|
||||
}
|
||||
if (!m_state.savedPrefix.isEmpty())
|
||||
m_logger->logWarning(u"Type not found in namespace"_qs, Log_Type,
|
||||
getCurrentSourceLocation());
|
||||
}
|
||||
|
||||
m_state.savedPrefix.clear();
|
||||
|
|
|
@ -421,9 +421,7 @@ void TestQmllint::dirtyQmlCode_data()
|
|||
<< false;
|
||||
QTest::newRow("brokenNamespace")
|
||||
<< QStringLiteral("brokenNamespace.qml")
|
||||
<< QString("Warning: %1:4:17: Type not found in namespace")
|
||||
<< QString()
|
||||
<< false;
|
||||
<< QString("Warning: %1:4:19: Type not found in namespace") << QString() << false;
|
||||
QTest::newRow("segFault (bad)")
|
||||
<< QStringLiteral("SegFault.bad.qml")
|
||||
<< QStringLiteral("Property \"foobar\" not found on type \"QQuickScreenAttached\"")
|
||||
|
|
|
@ -319,7 +319,6 @@ void CheckIdentifiers::operator()(
|
|||
|
||||
const QString baseName = memberAccessBase.m_name;
|
||||
auto typeIt = m_types.find(memberAccessBase.m_name);
|
||||
bool baseIsPrefixed = false;
|
||||
while (typeIt != m_types.end() && typeIt->isNull()) {
|
||||
// This is a namespaced import. Check with the full name.
|
||||
if (!memberAccessChain.isEmpty()) {
|
||||
|
@ -330,7 +329,6 @@ void CheckIdentifiers::operator()(
|
|||
+ memberAccessBase.m_location.length;
|
||||
memberAccessBase.m_location = location;
|
||||
typeIt = m_types.find(memberAccessBase.m_name);
|
||||
baseIsPrefixed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,23 +337,6 @@ void CheckIdentifiers::operator()(
|
|||
continue;
|
||||
}
|
||||
|
||||
// If we're in a custom parser component (or one of their children) we cannot be sure
|
||||
// that this is really an unqualified access. We have to err on the side of producing
|
||||
// false negatives for the sake of usability.
|
||||
if (qmlScope->isInCustomParserParent()) {
|
||||
// We can handle Connections properly
|
||||
if (qmlScope->baseType()
|
||||
&& qmlScope->baseType()->internalName() != u"QQmlConnections"_qs)
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto location = memberAccessBase.m_location;
|
||||
|
||||
if (baseIsPrefixed) {
|
||||
m_logger->logWarning(QLatin1String("Type not found in namespace"), Log_Type,
|
||||
location);
|
||||
}
|
||||
|
||||
Q_UNUSED(signalHandlers)
|
||||
Q_UNUSED(rootId)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue