aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs/qmljscheck.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <[email protected]>2010-02-18 14:24:46 +0100
committerErik Verbruggen <[email protected]>2010-02-19 15:11:03 +0100
commit7ee1bc52423a75f792af92f4d34c76fc069f81c4 (patch)
tree02857e6a51d9c281a4bf61bbcde4cca38df512da /src/libs/qmljs/qmljscheck.cpp
parent9798dd75446f7195de4b43a93945e264bc1db6c9 (diff)
Suppress 'unknown property' warning after finding an unknown type.
And made the warnings/errors translatable.
Diffstat (limited to 'src/libs/qmljs/qmljscheck.cpp')
-rw-r--r--src/libs/qmljs/qmljscheck.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index b79a6495caa..9340ec4ee35 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -33,8 +33,20 @@
#include "qmljsevaluate.h"
#include "parser/qmljsast_p.h"
+#include <QtGui/QApplication>
#include <QtCore/QDebug>
+namespace QmlJS {
+namespace Messages {
+static const char *invalidPropertyName = QT_TRANSLATE_NOOP("QmlJS::Check", "'%1' is not a valid property name");
+static const char *unknownType = QT_TRANSLATE_NOOP("QmlJS::Check", "unknown type");
+} // namespace Messages
+
+static inline QString tr(const char *msg)
+{ return qApp->translate("QmlJS::Check", msg); }
+
+} // namespace QmlJS
+
using namespace QmlJS;
using namespace QmlJS::AST;
using namespace QmlJS::Interpreter;
@@ -94,15 +106,15 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
return;
}
+ const bool oldAllowAnyProperty = _allowAnyProperty;
+
if (! _context.lookupType(_doc.data(), typeId)) {
- warning(typeId->identifierToken, QLatin1String("unknown type"));
- // ### don't give up!
- return;
+ warning(typeId->identifierToken, tr(Messages::unknownType));
+ _allowAnyProperty = true; // suppress subsequent "unknown property" errors
}
const ObjectValue *oldScopeObject = _context.qmlScopeObject();
const ObjectValue *oldExtraScope = _extraScope;
- const bool oldAllowAnyProperty = _allowAnyProperty;
const ObjectValue *scopeObject = _doc->bind()->findQmlObject(ast);
_context.setQmlScopeObject(scopeObject);
@@ -205,8 +217,7 @@ void Check::checkScopeObjectMember(const UiQualifiedId *id)
value = _extraScope->lookupMember(propertyName, &_context);
if (!value) {
error(id->identifierToken,
- QString("'%1' is not a valid property name").arg(propertyName));
- return;
+ tr(Messages::invalidPropertyName).arg(propertyName));
}
// can't look up members for attached properties