Commit 7ee1bc52 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Suppress 'unknown property' warning after finding an unknown type.

And made the warnings/errors translatable.
parent 9798dd75
...@@ -33,8 +33,20 @@ ...@@ -33,8 +33,20 @@
#include "qmljsevaluate.h" #include "qmljsevaluate.h"
#include "parser/qmljsast_p.h" #include "parser/qmljsast_p.h"
#include <QtGui/QApplication>
#include <QtCore/QDebug> #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;
using namespace QmlJS::AST; using namespace QmlJS::AST;
using namespace QmlJS::Interpreter; using namespace QmlJS::Interpreter;
...@@ -94,15 +106,15 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId, ...@@ -94,15 +106,15 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
return; return;
} }
const bool oldAllowAnyProperty = _allowAnyProperty;
if (! _context.lookupType(_doc.data(), typeId)) { if (! _context.lookupType(_doc.data(), typeId)) {
warning(typeId->identifierToken, QLatin1String("unknown type")); warning(typeId->identifierToken, tr(Messages::unknownType));
// ### don't give up! _allowAnyProperty = true; // suppress subsequent "unknown property" errors
return;
} }
const ObjectValue *oldScopeObject = _context.qmlScopeObject(); const ObjectValue *oldScopeObject = _context.qmlScopeObject();
const ObjectValue *oldExtraScope = _extraScope; const ObjectValue *oldExtraScope = _extraScope;
const bool oldAllowAnyProperty = _allowAnyProperty;
const ObjectValue *scopeObject = _doc->bind()->findQmlObject(ast); const ObjectValue *scopeObject = _doc->bind()->findQmlObject(ast);
_context.setQmlScopeObject(scopeObject); _context.setQmlScopeObject(scopeObject);
...@@ -205,8 +217,7 @@ void Check::checkScopeObjectMember(const UiQualifiedId *id) ...@@ -205,8 +217,7 @@ void Check::checkScopeObjectMember(const UiQualifiedId *id)
value = _extraScope->lookupMember(propertyName, &_context); value = _extraScope->lookupMember(propertyName, &_context);
if (!value) { if (!value) {
error(id->identifierToken, error(id->identifierToken,
QString("'%1' is not a valid property name").arg(propertyName)); tr(Messages::invalidPropertyName).arg(propertyName));
return;
} }
// can't look up members for attached properties // can't look up members for attached properties
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment