aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-03-16 12:16:21 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-17 09:05:30 +0100
commit869efe4a49c5286493d7f039325992725bcac6c3 (patch)
treea1ec0e4ce0420f01fec603e053f9103636053d04 /tools
parent1b5a6c19ab701c9b94b1ffb094999c34643bcd1d (diff)
qmllint: Check for unknown types in JavaScript access
There are many incomplete qmltypes files around. We should not just crash on those. Task-number: QTBUG-82817 Change-Id: Ie072b80473927570c80fb2f9ae329de711c35904 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/scopetree.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp
index 07413094c0..8c5358c7a5 100644
--- a/tools/qmllint/scopetree.cpp
+++ b/tools/qmllint/scopetree.cpp
@@ -179,13 +179,30 @@ bool ScopeTree::checkMemberAccess(
return true;
}
+ if (!access->m_child)
+ return true;
+
if (const ScopeTree *type = scopeIt->type()) {
if (access->m_parentType.isEmpty())
return checkMemberAccess(code, access.get(), type, types, colorOut);
}
- return unknownBuiltins.contains(typeName) || checkMemberAccess(
- code, access.get(), types.value(typeName).get(), types, colorOut);
+ if (unknownBuiltins.contains(typeName))
+ return true;
+
+ const auto it = types.find(typeName);
+ if (it != types.end())
+ return checkMemberAccess(code, access.get(), it->get(), types, colorOut);
+
+ colorOut.write("Warning: ", Warning);
+ colorOut.write(
+ QString::fromLatin1("Type \"%1\" of member \"%2\" not found at %3:%4.\n")
+ .arg(typeName)
+ .arg(access->m_name)
+ .arg(access->m_location.startLine)
+ .arg(access->m_location.startColumn), Normal);
+ printContext(colorOut, code, access->m_location);
+ return false;
}
const auto scopeMethodIt = scope->m_methods.find(access->m_name);