summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljscheck.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-09-29 11:48:13 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-10-12 08:49:30 +0200
commit038111c384e79d20faa33e52a9bbbc8999ad695b (patch)
tree0d0b680bf6bfabbcc8f4b16f9b8ed31dbe6d11db /src/libs/qmljs/qmljscheck.cpp
parentf3c78d352276f01035d79f0a97cfe88f43b30374 (diff)
downloadqt-creator-038111c384e79d20faa33e52a9bbbc8999ad695b.tar.gz
QmlJS checks: Disable some checks when imports failed.
The important error in this case is on the import. Change-Id: I3a547ca7ac44a89aba6819ea80ec52185071408a Reviewed-on: http://codereview.qt-project.org/5879 Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com> Sanity-Review: Christian Kamm <christian.d.kamm@nokia.com>
Diffstat (limited to 'src/libs/qmljs/qmljscheck.cpp')
-rw-r--r--src/libs/qmljs/qmljscheck.cpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index 4f6860209d..680d033ad1 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -513,7 +513,12 @@ Check::Check(Document::Ptr doc, const ContextPtr &context)
, _scopeChain(doc, _context)
, _scopeBuilder(&_scopeChain)
, _lastValue(0)
+ , _importsOk(false)
{
+ const Imports *imports = context->imports(doc.data());
+ if (imports && !imports->importFailed())
+ _importsOk = true;
+
_enabledMessages = Message::allMessageTypes().toSet();
disableMessage(HintAnonymousFunctionSpacing);
disableMessage(HintDeclareVarsInOneLine);
@@ -623,29 +628,31 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
}
bool typeError = false;
- const SourceLocation typeErrorLocation = fullLocationForQualifiedId(typeId);
- const ObjectValue *prototype = _context->lookupType(_doc.data(), typeId);
- if (!prototype) {
- typeError = true;
- addMessage(ErrUnknownComponent, typeErrorLocation);
- } else {
- PrototypeIterator iter(prototype, _context);
- QList<const ObjectValue *> prototypes = iter.all();
- if (iter.error() != PrototypeIterator::NoError)
+ if (_importsOk) {
+ const SourceLocation typeErrorLocation = fullLocationForQualifiedId(typeId);
+ const ObjectValue *prototype = _context->lookupType(_doc.data(), typeId);
+ if (!prototype) {
typeError = true;
- const ObjectValue *lastPrototype = prototypes.last();
- if (iter.error() == PrototypeIterator::ReferenceResolutionError) {
- if (const QmlPrototypeReference *ref =
- dynamic_cast<const QmlPrototypeReference *>(lastPrototype->prototype())) {
- addMessage(ErrCouldNotResolvePrototypeOf, typeErrorLocation,
- toString(ref->qmlTypeName()), lastPrototype->className());
- } else {
- addMessage(ErrCouldNotResolvePrototype, typeErrorLocation,
+ addMessage(ErrUnknownComponent, typeErrorLocation);
+ } else {
+ PrototypeIterator iter(prototype, _context);
+ QList<const ObjectValue *> prototypes = iter.all();
+ if (iter.error() != PrototypeIterator::NoError)
+ typeError = true;
+ const ObjectValue *lastPrototype = prototypes.last();
+ if (iter.error() == PrototypeIterator::ReferenceResolutionError) {
+ if (const QmlPrototypeReference *ref =
+ dynamic_cast<const QmlPrototypeReference *>(lastPrototype->prototype())) {
+ addMessage(ErrCouldNotResolvePrototypeOf, typeErrorLocation,
+ toString(ref->qmlTypeName()), lastPrototype->className());
+ } else {
+ addMessage(ErrCouldNotResolvePrototype, typeErrorLocation,
+ lastPrototype->className());
+ }
+ } else if (iter.error() == PrototypeIterator::CycleError) {
+ addMessage(ErrPrototypeCycle, typeErrorLocation,
lastPrototype->className());
}
- } else if (iter.error() == PrototypeIterator::CycleError) {
- addMessage(ErrPrototypeCycle, typeErrorLocation,
- lastPrototype->className());
}
}
@@ -1197,6 +1204,9 @@ bool Check::visit(StatementList *ast)
/// ### Maybe put this into the context as a helper method.
const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
{
+ if (!_importsOk)
+ return 0;
+
QList<const ObjectValue *> scopeObjects = _scopeChain.qmlScopeObjects();
if (scopeObjects.isEmpty())
return 0;