Restore offset/length in QQmlJS::DiagnosticMessage
This is needed in a few places outside of declarative, so this change
restores the loc member in DiagnosticMessage and moves
QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory.
QQmlError is unaffected and retains only line/column.
Amends d4d197d062
Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
d8f6f41c33
commit
8ab237edf1
|
@ -28,6 +28,7 @@ HEADERS += \
|
|||
$$PWD/qqmljsdiagnosticmessage_p.h \
|
||||
$$PWD/qqmljsfixedpoolarray_p.h \
|
||||
$$PWD/qqmljsmemorypool_p.h \
|
||||
$$PWD/qqmljssourcelocation_p.h \
|
||||
$$PWD/qv4alloca_p.h \
|
||||
$$PWD/qv4calldata_p.h \
|
||||
$$PWD/qv4compileddata_p.h \
|
||||
|
|
|
@ -51,6 +51,6 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#define Q_QML_PRIVATE_API_VERSION 7
|
||||
#define Q_QML_PRIVATE_API_VERSION 8
|
||||
|
||||
#endif // QQMLAPIVERSION_P_H
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
// QQmlSourceLocation -> line/column change.
|
||||
#include <private/qqmlapiversion_p.h>
|
||||
|
||||
#include "qqmljssourcelocation_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QQmlJS {
|
||||
|
@ -65,8 +67,7 @@ struct DiagnosticMessage
|
|||
{
|
||||
QString message;
|
||||
QtMsgType type = QtCriticalMsg;
|
||||
quint32 line = 0;
|
||||
quint32 column = 0;
|
||||
SourceLocation loc;
|
||||
|
||||
bool isError() const
|
||||
{
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#ifndef QQMLJSSOURCELOCATION_P_H
|
||||
#define QQMLJSSOURCELOCATION_P_H
|
||||
|
||||
#include "qqmljsglobal_p.h"
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
//
|
||||
|
@ -57,7 +55,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QQmlJS { namespace AST {
|
||||
namespace QQmlJS {
|
||||
|
||||
class SourceLocation
|
||||
{
|
||||
|
@ -80,7 +78,7 @@ public:
|
|||
quint32 startColumn;
|
||||
};
|
||||
|
||||
} } // namespace AST
|
||||
} // namespace QQmlJS
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -169,7 +169,7 @@ QV4::CompiledData::BuiltinType Parameter::stringToBuiltinType(const QString &typ
|
|||
return QV4::CompiledData::BuiltinType::InvalidBuiltin;
|
||||
}
|
||||
|
||||
void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &loc)
|
||||
void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::SourceLocation &loc)
|
||||
{
|
||||
inheritedTypeNameIndex = typeNameIndex;
|
||||
|
||||
|
@ -193,7 +193,7 @@ void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, cons
|
|||
declarationsOverride = nullptr;
|
||||
}
|
||||
|
||||
QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation)
|
||||
QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::SourceLocation *errorLocation)
|
||||
{
|
||||
QSet<int> functionNames;
|
||||
for (auto functionit = obj->functionsBegin(); functionit != obj->functionsEnd(); ++functionit) {
|
||||
|
@ -249,7 +249,7 @@ QString Object::appendSignal(Signal *signal)
|
|||
return QString(); // no error
|
||||
}
|
||||
|
||||
QString Object::appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation)
|
||||
QString Object::appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation)
|
||||
{
|
||||
Object *target = declarationsOverride;
|
||||
if (!target)
|
||||
|
@ -273,7 +273,7 @@ QString Object::appendProperty(Property *prop, const QString &propertyName, bool
|
|||
return QString(); // no error
|
||||
}
|
||||
|
||||
QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation)
|
||||
QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation)
|
||||
{
|
||||
Object *target = declarationsOverride;
|
||||
if (!target)
|
||||
|
@ -358,8 +358,8 @@ QString Object::bindingAsString(Document *doc, int scriptIndex) const
|
|||
QQmlJS::AST::Node *node = foe->node;
|
||||
if (QQmlJS::AST::ExpressionStatement *exprStmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(node))
|
||||
node = exprStmt->expression;
|
||||
QQmlJS::AST::SourceLocation start = node->firstSourceLocation();
|
||||
QQmlJS::AST::SourceLocation end = node->lastSourceLocation();
|
||||
QQmlJS::SourceLocation start = node->firstSourceLocation();
|
||||
QQmlJS::SourceLocation end = node->lastSourceLocation();
|
||||
return doc->code.mid(start.offset, end.offset + end.length - start.offset);
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen
|
|||
// Extract errors from the parser
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
|
||||
if (m.isWarning()) {
|
||||
qWarning("%s:%d : %s", qPrintable(url), m.line, qPrintable(m.message));
|
||||
qWarning("%s:%d : %s", qPrintable(url), m.loc.startLine, qPrintable(m.message));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen
|
|||
accept(program->headers);
|
||||
|
||||
if (program->members->next) {
|
||||
QQmlJS::AST::SourceLocation loc = program->members->next->firstSourceLocation();
|
||||
QQmlJS::SourceLocation loc = program->members->next->firstSourceLocation();
|
||||
recordError(loc, QCoreApplication::translate("QQmlParser", "Unexpected object definition"));
|
||||
return false;
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiObjectDefinition *node)
|
|||
int idx = 0;
|
||||
if (!defineQMLObject(&idx, node))
|
||||
return false;
|
||||
const QQmlJS::AST::SourceLocation nameLocation = node->qualifiedTypeNameId->identifierToken;
|
||||
const QQmlJS::SourceLocation nameLocation = node->qualifiedTypeNameId->identifierToken;
|
||||
appendBinding(nameLocation, nameLocation, emptyStringIndex, idx);
|
||||
} else {
|
||||
int idx = 0;
|
||||
|
@ -590,7 +590,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiScriptBinding *node)
|
|||
|
||||
bool IRBuilder::visit(QQmlJS::AST::UiArrayBinding *node)
|
||||
{
|
||||
const QQmlJS::AST::SourceLocation qualifiedNameLocation = node->qualifiedId->identifierToken;
|
||||
const QQmlJS::SourceLocation qualifiedNameLocation = node->qualifiedId->identifierToken;
|
||||
Object *object = nullptr;
|
||||
QQmlJS::AST::UiQualifiedId *name = node->qualifiedId;
|
||||
if (!resolveQualifiedId(&name, &object))
|
||||
|
@ -655,7 +655,7 @@ void IRBuilder::accept(QQmlJS::AST::Node *node)
|
|||
QQmlJS::AST::Node::accept(node, this);
|
||||
}
|
||||
|
||||
bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride)
|
||||
bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride)
|
||||
{
|
||||
if (QQmlJS::AST::UiQualifiedId *lastName = qualifiedTypeNameId) {
|
||||
while (lastName->next)
|
||||
|
@ -691,7 +691,7 @@ bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qu
|
|||
if (!errors.isEmpty())
|
||||
return false;
|
||||
|
||||
QQmlJS::AST::SourceLocation loc;
|
||||
QQmlJS::SourceLocation loc;
|
||||
QString error = sanityCheckFunctionNames(obj, illegalNames, &loc);
|
||||
if (!error.isEmpty()) {
|
||||
recordError(loc, error);
|
||||
|
@ -871,7 +871,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
|
|||
const QString signalName = node->name.toString();
|
||||
signal->nameIndex = registerString(signalName);
|
||||
|
||||
QQmlJS::AST::SourceLocation loc = node->typeToken;
|
||||
QQmlJS::SourceLocation loc = node->typeToken;
|
||||
signal->location.line = loc.startLine;
|
||||
signal->location.column = loc.startColumn;
|
||||
|
||||
|
@ -954,11 +954,11 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
|
|||
const QString propName = name.toString();
|
||||
property->nameIndex = registerString(propName);
|
||||
|
||||
QQmlJS::AST::SourceLocation loc = node->firstSourceLocation();
|
||||
QQmlJS::SourceLocation loc = node->firstSourceLocation();
|
||||
property->location.line = loc.startLine;
|
||||
property->location.column = loc.startColumn;
|
||||
|
||||
QQmlJS::AST::SourceLocation errorLocation;
|
||||
QQmlJS::SourceLocation errorLocation;
|
||||
QString error;
|
||||
|
||||
if (illegalNames.contains(propName))
|
||||
|
@ -999,7 +999,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiSourceElement *node)
|
|||
const int index = _object->functionsAndExpressions->append(foe);
|
||||
|
||||
Function *f = New<Function>();
|
||||
QQmlJS::AST::SourceLocation loc = funDecl->identifierToken;
|
||||
QQmlJS::SourceLocation loc = funDecl->identifierToken;
|
||||
f->location.line = loc.startLine;
|
||||
f->location.column = loc.startColumn;
|
||||
f->index = index;
|
||||
|
@ -1073,14 +1073,14 @@ void IRBuilder::extractVersion(const QStringRef &string, int *maj, int *min)
|
|||
}
|
||||
}
|
||||
|
||||
QStringRef IRBuilder::textRefAt(const QQmlJS::AST::SourceLocation &first, const QQmlJS::AST::SourceLocation &last) const
|
||||
QStringRef IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const
|
||||
{
|
||||
return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset);
|
||||
}
|
||||
|
||||
void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
|
||||
{
|
||||
QQmlJS::AST::SourceLocation loc = statement->firstSourceLocation();
|
||||
QQmlJS::SourceLocation loc = statement->firstSourceLocation();
|
||||
binding->valueLocation.line = loc.startLine;
|
||||
binding->valueLocation.column = loc.startColumn;
|
||||
binding->type = QV4::CompiledData::Binding::Type_Invalid;
|
||||
|
@ -1257,7 +1257,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
|
|||
|
||||
void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
|
||||
{
|
||||
const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken;
|
||||
const QQmlJS::SourceLocation qualifiedNameLocation = name->identifierToken;
|
||||
Object *object = nullptr;
|
||||
if (!resolveQualifiedId(&name, &object))
|
||||
return;
|
||||
|
@ -1272,7 +1272,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Sta
|
|||
|
||||
void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment)
|
||||
{
|
||||
const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken;
|
||||
const QQmlJS::SourceLocation qualifiedNameLocation = name->identifierToken;
|
||||
Object *object = nullptr;
|
||||
if (!resolveQualifiedId(&name, &object, isOnAssignment))
|
||||
return;
|
||||
|
@ -1281,7 +1281,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex,
|
|||
qSwap(_object, object);
|
||||
}
|
||||
|
||||
void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
|
||||
void IRBuilder::appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex,
|
||||
QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
|
||||
{
|
||||
Binding *binding = New<Binding>();
|
||||
|
@ -1297,7 +1297,7 @@ void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLo
|
|||
}
|
||||
}
|
||||
|
||||
void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment)
|
||||
void IRBuilder::appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment)
|
||||
{
|
||||
if (stringAt(propertyNameIndex) == QLatin1String("id")) {
|
||||
recordError(nameLocation, tr("Invalid component id specification"));
|
||||
|
@ -1346,7 +1346,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node)
|
|||
const QString propName = node->name.toString();
|
||||
alias->nameIndex = registerString(propName);
|
||||
|
||||
QQmlJS::AST::SourceLocation loc = node->firstSourceLocation();
|
||||
QQmlJS::SourceLocation loc = node->firstSourceLocation();
|
||||
alias->location.line = loc.startLine;
|
||||
alias->location.column = loc.startColumn;
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node)
|
|||
if (!node->statement && !node->binding)
|
||||
COMPILE_EXCEPTION(loc, tr("No property alias location"));
|
||||
|
||||
QQmlJS::AST::SourceLocation rhsLoc;
|
||||
QQmlJS::SourceLocation rhsLoc;
|
||||
if (node->binding)
|
||||
rhsLoc = node->binding->firstSourceLocation();
|
||||
else if (node->statement)
|
||||
|
@ -1390,7 +1390,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node)
|
|||
propertyValue += QLatin1Char('.') + aliasReference.at(2);
|
||||
alias->propertyNameIndex = registerString(propertyValue);
|
||||
|
||||
QQmlJS::AST::SourceLocation errorLocation;
|
||||
QQmlJS::SourceLocation errorLocation;
|
||||
QString error;
|
||||
|
||||
if (illegalNames.contains(propName))
|
||||
|
@ -1416,9 +1416,9 @@ Object *IRBuilder::bindingsTarget() const
|
|||
return _object;
|
||||
}
|
||||
|
||||
bool IRBuilder::setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
|
||||
bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
|
||||
{
|
||||
QQmlJS::AST::SourceLocation loc = value->firstSourceLocation();
|
||||
QQmlJS::SourceLocation loc = value->firstSourceLocation();
|
||||
QStringRef str;
|
||||
|
||||
QQmlJS::AST::Node *node = value;
|
||||
|
@ -1520,7 +1520,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
|
|||
binding->type = QV4::CompiledData::Binding::Type_GroupProperty;
|
||||
|
||||
int objIndex = 0;
|
||||
if (!defineQMLObject(&objIndex, nullptr, QQmlJS::AST::SourceLocation(), nullptr, nullptr))
|
||||
if (!defineQMLObject(&objIndex, nullptr, QQmlJS::SourceLocation(), nullptr, nullptr))
|
||||
return false;
|
||||
binding->value.objectIndex = objIndex;
|
||||
|
||||
|
@ -1543,11 +1543,10 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
|
|||
return true;
|
||||
}
|
||||
|
||||
void IRBuilder::recordError(const QQmlJS::AST::SourceLocation &location, const QString &description)
|
||||
void IRBuilder::recordError(const QQmlJS::SourceLocation &location, const QString &description)
|
||||
{
|
||||
QQmlJS::DiagnosticMessage error;
|
||||
error.line = location.startLine;
|
||||
error.column = location.startColumn;
|
||||
error.loc = location;
|
||||
error.message = description;
|
||||
errors << error;
|
||||
}
|
||||
|
|
|
@ -371,12 +371,12 @@ public:
|
|||
// specified object. Used for declarations inside group properties.
|
||||
Object *declarationsOverride;
|
||||
|
||||
void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &location = QQmlJS::AST::SourceLocation());
|
||||
void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::SourceLocation &location = QQmlJS::SourceLocation());
|
||||
|
||||
QString appendEnum(Enum *enumeration);
|
||||
QString appendSignal(Signal *signal);
|
||||
QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation);
|
||||
QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation);
|
||||
QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation);
|
||||
QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation);
|
||||
void appendFunction(QmlIR::Function *f);
|
||||
void appendInlineComponent(InlineComponent *ic);
|
||||
void appendRequiredPropertyExtraData(RequiredPropertyExtraData *extraData);
|
||||
|
@ -485,24 +485,24 @@ public:
|
|||
|
||||
void throwRecursionDepthError() override
|
||||
{
|
||||
recordError(QQmlJS::AST::SourceLocation(),
|
||||
recordError(QQmlJS::SourceLocation(),
|
||||
QStringLiteral("Maximum statement or expression depth exceeded"));
|
||||
}
|
||||
|
||||
void accept(QQmlJS::AST::Node *node);
|
||||
|
||||
// returns index in _objects
|
||||
bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr);
|
||||
bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr);
|
||||
bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiObjectDefinition *node, Object *declarationsOverride = nullptr)
|
||||
{ return defineQMLObject(objectIndex, node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); }
|
||||
|
||||
static QString asString(QQmlJS::AST::UiQualifiedId *node);
|
||||
QStringRef asStringRef(QQmlJS::AST::Node *node);
|
||||
static void extractVersion(const QStringRef &string, int *maj, int *min);
|
||||
QStringRef textRefAt(const QQmlJS::AST::SourceLocation &loc) const
|
||||
QStringRef textRefAt(const QQmlJS::SourceLocation &loc) const
|
||||
{ return QStringRef(&sourceCode, loc.offset, loc.length); }
|
||||
QStringRef textRefAt(const QQmlJS::AST::SourceLocation &first,
|
||||
const QQmlJS::AST::SourceLocation &last) const;
|
||||
QStringRef textRefAt(const QQmlJS::SourceLocation &first,
|
||||
const QQmlJS::SourceLocation &last) const;
|
||||
|
||||
void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement,
|
||||
QQmlJS::AST::Node *parentNode);
|
||||
|
@ -511,24 +511,24 @@ public:
|
|||
void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value,
|
||||
QQmlJS::AST::Node *parentNode);
|
||||
void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false);
|
||||
void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation,
|
||||
const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
|
||||
void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation,
|
||||
const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex,
|
||||
QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode);
|
||||
void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation,
|
||||
const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
|
||||
void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation,
|
||||
const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex,
|
||||
int objectIndex, bool isListItem = false, bool isOnAssignment = false);
|
||||
|
||||
bool appendAlias(QQmlJS::AST::UiPublicMember *node);
|
||||
|
||||
Object *bindingsTarget() const;
|
||||
|
||||
bool setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value);
|
||||
bool setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value);
|
||||
|
||||
// resolves qualified name (font.pixelSize for example) and returns the last name along
|
||||
// with the object any right-hand-side of a binding should apply to.
|
||||
bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, Object **object, bool onAssignment = false);
|
||||
|
||||
void recordError(const QQmlJS::AST::SourceLocation &location, const QString &description);
|
||||
void recordError(const QQmlJS::SourceLocation &location, const QString &description);
|
||||
|
||||
quint32 registerString(const QString &str) const { return jsGenerator->registerString(str); }
|
||||
template <typename _Tp> _Tp *New() { return pool->New<_Tp>(); }
|
||||
|
@ -538,7 +538,7 @@ public:
|
|||
static bool isStatementNodeScript(QQmlJS::AST::Statement *statement);
|
||||
static bool isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement);
|
||||
|
||||
QString sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation);
|
||||
QString sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::SourceLocation *errorLocation);
|
||||
|
||||
QList<QQmlJS::DiagnosticMessage> errors;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ QT_USE_NAMESPACE
|
|||
using namespace QV4;
|
||||
using namespace Moth;
|
||||
|
||||
void BytecodeGenerator::setLocation(const QQmlJS::AST::SourceLocation &loc)
|
||||
void BytecodeGenerator::setLocation(const QQmlJS::SourceLocation &loc)
|
||||
{
|
||||
currentLine = static_cast<int>(loc.startLine);
|
||||
}
|
||||
|
|
|
@ -56,10 +56,8 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QQmlJS {
|
||||
namespace AST {
|
||||
class SourceLocation;
|
||||
}
|
||||
}
|
||||
|
||||
namespace QV4 {
|
||||
|
||||
|
@ -244,7 +242,7 @@ QT_WARNING_POP
|
|||
|
||||
|
||||
|
||||
void setLocation(const QQmlJS::AST::SourceLocation &loc);
|
||||
void setLocation(const QQmlJS::SourceLocation &loc);
|
||||
|
||||
ExceptionHandler *exceptionHandler() const {
|
||||
return currentExceptionHandler;
|
||||
|
|
|
@ -3821,8 +3821,7 @@ void Codegen::throwError(ErrorType errorType, const SourceLocation &loc, const Q
|
|||
|
||||
_errorType = errorType;
|
||||
_error.message = detail;
|
||||
_error.line = loc.startLine;
|
||||
_error.column = loc.startColumn;
|
||||
_error.loc = loc;
|
||||
}
|
||||
|
||||
void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail)
|
||||
|
@ -4105,7 +4104,7 @@ Codegen::Reference Codegen::Reference::asLValue() const
|
|||
case Accumulator:
|
||||
Q_UNREACHABLE();
|
||||
case Super:
|
||||
codegen->throwSyntaxError(AST::SourceLocation(), QStringLiteral("Super lvalues not implemented."));
|
||||
codegen->throwSyntaxError(SourceLocation(), QStringLiteral("Super lvalues not implemented."));
|
||||
return *this;
|
||||
case Member:
|
||||
if (!propertyBase.isStackSlot()) {
|
||||
|
|
|
@ -661,12 +661,12 @@ protected:
|
|||
bool visit(QQmlJS::AST::UiSourceElement *ast) override;
|
||||
|
||||
bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(const Reference &r,
|
||||
const QQmlJS::AST::SourceLocation &loc);
|
||||
virtual void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail);
|
||||
virtual void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail);
|
||||
const QQmlJS::SourceLocation &loc);
|
||||
virtual void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail);
|
||||
virtual void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail);
|
||||
void throwRecursionDepthError() override
|
||||
{
|
||||
throwSyntaxError(QQmlJS::AST::SourceLocation(),
|
||||
throwSyntaxError(QQmlJS::SourceLocation(),
|
||||
QStringLiteral("Maximum statement or expression depth exceeded"));
|
||||
}
|
||||
|
||||
|
@ -700,7 +700,7 @@ public:
|
|||
|
||||
Reference referenceForName(
|
||||
const QString &name, bool lhs,
|
||||
const QQmlJS::AST::SourceLocation &accessLocation = QQmlJS::AST::SourceLocation());
|
||||
const QQmlJS::SourceLocation &accessLocation = QQmlJS::SourceLocation());
|
||||
|
||||
QV4::CompiledData::CompilationUnit generateCompilationUnit(bool generateUnitData = true);
|
||||
static QV4::CompiledData::CompilationUnit compileModule(
|
||||
|
@ -810,7 +810,7 @@ protected:
|
|||
private:
|
||||
VolatileMemoryLocations scanVolatileMemoryLocations(QQmlJS::AST::Node *ast);
|
||||
void handleConstruct(const Reference &base, QQmlJS::AST::ArgumentList *args);
|
||||
void throwError(ErrorType errorType, const QQmlJS::AST::SourceLocation &loc,
|
||||
void throwError(ErrorType errorType, const QQmlJS::SourceLocation &loc,
|
||||
const QString &detail);
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ QT_USE_NAMESPACE
|
|||
using namespace QV4;
|
||||
using namespace QV4::Compiler;
|
||||
using namespace QQmlJS::AST;
|
||||
using namespace QQmlJS;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -86,7 +87,7 @@ bool Context::Member::requiresTDZCheck(const SourceLocation &accessLocation, boo
|
|||
}
|
||||
|
||||
bool Context::addLocalVar(const QString &name, Context::MemberType type, VariableScope scope, FunctionExpression *function,
|
||||
const QQmlJS::AST::SourceLocation &endOfInitializer)
|
||||
const QQmlJS::SourceLocation &endOfInitializer)
|
||||
{
|
||||
// ### can this happen?
|
||||
if (name.isEmpty())
|
||||
|
@ -122,7 +123,7 @@ bool Context::addLocalVar(const QString &name, Context::MemberType type, Variabl
|
|||
return true;
|
||||
}
|
||||
|
||||
Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation)
|
||||
Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation)
|
||||
{
|
||||
int scope = 0;
|
||||
Context *c = this;
|
||||
|
|
|
@ -183,10 +183,10 @@ struct Context {
|
|||
QQmlJS::AST::VariableScope scope = QQmlJS::AST::VariableScope::Var;
|
||||
mutable bool canEscape = false;
|
||||
QQmlJS::AST::FunctionExpression *function = nullptr;
|
||||
QQmlJS::AST::SourceLocation endOfInitializerLocation;
|
||||
QQmlJS::SourceLocation endOfInitializerLocation;
|
||||
|
||||
bool isLexicallyScoped() const { return this->scope != QQmlJS::AST::VariableScope::Var; }
|
||||
bool requiresTDZCheck(const QQmlJS::AST::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const;
|
||||
bool requiresTDZCheck(const QQmlJS::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const;
|
||||
};
|
||||
typedef QMap<QString, Member> MemberMap;
|
||||
|
||||
|
@ -227,7 +227,7 @@ struct Context {
|
|||
bool isWithBlock = false;
|
||||
bool isCatchBlock = false;
|
||||
QString caughtVariable;
|
||||
QQmlJS::AST::SourceLocation lastBlockInitializerLocation;
|
||||
QQmlJS::SourceLocation lastBlockInitializerLocation;
|
||||
|
||||
enum UsesArgumentsObject {
|
||||
ArgumentsObjectUnknown,
|
||||
|
@ -331,7 +331,7 @@ struct Context {
|
|||
}
|
||||
|
||||
bool addLocalVar(const QString &name, MemberType contextType, QQmlJS::AST::VariableScope scope, QQmlJS::AST::FunctionExpression *function = nullptr,
|
||||
const QQmlJS::AST::SourceLocation &endOfInitializer = QQmlJS::AST::SourceLocation());
|
||||
const QQmlJS::SourceLocation &endOfInitializer = QQmlJS::SourceLocation());
|
||||
|
||||
struct ResolvedName {
|
||||
enum Type {
|
||||
|
@ -348,10 +348,10 @@ struct Context {
|
|||
bool requiresTDZCheck = false;
|
||||
int scope = -1;
|
||||
int index = -1;
|
||||
QQmlJS::AST::SourceLocation endOfDeclarationLocation;
|
||||
QQmlJS::SourceLocation endOfDeclarationLocation;
|
||||
bool isValid() const { return type != Unresolved; }
|
||||
};
|
||||
ResolvedName resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation);
|
||||
ResolvedName resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation);
|
||||
void emitBlockHeader(Compiler::Codegen *codegen);
|
||||
void emitBlockFooter(Compiler::Codegen *codegen);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ using namespace QV4::Compiler;
|
|||
using namespace QQmlJS;
|
||||
using namespace QQmlJS::AST;
|
||||
|
||||
static CompiledData::Location location(const QQmlJS::AST::SourceLocation &astLocation)
|
||||
static CompiledData::Location location(const QQmlJS::SourceLocation &astLocation)
|
||||
{
|
||||
CompiledData::Location target;
|
||||
target.line = astLocation.startLine;
|
||||
|
@ -129,7 +129,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast)
|
|||
}
|
||||
}
|
||||
|
||||
void ScanFunctions::checkName(const QStringRef &name, const SourceLocation &loc)
|
||||
void ScanFunctions::checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc)
|
||||
{
|
||||
if (_context->isStrict) {
|
||||
if (name == QLatin1String("implements")
|
||||
|
@ -330,7 +330,7 @@ bool ScanFunctions::visit(PatternElement *ast)
|
|||
BoundNames names;
|
||||
ast->boundNames(&names);
|
||||
|
||||
QQmlJS::AST::SourceLocation lastInitializerLocation = ast->lastSourceLocation();
|
||||
QQmlJS::SourceLocation lastInitializerLocation = ast->lastSourceLocation();
|
||||
if (_context->lastBlockInitializerLocation.isValid())
|
||||
lastInitializerLocation = _context->lastBlockInitializerLocation;
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ protected:
|
|||
|
||||
void checkDirectivePrologue(QQmlJS::AST::StatementList *ast);
|
||||
|
||||
void checkName(const QStringRef &name, const QQmlJS::AST::SourceLocation &loc);
|
||||
void checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc);
|
||||
|
||||
bool visit(QQmlJS::AST::Program *ast) override;
|
||||
void endVisit(QQmlJS::AST::Program *) override;
|
||||
|
|
|
@ -1910,10 +1910,10 @@ QQmlRefPointer<ExecutableCompilationUnit> ExecutionEngine::compileModule(
|
|||
sourceCode, sourceTimeStamp, &diagnostics);
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnostics) {
|
||||
if (m.isError()) {
|
||||
throwSyntaxError(m.message, url.toString(), m.line, m.column);
|
||||
throwSyntaxError(m.message, url.toString(), m.loc.startLine, m.loc.startColumn);
|
||||
return nullptr;
|
||||
} else {
|
||||
qWarning() << url << ':' << m.line << ':' << m.column
|
||||
qWarning() << url << ':' << m.loc.startLine << ':' << m.loc.startColumn
|
||||
<< ": warning: " << m.message;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ void RuntimeCodegen::generateFromFunctionExpression(const QString &fileName,
|
|||
_module->rootContext = _module->functions.at(index);
|
||||
}
|
||||
|
||||
void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QString &detail)
|
||||
void RuntimeCodegen::throwSyntaxError(const SourceLocation &loc, const QString &detail)
|
||||
{
|
||||
if (hasError())
|
||||
return;
|
||||
|
@ -76,7 +76,7 @@ void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QStr
|
|||
engine->throwSyntaxError(detail, _module->fileName, loc.startLine, loc.startColumn);
|
||||
}
|
||||
|
||||
void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const QString &detail)
|
||||
void RuntimeCodegen::throwReferenceError(const SourceLocation &loc, const QString &detail)
|
||||
{
|
||||
if (hasError())
|
||||
return;
|
||||
|
|
|
@ -69,8 +69,8 @@ public:
|
|||
QQmlJS::AST::FunctionExpression *ast,
|
||||
Compiler::Module *module);
|
||||
|
||||
void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail) override;
|
||||
void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail) override;
|
||||
void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail) override;
|
||||
void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail) override;
|
||||
|
||||
private:
|
||||
ExecutionEngine *engine;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include <private/qqmljsparser_p.h>
|
||||
#include <private/qqmljsast_p.h>
|
||||
#include <private/qqmlengine_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
#include <private/qv4profiling_p.h>
|
||||
#include <qv4runtimecodegen_p.h>
|
||||
|
||||
|
@ -109,10 +110,10 @@ void Script::parse()
|
|||
const auto diagnosticMessages = parser.diagnosticMessages();
|
||||
for (const DiagnosticMessage &m : diagnosticMessages) {
|
||||
if (m.isError()) {
|
||||
valueScope.engine->throwSyntaxError(m.message, sourceFile, m.line, m.column);
|
||||
valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);
|
||||
return;
|
||||
} else {
|
||||
qWarning() << sourceFile << ':' << m.line << ':' << m.column
|
||||
qWarning() << sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn
|
||||
<< ": warning: " << m.message;
|
||||
}
|
||||
}
|
||||
|
@ -209,8 +210,8 @@ QV4::CompiledData::CompilationUnit Script::precompile(
|
|||
const auto v4Error = cg.error();
|
||||
QQmlError error;
|
||||
error.setUrl(cg.url());
|
||||
error.setLine(v4Error.line);
|
||||
error.setColumn(v4Error.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(v4Error.loc.startLine));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(v4Error.loc.startColumn));
|
||||
error.setDescription(v4Error.message);
|
||||
reportedErrors->append(error);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ HEADERS += \
|
|||
$$PWD/qqmljslexer_p.h \
|
||||
$$PWD/qqmljsglobal_p.h \
|
||||
$$PWD/qqmljskeywords_p.h \
|
||||
$$PWD/qqmljsengine_p.h \
|
||||
$$PWD/qqmljssourcelocation_p.h
|
||||
$$PWD/qqmljsengine_p.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/qqmljsast.cpp \
|
||||
|
|
|
@ -390,10 +390,10 @@ public:
|
|||
{ return diagnosticMessage().message; }
|
||||
|
||||
inline int errorLineNumber() const
|
||||
{ return diagnosticMessage().line; }
|
||||
{ return diagnosticMessage().loc.startLine; }
|
||||
|
||||
inline int errorColumnNumber() const
|
||||
{ return diagnosticMessage().column; }
|
||||
{ return diagnosticMessage().loc.startColumn; }
|
||||
|
||||
protected:
|
||||
bool parse(int startToken);
|
||||
|
@ -409,7 +409,7 @@ protected:
|
|||
inline QStringRef &rawStringRef(int index)
|
||||
{ return rawString_stack [tos + index - 1]; }
|
||||
|
||||
inline AST::SourceLocation &loc(int index)
|
||||
inline SourceLocation &loc(int index)
|
||||
{ return location_stack [tos + index - 1]; }
|
||||
|
||||
AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
|
||||
|
@ -417,21 +417,20 @@ protected:
|
|||
void pushToken(int token);
|
||||
int lookaheadToken(Lexer *lexer);
|
||||
|
||||
static DiagnosticMessage compileError(const AST::SourceLocation &location,
|
||||
static DiagnosticMessage compileError(const SourceLocation &location,
|
||||
const QString &message, QtMsgType kind = QtCriticalMsg)
|
||||
{
|
||||
DiagnosticMessage error;
|
||||
error.line = location.startLine;
|
||||
error.column = location.startColumn;
|
||||
error.loc = location;
|
||||
error.message = message;
|
||||
error.type = kind;
|
||||
return error;
|
||||
}
|
||||
|
||||
void syntaxError(const AST::SourceLocation &location, const char *message) {
|
||||
void syntaxError(const SourceLocation &location, const char *message) {
|
||||
diagnostic_messages.append(compileError(location, QLatin1String(message)));
|
||||
}
|
||||
void syntaxError(const AST::SourceLocation &location, const QString &message) {
|
||||
void syntaxError(const SourceLocation &location, const QString &message) {
|
||||
diagnostic_messages.append(compileError(location, message));
|
||||
}
|
||||
|
||||
|
@ -444,7 +443,7 @@ protected:
|
|||
int stack_size = 0;
|
||||
Value *sym_stack = nullptr;
|
||||
int *state_stack = nullptr;
|
||||
AST::SourceLocation *location_stack = nullptr;
|
||||
SourceLocation *location_stack = nullptr;
|
||||
QVector<QStringRef> string_stack;
|
||||
QVector<QStringRef> rawString_stack;
|
||||
|
||||
|
@ -456,7 +455,7 @@ protected:
|
|||
struct SavedToken {
|
||||
int token;
|
||||
double dval;
|
||||
AST::SourceLocation loc;
|
||||
SourceLocation loc;
|
||||
QStringRef spell;
|
||||
QStringRef raw;
|
||||
};
|
||||
|
@ -465,8 +464,8 @@ protected:
|
|||
double yylval = 0.;
|
||||
QStringRef yytokenspell;
|
||||
QStringRef yytokenraw;
|
||||
AST::SourceLocation yylloc;
|
||||
AST::SourceLocation yyprevlloc;
|
||||
SourceLocation yylloc;
|
||||
SourceLocation yyprevlloc;
|
||||
|
||||
SavedToken token_buffer[TOKEN_BUFFER_SIZE];
|
||||
SavedToken *first_token = nullptr;
|
||||
|
@ -479,7 +478,7 @@ protected:
|
|||
CE_ParenthesizedExpression,
|
||||
CE_FormalParameterList
|
||||
};
|
||||
AST::SourceLocation coverExpressionErrorLocation;
|
||||
SourceLocation coverExpressionErrorLocation;
|
||||
CoverExpressionType coverExpressionType = CE_Invalid;
|
||||
|
||||
QList<DiagnosticMessage> diagnostic_messages;
|
||||
|
@ -524,7 +523,7 @@ void Parser::reallocateStack()
|
|||
|
||||
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
|
||||
location_stack = reinterpret_cast<SourceLocation*> (realloc(location_stack, stack_size * sizeof(SourceLocation)));
|
||||
string_stack.resize(stack_size);
|
||||
rawString_stack.resize(stack_size);
|
||||
}
|
||||
|
@ -544,9 +543,9 @@ Parser::~Parser()
|
|||
}
|
||||
}
|
||||
|
||||
static inline AST::SourceLocation location(Lexer *lexer)
|
||||
static inline SourceLocation location(Lexer *lexer)
|
||||
{
|
||||
AST::SourceLocation loc;
|
||||
SourceLocation loc;
|
||||
loc.offset = lexer->tokenOffset();
|
||||
loc.length = lexer->tokenLength();
|
||||
loc.startLine = lexer->tokenStartLine();
|
||||
|
@ -557,7 +556,7 @@ static inline AST::SourceLocation location(Lexer *lexer)
|
|||
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
|
||||
{
|
||||
QVarLengthArray<QStringRef, 4> nameIds;
|
||||
QVarLengthArray<AST::SourceLocation, 4> locations;
|
||||
QVarLengthArray<SourceLocation, 4> locations;
|
||||
|
||||
AST::ExpressionNode *it = expr;
|
||||
while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
|
||||
|
@ -2842,7 +2841,7 @@ AssignmentExpression_In: LeftHandSideExpression T_EQ AssignmentExpression_In;
|
|||
case $rule_number: {
|
||||
// need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
|
||||
if (AST::Pattern *p = sym(1).Expression->patternCast()) {
|
||||
AST::SourceLocation errorLoc;
|
||||
SourceLocation errorLoc;
|
||||
QString errorMsg;
|
||||
if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) {
|
||||
syntaxError(errorLoc, errorMsg);
|
||||
|
@ -3508,7 +3507,7 @@ IterationStatement: T_FOR T_LPAREN LeftHandSideExpression InOrOf Expression_In T
|
|||
case $rule_number: {
|
||||
// need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
|
||||
if (AST::Pattern *p = sym(3).Expression->patternCast()) {
|
||||
AST::SourceLocation errorLoc;
|
||||
SourceLocation errorLoc;
|
||||
QString errorMsg;
|
||||
if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) {
|
||||
syntaxError(errorLoc, errorMsg);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define QQMLJSAST_FWD_P_H
|
||||
|
||||
#include "qqmljsglobal_p.h"
|
||||
#include "qqmljssourcelocation_p.h"
|
||||
#include <private/qqmljssourcelocation_p.h>
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ void Engine::setCode(const QString &code)
|
|||
{ _code = code; }
|
||||
|
||||
void Engine::addComment(int pos, int len, int line, int col)
|
||||
{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); }
|
||||
{ if (len > 0) _comments.append(QQmlJS::SourceLocation(pos, len, line, col)); }
|
||||
|
||||
QList<QQmlJS::AST::SourceLocation> Engine::comments() const
|
||||
QList<QQmlJS::SourceLocation> Engine::comments() const
|
||||
{ return _comments; }
|
||||
|
||||
Lexer *Engine::lexer() const
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
//
|
||||
|
||||
#include "qqmljsglobal_p.h"
|
||||
#include "qqmljssourcelocation_p.h"
|
||||
#include <private/qqmljssourcelocation_p.h>
|
||||
|
||||
#include <private/qqmljsmemorypool_p.h>
|
||||
|
||||
|
@ -97,7 +97,7 @@ class QML_PARSER_EXPORT Engine
|
|||
Lexer *_lexer;
|
||||
Directives *_directives;
|
||||
MemoryPool _pool;
|
||||
QList<AST::SourceLocation> _comments;
|
||||
QList<SourceLocation> _comments;
|
||||
QString _extraCode;
|
||||
QString _code;
|
||||
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
const QString &code() const { return _code; }
|
||||
|
||||
void addComment(int pos, int len, int line, int col);
|
||||
QList<AST::SourceLocation> comments() const;
|
||||
QList<SourceLocation> comments() const;
|
||||
|
||||
Lexer *lexer() const;
|
||||
void setLexer(Lexer *lexer);
|
||||
|
|
|
@ -1480,8 +1480,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
|
|||
{
|
||||
auto setError = [error, this](QString message) {
|
||||
error->message = std::move(message);
|
||||
error->line = tokenStartLine();
|
||||
error->column = tokenStartColumn();
|
||||
error->loc.startLine = tokenStartLine();
|
||||
error->loc.startColumn = tokenStartColumn();
|
||||
};
|
||||
|
||||
QScopedValueRollback<bool> directivesGuard(_handlingDirectives, true);
|
||||
|
@ -1596,8 +1596,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
|
|||
else
|
||||
setError(QCoreApplication::translate("QQmlParser", "Module import requires a qualifier"));
|
||||
if (tokenStartLine() != lineNumber) {
|
||||
error->line = lineNumber;
|
||||
error->line = column;
|
||||
error->loc.startLine = lineNumber;
|
||||
error->loc.startColumn = column;
|
||||
}
|
||||
return false; // expected `as'
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "qqmlincubator.h"
|
||||
#include "qqmlincubator_p.h"
|
||||
#include <private/qqmljavascriptexpression_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
|
||||
#include <private/qv4functionobject_p.h>
|
||||
#include <private/qv4script_p.h>
|
||||
|
@ -1424,8 +1425,8 @@ QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(const RequiredP
|
|||
}
|
||||
error.setDescription(description);
|
||||
error.setUrl(unsetRequiredProperty.fileUrl);
|
||||
error.setLine(unsetRequiredProperty.location.line);
|
||||
error.setColumn(unsetRequiredProperty.location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(unsetRequiredProperty.location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(unsetRequiredProperty.location.column));
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "qqmlcustomparser_p.h"
|
||||
|
||||
#include <private/qv4compileddata_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
|
@ -100,10 +101,10 @@ void QQmlCustomParser::clearErrors()
|
|||
*/
|
||||
void QQmlCustomParser::error(const QV4::CompiledData::Location &location, const QString &description)
|
||||
{
|
||||
QQmlJS::DiagnosticMessage error;
|
||||
error.line = location.line;
|
||||
error.column = location.column;
|
||||
error.message = description;
|
||||
QQmlError error;
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
|
||||
error.setDescription(description);
|
||||
|
||||
exceptions << error;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
virtual void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0;
|
||||
virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0;
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> errors() const { return exceptions; }
|
||||
QVector<QQmlError> errors() const { return exceptions; }
|
||||
|
||||
protected:
|
||||
void error(const QV4::CompiledData::Binding *binding, const QString& description)
|
||||
|
@ -97,7 +97,7 @@ protected:
|
|||
const QMetaObject *resolveType(const QString&) const;
|
||||
|
||||
private:
|
||||
QVector<QQmlJS::DiagnosticMessage> exceptions;
|
||||
QVector<QQmlError> exceptions;
|
||||
QQmlEnginePrivate *engine;
|
||||
const QQmlPropertyValidator *validator;
|
||||
Flags m_flags;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <private/qqmlprofiler_p.h>
|
||||
#include <private/qqmltypeloader_p.h>
|
||||
#include <private/qqmltypeloaderthread_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
|
||||
#include <QtQml/qqmlengine.h>
|
||||
|
||||
|
@ -306,22 +307,19 @@ void QQmlDataBlob::setError(const QList<QQmlError> &errors)
|
|||
void QQmlDataBlob::setError(const QQmlJS::DiagnosticMessage &error)
|
||||
{
|
||||
QQmlError e;
|
||||
e.setColumn(error.column);
|
||||
e.setLine(error.line);
|
||||
e.setColumn(qmlConvertSourceCoordinate<quint32, int>(error.loc.startColumn));
|
||||
e.setLine(qmlConvertSourceCoordinate<quint32, int>(error.loc.startLine));
|
||||
e.setDescription(error.message);
|
||||
e.setUrl(url());
|
||||
setError(e);
|
||||
}
|
||||
|
||||
void QQmlDataBlob::setError(const QVector<QQmlJS::DiagnosticMessage> &errors)
|
||||
void QQmlDataBlob::setError(const QVector<QQmlError> &errors)
|
||||
{
|
||||
QList<QQmlError> finalErrors;
|
||||
finalErrors.reserve(errors.count());
|
||||
for (const auto &error : errors) {
|
||||
QQmlError e;
|
||||
e.setColumn(error.column);
|
||||
e.setLine(error.line);
|
||||
e.setDescription(error.message);
|
||||
QQmlError e = error;
|
||||
e.setUrl(url());
|
||||
finalErrors << e;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ protected:
|
|||
void setError(const QQmlError &);
|
||||
void setError(const QList<QQmlError> &errors);
|
||||
void setError(const QQmlJS::DiagnosticMessage &error);
|
||||
void setError(const QVector<QQmlJS::DiagnosticMessage> &errors);
|
||||
void setError(const QVector<QQmlError> &errors);
|
||||
void setError(const QString &description);
|
||||
void addDependency(QQmlDataBlob *);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "qqmlnotifier_p.h"
|
||||
#include "qqmlincubator.h"
|
||||
#include "qqmlabstracturlinterceptor.h"
|
||||
#include "qqmlsourcecoordinate_p.h"
|
||||
#include <private/qqmldirparser_p.h>
|
||||
#include <private/qqmlboundsignal_p.h>
|
||||
#include <private/qqmljsdiagnosticmessage_p.h>
|
||||
|
@ -2124,15 +2125,15 @@ QList<QQmlError> QQmlEnginePrivate::qmlErrorFromDiagnostics(
|
|||
QList<QQmlError> errors;
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
|
||||
if (m.isWarning()) {
|
||||
qWarning("%s:%d : %s", qPrintable(fileName), m.line, qPrintable(m.message));
|
||||
qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message));
|
||||
continue;
|
||||
}
|
||||
|
||||
QQmlError error;
|
||||
error.setUrl(QUrl(fileName));
|
||||
error.setDescription(m.message);
|
||||
error.setLine(m.line);
|
||||
error.setColumn(m.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(m.loc.startLine));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(m.loc.startColumn));
|
||||
errors << error;
|
||||
}
|
||||
return errors;
|
||||
|
|
|
@ -77,12 +77,15 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
\sa QQuickView::errors(), QQmlComponent::errors()
|
||||
*/
|
||||
class QQmlErrorPrivate : public QQmlJS::DiagnosticMessage
|
||||
class QQmlErrorPrivate
|
||||
{
|
||||
public:
|
||||
QQmlErrorPrivate() { type = QtWarningMsg; }
|
||||
QUrl url;
|
||||
QPointer<QObject> object;
|
||||
QString message;
|
||||
QtMsgType type = QtWarningMsg;
|
||||
int line = -1;
|
||||
int column = -1;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -185,7 +188,7 @@ void QQmlError::setDescription(const QString &description)
|
|||
int QQmlError::line() const
|
||||
{
|
||||
if (d)
|
||||
return qmlConvertSourceCoordinate<quint32, int>(d->line);
|
||||
return d->line;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -196,7 +199,7 @@ void QQmlError::setLine(int line)
|
|||
{
|
||||
if (!d)
|
||||
d = new QQmlErrorPrivate;
|
||||
d->line = qmlConvertSourceCoordinate<int, quint32>(line);
|
||||
d->line = line;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -205,7 +208,7 @@ void QQmlError::setLine(int line)
|
|||
int QQmlError::column() const
|
||||
{
|
||||
if (d)
|
||||
return qmlConvertSourceCoordinate<quint32, int>(d->column);
|
||||
return d->column;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -216,7 +219,7 @@ void QQmlError::setColumn(int column)
|
|||
{
|
||||
if (!d)
|
||||
d = new QQmlErrorPrivate;
|
||||
d->column = qmlConvertSourceCoordinate<int, quint32>(column);
|
||||
d->column = column;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "qqmlcontext_p.h"
|
||||
#include "qqmlmetatype_p.h"
|
||||
#include "qqmlengine_p.h"
|
||||
#include "qqmlsourcecoordinate_p.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
@ -218,8 +219,8 @@ QQmlInfo::~QQmlInfo()
|
|||
QQmlData *ddata = QQmlData::get(object, false);
|
||||
if (ddata && ddata->outerContext) {
|
||||
error.setUrl(ddata->outerContext->url());
|
||||
error.setLine(ddata->lineNumber);
|
||||
error.setColumn(ddata->columnNumber);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint16, int>(ddata->lineNumber));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint16, int>(ddata->columnNumber));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,14 +78,14 @@ struct FakeExpression : public QQmlJS::AST::NullExpression
|
|||
: location(start, length)
|
||||
{}
|
||||
|
||||
virtual QQmlJS::AST::SourceLocation firstSourceLocation() const
|
||||
virtual QQmlJS::SourceLocation firstSourceLocation() const
|
||||
{ return location; }
|
||||
|
||||
virtual QQmlJS::AST::SourceLocation lastSourceLocation() const
|
||||
virtual QQmlJS::SourceLocation lastSourceLocation() const
|
||||
{ return location; }
|
||||
|
||||
private:
|
||||
QQmlJS::AST::SourceLocation location;
|
||||
QQmlJS::SourceLocation location;
|
||||
};
|
||||
|
||||
QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *serializedObject)
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <private/qqmlglobal_p.h>
|
||||
#include <private/qv4qobjectwrapper_p.h>
|
||||
#include <private/qqmlbuiltinfunctions_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -72,8 +73,8 @@ bool QQmlDelayedError::addError(QQmlEnginePrivate *e)
|
|||
void QQmlDelayedError::setErrorLocation(const QQmlSourceLocation &sourceLocation)
|
||||
{
|
||||
m_error.setUrl(QUrl(sourceLocation.sourceFile));
|
||||
m_error.setLine(sourceLocation.line);
|
||||
m_error.setColumn(sourceLocation.column);
|
||||
m_error.setLine(qmlConvertSourceCoordinate<quint16, int>(sourceLocation.line));
|
||||
m_error.setColumn(qmlConvertSourceCoordinate<quint16, int>(sourceLocation.column));
|
||||
}
|
||||
|
||||
void QQmlDelayedError::setErrorDescription(const QString &description)
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <private/qqmldebugconnector_p.h>
|
||||
#include <private/qqmldebugserviceinterfaces_p.h>
|
||||
#include <private/qqmlscriptdata_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
#include <private/qjsvalue_p.h>
|
||||
#include <private/qv4generatorobject_p.h>
|
||||
|
||||
|
@ -1135,8 +1136,8 @@ void QQmlObjectCreator::recordError(const QV4::CompiledData::Location &location,
|
|||
{
|
||||
QQmlError error;
|
||||
error.setUrl(compilationUnit->url());
|
||||
error.setLine(location.line);
|
||||
error.setColumn(location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
|
||||
error.setDescription(description);
|
||||
errors << error;
|
||||
}
|
||||
|
|
|
@ -56,19 +56,20 @@
|
|||
#include <private/qqmlpropertyresolver_p.h>
|
||||
#include <private/qqmltypedata_p.h>
|
||||
#include <private/inlinecomponentutils_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
|
||||
#include <QScopedValueRollback>
|
||||
#include <vector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
inline QQmlJS::DiagnosticMessage qQmlCompileError(const QV4::CompiledData::Location &location,
|
||||
inline QQmlError qQmlCompileError(const QV4::CompiledData::Location &location,
|
||||
const QString &description)
|
||||
{
|
||||
QQmlJS::DiagnosticMessage error;
|
||||
error.line = location.line;
|
||||
error.column = location.column;
|
||||
error.message = description;
|
||||
QQmlError error;
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
|
||||
error.setDescription(description);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -117,16 +118,16 @@ public:
|
|||
const ObjectContainer *objectContainer, const QQmlImports *imports,
|
||||
const QByteArray &typeClassName);
|
||||
|
||||
QQmlJS::DiagnosticMessage buildMetaObjects();
|
||||
QQmlError buildMetaObjects();
|
||||
|
||||
enum class VMEMetaObjectIsRequired {
|
||||
Maybe,
|
||||
Always
|
||||
};
|
||||
protected:
|
||||
QQmlJS::DiagnosticMessage buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired);
|
||||
QQmlRefPointer<QQmlPropertyCache> propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlJS::DiagnosticMessage *error) const;
|
||||
QQmlJS::DiagnosticMessage createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache);
|
||||
QQmlError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired);
|
||||
QQmlRefPointer<QQmlPropertyCache> propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const;
|
||||
QQmlError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache);
|
||||
|
||||
int metaTypeForParameter(const QV4::CompiledData::ParameterType ¶m, QString *customTypeName = nullptr);
|
||||
|
||||
|
@ -159,7 +160,7 @@ inline QQmlPropertyCacheCreator<ObjectContainer>::QQmlPropertyCacheCreator(QQmlP
|
|||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjects()
|
||||
inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjects()
|
||||
{
|
||||
using namespace icutils;
|
||||
QQmlBindingInstantiationContext context;
|
||||
|
@ -186,8 +187,8 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
auto nodesSorted = topoSort(nodes, adjacencyList, hasCycle);
|
||||
|
||||
if (hasCycle) {
|
||||
QQmlJS::DiagnosticMessage diag;
|
||||
diag.message = QLatin1String("Inline components form a cycle!");
|
||||
QQmlError diag;
|
||||
diag.setDescription(QLatin1String("Inline components form a cycle!"));
|
||||
return diag;
|
||||
}
|
||||
|
||||
|
@ -201,7 +202,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
QByteArray icTypeName { objectContainer->stringAt(ic.nameIndex).toUtf8() };
|
||||
QScopedValueRollback<QByteArray> nameChange {typeClassName, icTypeName};
|
||||
QScopedValueRollback<unsigned int> rootChange {currentRoot, ic.objectIndex};
|
||||
QQmlJS::DiagnosticMessage diag = buildMetaObjectRecursively(ic.objectIndex, context, VMEMetaObjectIsRequired::Always);
|
||||
QQmlError diag = buildMetaObjectRecursively(ic.objectIndex, context, VMEMetaObjectIsRequired::Always);
|
||||
if (diag.isValid()) {
|
||||
return diag;
|
||||
}
|
||||
|
@ -213,7 +214,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired)
|
||||
inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired)
|
||||
{
|
||||
auto isAddressable = [](const QUrl &url) {
|
||||
const QString fileName = url.fileName();
|
||||
|
@ -242,7 +243,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
auto *typeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex);
|
||||
Q_ASSERT(typeRef);
|
||||
QQmlRefPointer<QQmlPropertyCache> baseTypeCache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
|
||||
QQmlJS::DiagnosticMessage error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache);
|
||||
QQmlError error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache);
|
||||
if (error.isValid())
|
||||
return error;
|
||||
}
|
||||
|
@ -257,7 +258,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
|
||||
QQmlRefPointer<QQmlPropertyCache> baseTypeCache;
|
||||
{
|
||||
QQmlJS::DiagnosticMessage error;
|
||||
QQmlError error;
|
||||
baseTypeCache = propertyCacheForObject(obj, context, &error);
|
||||
if (error.isValid())
|
||||
return error;
|
||||
|
@ -265,7 +266,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
|
||||
if (baseTypeCache) {
|
||||
if (needVMEMetaObject) {
|
||||
QQmlJS::DiagnosticMessage error = createMetaObject(objectIndex, obj, baseTypeCache);
|
||||
QQmlError error = createMetaObject(objectIndex, obj, baseTypeCache);
|
||||
if (error.isValid())
|
||||
return error;
|
||||
} else {
|
||||
|
@ -287,18 +288,18 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
|
|||
if (!context.resolveInstantiatingProperty())
|
||||
pendingGroupPropertyBindings->append(context);
|
||||
|
||||
QQmlJS::DiagnosticMessage error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe);
|
||||
QQmlError error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe);
|
||||
if (error.isValid())
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
QQmlJS::DiagnosticMessage noError;
|
||||
QQmlError noError;
|
||||
return noError;
|
||||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlJS::DiagnosticMessage *error) const
|
||||
inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const
|
||||
{
|
||||
if (context.instantiatingProperty) {
|
||||
return context.instantiatingPropertyCache(enginePrivate);
|
||||
|
@ -344,7 +345,7 @@ inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContaine
|
|||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache)
|
||||
inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache)
|
||||
{
|
||||
QQmlRefPointer<QQmlPropertyCache> cache;
|
||||
cache.adopt(baseTypeCache->copyAndReserve(obj->propertyCount() + obj->aliasCount(),
|
||||
|
@ -622,7 +623,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::crea
|
|||
effectiveSignalIndex++;
|
||||
}
|
||||
|
||||
QQmlJS::DiagnosticMessage noError;
|
||||
QQmlError noError;
|
||||
return noError;
|
||||
}
|
||||
|
||||
|
@ -670,11 +671,11 @@ public:
|
|||
|
||||
void appendAliasPropertiesToMetaObjects(QQmlEnginePrivate *enginePriv);
|
||||
|
||||
QQmlJS::DiagnosticMessage appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv);
|
||||
QQmlError appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv);
|
||||
|
||||
private:
|
||||
void appendAliasPropertiesInMetaObjectsWithinComponent(const CompiledObject &component, int firstObjectIndex, QQmlEnginePrivate *enginePriv);
|
||||
QQmlJS::DiagnosticMessage propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *rev, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv);
|
||||
QQmlError propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *rev, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv);
|
||||
|
||||
void collectObjectsWithAliasesRecursively(int objectIndex, QVector<int> *objectsWithAliases) const;
|
||||
|
||||
|
@ -785,7 +786,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::collectObjectsWithAl
|
|||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *minorVersion,
|
||||
inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *minorVersion,
|
||||
QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv)
|
||||
{
|
||||
*type = 0;
|
||||
|
@ -896,16 +897,16 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
|
|||
|
||||
propertyFlags->setIsWritable(!(alias.flags & QV4::CompiledData::Alias::IsReadOnly) && writable);
|
||||
propertyFlags->setIsResettable(resettable);
|
||||
return QQmlJS::DiagnosticMessage();
|
||||
return QQmlError();
|
||||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache(
|
||||
inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache(
|
||||
const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv)
|
||||
{
|
||||
const CompiledObject &object = *objectContainer->objectAt(objectIndex);
|
||||
if (!object.aliasCount())
|
||||
return QQmlJS::DiagnosticMessage();
|
||||
return QQmlError();
|
||||
|
||||
QQmlPropertyCache *propertyCache = propertyCaches->at(objectIndex);
|
||||
Q_ASSERT(propertyCache);
|
||||
|
@ -922,7 +923,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
|
|||
int type = 0;
|
||||
int minorVersion = 0;
|
||||
QQmlPropertyData::Flags propertyFlags;
|
||||
QQmlJS::DiagnosticMessage error = propertyDataForAlias(component, *alias, &type, &minorVersion, &propertyFlags, enginePriv);
|
||||
QQmlError error = propertyDataForAlias(component, *alias, &type, &minorVersion, &propertyFlags, enginePriv);
|
||||
if (error.isValid())
|
||||
return error;
|
||||
|
||||
|
@ -935,7 +936,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
|
|||
type, minorVersion, effectiveSignalIndex++);
|
||||
}
|
||||
|
||||
return QQmlJS::DiagnosticMessage();
|
||||
return QQmlError();
|
||||
}
|
||||
|
||||
template <typename ObjectContainer>
|
||||
|
|
|
@ -73,7 +73,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, c
|
|||
bindingPropertyDataPerObject->resize(compilationUnit->objectCount());
|
||||
}
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validate()
|
||||
QVector<QQmlError> QQmlPropertyValidator::validate()
|
||||
{
|
||||
return validateObject(/*root object*/0, /*instantiatingBinding*/nullptr);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ struct BindingFinder
|
|||
}
|
||||
};
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
|
||||
QVector<QQmlError> QQmlPropertyValidator::validateObject(
|
||||
int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, bool populatingValueTypeGroupProperty) const
|
||||
{
|
||||
const QV4::CompiledData::Object *obj = compilationUnit->objectAt(objectIndex);
|
||||
|
@ -113,7 +113,7 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
|
|||
|
||||
QQmlPropertyCache *propertyCache = propertyCaches.at(objectIndex);
|
||||
if (!propertyCache)
|
||||
return QVector<QQmlJS::DiagnosticMessage>();
|
||||
return QVector<QQmlError>();
|
||||
|
||||
QQmlCustomParser *customParser = nullptr;
|
||||
if (auto typeRef = resolvedType(obj->inheritedTypeNameIndex)) {
|
||||
|
@ -223,7 +223,7 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
|
|||
= pd
|
||||
&& QQmlValueTypeFactory::metaObjectForMetaType(pd->propType())
|
||||
&& !(binding->flags & QV4::CompiledData::Binding::IsOnAssignment);
|
||||
const QVector<QQmlJS::DiagnosticMessage> subObjectValidatorErrors
|
||||
const QVector<QQmlError> subObjectValidatorErrors
|
||||
= validateObject(binding->value.objectIndex, binding,
|
||||
populatingValueTypeGroupProperty);
|
||||
if (!subObjectValidatorErrors.isEmpty())
|
||||
|
@ -280,11 +280,11 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
|
|||
}
|
||||
|
||||
if (binding->type < QV4::CompiledData::Binding::Type_Script) {
|
||||
QQmlJS::DiagnosticMessage bindingError = validateLiteralBinding(propertyCache, pd, binding);
|
||||
QQmlError bindingError = validateLiteralBinding(propertyCache, pd, binding);
|
||||
if (bindingError.isValid())
|
||||
return recordError(bindingError);
|
||||
} else if (binding->type == QV4::CompiledData::Binding::Type_Object) {
|
||||
QQmlJS::DiagnosticMessage bindingError = validateObjectBinding(pd, name, binding);
|
||||
QQmlError bindingError = validateObjectBinding(pd, name, binding);
|
||||
if (bindingError.isValid())
|
||||
return recordError(bindingError);
|
||||
} else if (binding->isGroupProperty()) {
|
||||
|
@ -346,24 +346,24 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
|
|||
customParser->validator = nullptr;
|
||||
customParser->engine = nullptr;
|
||||
customParser->imports = (QQmlImports*)nullptr;
|
||||
QVector<QQmlJS::DiagnosticMessage> parserErrors = customParser->errors();
|
||||
QVector<QQmlError> parserErrors = customParser->errors();
|
||||
if (!parserErrors.isEmpty())
|
||||
return parserErrors;
|
||||
}
|
||||
|
||||
(*bindingPropertyDataPerObject)[objectIndex] = collectedBindingPropertyData;
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> noError;
|
||||
QVector<QQmlError> noError;
|
||||
return noError;
|
||||
}
|
||||
|
||||
QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const
|
||||
QQmlError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const
|
||||
{
|
||||
if (property->isQList()) {
|
||||
return qQmlCompileError(binding->valueLocation, tr("Cannot assign primitives to lists"));
|
||||
}
|
||||
|
||||
QQmlJS::DiagnosticMessage noError;
|
||||
QQmlError noError;
|
||||
|
||||
if (property->isEnum()) {
|
||||
if (binding->flags & QV4::CompiledData::Binding::IsResolvedEnum)
|
||||
|
@ -387,8 +387,8 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
|
|||
if (binding->type == QV4::CompiledData::Binding::Type_Null) {
|
||||
QQmlError warning;
|
||||
warning.setUrl(compilationUnit->url());
|
||||
warning.setLine(binding->valueLocation.line);
|
||||
warning.setColumn(binding->valueLocation.column);
|
||||
warning.setLine(qmlConvertSourceCoordinate<quint32, int>(binding->valueLocation.line));
|
||||
warning.setColumn(qmlConvertSourceCoordinate<quint32, int>(binding->valueLocation.column));
|
||||
warning.setDescription(error + tr(" - Assigning null to incompatible properties in QML "
|
||||
"is deprecated. This will become a compile error in "
|
||||
"future versions of Qt."));
|
||||
|
@ -659,23 +659,23 @@ bool QQmlPropertyValidator::canCoerce(int to, QQmlPropertyCache *fromMo) const
|
|||
return false;
|
||||
}
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::recordError(const QV4::CompiledData::Location &location, const QString &description) const
|
||||
QVector<QQmlError> QQmlPropertyValidator::recordError(const QV4::CompiledData::Location &location, const QString &description) const
|
||||
{
|
||||
QVector<QQmlJS::DiagnosticMessage> errors;
|
||||
QVector<QQmlError> errors;
|
||||
errors.append(qQmlCompileError(location, description));
|
||||
return errors;
|
||||
}
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::recordError(const QQmlJS::DiagnosticMessage &error) const
|
||||
QVector<QQmlError> QQmlPropertyValidator::recordError(const QQmlError &error) const
|
||||
{
|
||||
QVector<QQmlJS::DiagnosticMessage> errors;
|
||||
QVector<QQmlError> errors;
|
||||
errors.append(error);
|
||||
return errors;
|
||||
}
|
||||
|
||||
QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const
|
||||
QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const
|
||||
{
|
||||
QQmlJS::DiagnosticMessage noError;
|
||||
QQmlError noError;
|
||||
|
||||
if (binding->flags & QV4::CompiledData::Binding::IsOnAssignment) {
|
||||
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Object);
|
||||
|
|
|
@ -66,25 +66,24 @@ class QQmlPropertyValidator
|
|||
public:
|
||||
QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit);
|
||||
|
||||
QVector<QQmlJS::DiagnosticMessage> validate();
|
||||
QVector<QQmlError> validate();
|
||||
|
||||
private:
|
||||
QVector<QQmlJS::DiagnosticMessage> validateObject(
|
||||
QVector<QQmlError> validateObject(
|
||||
int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding,
|
||||
bool populatingValueTypeGroupProperty = false) const;
|
||||
QQmlJS::DiagnosticMessage validateLiteralBinding(
|
||||
QQmlError validateLiteralBinding(
|
||||
QQmlPropertyCache *propertyCache, QQmlPropertyData *property,
|
||||
const QV4::CompiledData::Binding *binding) const;
|
||||
QQmlJS::DiagnosticMessage validateObjectBinding(
|
||||
QQmlError validateObjectBinding(
|
||||
QQmlPropertyData *property, const QString &propertyName,
|
||||
const QV4::CompiledData::Binding *binding) const;
|
||||
|
||||
bool canCoerce(int to, QQmlPropertyCache *fromMo) const;
|
||||
|
||||
Q_REQUIRED_RESULT QVector<QQmlJS::DiagnosticMessage> recordError(
|
||||
Q_REQUIRED_RESULT QVector<QQmlError> recordError(
|
||||
const QV4::CompiledData::Location &location, const QString &description) const;
|
||||
Q_REQUIRED_RESULT QVector<QQmlJS::DiagnosticMessage> recordError(
|
||||
const QQmlJS::DiagnosticMessage &error) const;
|
||||
Q_REQUIRED_RESULT QVector<QQmlError> recordError(const QQmlError &error) const;
|
||||
QString stringAt(int index) const { return compilationUnit->stringAt(index); }
|
||||
QV4::ResolvedTypeReference *resolvedType(int id) const
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <private/qqmlirbuilder_p.h>
|
||||
#include <private/qqmlscriptblob_p.h>
|
||||
#include <private/qqmlscriptdata_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
#include <private/qv4runtimecodegen_p.h>
|
||||
#include <private/qv4script_p.h>
|
||||
|
||||
|
@ -167,8 +168,8 @@ void QQmlScriptBlob::done()
|
|||
QList<QQmlError> errors = script.script->errors();
|
||||
QQmlError error;
|
||||
error.setUrl(url());
|
||||
error.setLine(script.location.line);
|
||||
error.setColumn(script.location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(script.location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(script.location.column));
|
||||
error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString()));
|
||||
errors.prepend(error);
|
||||
setError(errors);
|
||||
|
|
|
@ -82,7 +82,7 @@ QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlTypeCompiler::compile()
|
|||
{
|
||||
QQmlPropertyCacheCreator<QQmlTypeCompiler> propertyCacheBuilder(&m_propertyCaches, &pendingGroupPropertyBindings,
|
||||
engine, this, imports(), typeData->typeClassName());
|
||||
QQmlJS::DiagnosticMessage error = propertyCacheBuilder.buildMetaObjects();
|
||||
QQmlError error = propertyCacheBuilder.buildMetaObjects();
|
||||
if (error.isValid()) {
|
||||
recordError(error);
|
||||
return nullptr;
|
||||
|
@ -174,8 +174,8 @@ QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlTypeCompiler::compile()
|
|||
void QQmlTypeCompiler::recordError(const QV4::CompiledData::Location &location, const QString &description)
|
||||
{
|
||||
QQmlError error;
|
||||
error.setLine(location.line);
|
||||
error.setColumn(location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
|
||||
error.setDescription(description);
|
||||
error.setUrl(url());
|
||||
errors << error;
|
||||
|
@ -185,8 +185,15 @@ void QQmlTypeCompiler::recordError(const QQmlJS::DiagnosticMessage &message)
|
|||
{
|
||||
QQmlError error;
|
||||
error.setDescription(message.message);
|
||||
error.setLine(message.line);
|
||||
error.setColumn(message.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(message.loc.startLine));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(message.loc.startColumn));
|
||||
error.setUrl(url());
|
||||
errors << error;
|
||||
}
|
||||
|
||||
void QQmlTypeCompiler::recordError(const QQmlError &e)
|
||||
{
|
||||
QQmlError error = e;
|
||||
error.setUrl(url());
|
||||
errors << error;
|
||||
}
|
||||
|
@ -1016,7 +1023,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
|
|||
|
||||
for (int objectIndex: qAsConst(_objectsWithAliases)) {
|
||||
|
||||
QQmlJS::DiagnosticMessage error;
|
||||
QQmlError error;
|
||||
const auto result = resolveAliasesInObject(objectIndex, &error);
|
||||
|
||||
if (error.isValid()) {
|
||||
|
@ -1025,7 +1032,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
|
|||
}
|
||||
|
||||
if (result == AllAliasesResolved) {
|
||||
QQmlJS::DiagnosticMessage error = aliasCacheCreator.appendAliasesToPropertyCache(*qmlObjects->at(componentIndex), objectIndex, enginePrivate);
|
||||
QQmlError error = aliasCacheCreator.appendAliasesToPropertyCache(*qmlObjects->at(componentIndex), objectIndex, enginePrivate);
|
||||
if (error.isValid()) {
|
||||
recordError(error);
|
||||
return false;
|
||||
|
@ -1056,7 +1063,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
|
|||
|
||||
QQmlComponentAndAliasResolver::AliasResolutionResult
|
||||
QQmlComponentAndAliasResolver::resolveAliasesInObject(int objectIndex,
|
||||
QQmlJS::DiagnosticMessage *error)
|
||||
QQmlError *error)
|
||||
{
|
||||
const QmlIR::Object * const obj = qmlObjects->at(objectIndex);
|
||||
if (!obj->aliasCount())
|
||||
|
|
|
@ -100,7 +100,8 @@ public:
|
|||
|
||||
QList<QQmlError> compilationErrors() const { return errors; }
|
||||
void recordError(const QV4::CompiledData::Location &location, const QString &description);
|
||||
void recordError(const QQmlJS::DiagnosticMessage &error);
|
||||
void recordError(const QQmlJS::DiagnosticMessage &message);
|
||||
void recordError(const QQmlError &e);
|
||||
|
||||
int registerString(const QString &str);
|
||||
int registerConstant(QV4::ReturnedValue v);
|
||||
|
@ -157,7 +158,7 @@ struct QQmlCompilePass
|
|||
protected:
|
||||
void recordError(const QV4::CompiledData::Location &location, const QString &description) const
|
||||
{ compiler->recordError(location, description); }
|
||||
void recordError(const QQmlJS::DiagnosticMessage &error)
|
||||
void recordError(const QQmlError &error)
|
||||
{ compiler->recordError(error); }
|
||||
|
||||
QV4::ResolvedTypeReference *resolvedType(int id) const
|
||||
|
@ -280,7 +281,7 @@ protected:
|
|||
AllAliasesResolved
|
||||
};
|
||||
|
||||
AliasResolutionResult resolveAliasesInObject(int objectIndex, QQmlJS::DiagnosticMessage *error);
|
||||
AliasResolutionResult resolveAliasesInObject(int objectIndex, QQmlError *error);
|
||||
|
||||
QQmlEnginePrivate *enginePrivate;
|
||||
QQmlJS::MemoryPool *pool;
|
||||
|
|
|
@ -203,8 +203,8 @@ bool QQmlTypeData::tryLoadFromDiskCache()
|
|||
Q_ASSERT(errors.size());
|
||||
QQmlError error(errors.takeFirst());
|
||||
error.setUrl(m_importCache.baseUrl());
|
||||
error.setLine(import->location.line);
|
||||
error.setColumn(import->location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
|
||||
errors.prepend(error); // put it back on the list after filling out information.
|
||||
setError(errors);
|
||||
return false;
|
||||
|
@ -244,7 +244,7 @@ void QQmlTypeData::createTypeAndPropertyCaches(
|
|||
QQmlPropertyCacheCreator<QV4::ExecutableCompilationUnit> propertyCacheCreator(
|
||||
&m_compiledData->propertyCaches, &pendingGroupPropertyBindings, engine,
|
||||
m_compiledData.data(), &m_importCache, typeClassName());
|
||||
QQmlJS::DiagnosticMessage error = propertyCacheCreator.buildMetaObjects();
|
||||
QQmlError error = propertyCacheCreator.buildMetaObjects();
|
||||
if (error.isValid()) {
|
||||
setError(error);
|
||||
return;
|
||||
|
@ -325,8 +325,8 @@ void QQmlTypeData::done()
|
|||
QList<QQmlError> errors = script.script->errors();
|
||||
QQmlError error;
|
||||
error.setUrl(url());
|
||||
error.setLine(script.location.line);
|
||||
error.setColumn(script.location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(script.location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(script.location.column));
|
||||
error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString()));
|
||||
errors.prepend(error);
|
||||
setError(errors);
|
||||
|
@ -349,8 +349,8 @@ void QQmlTypeData::done()
|
|||
QList<QQmlError> errors = type.typeData ? type.typeData->errors() : QList<QQmlError>{};
|
||||
QQmlError error;
|
||||
error.setUrl(url());
|
||||
error.setLine(type.location.line);
|
||||
error.setColumn(type.location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
|
||||
error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(typeName.leftRef(lastDot), type.type.pendingResolutionName()));
|
||||
errors.prepend(error);
|
||||
setError(errors);
|
||||
|
@ -365,8 +365,8 @@ void QQmlTypeData::done()
|
|||
QList<QQmlError> errors = type.typeData->errors();
|
||||
QQmlError error;
|
||||
error.setUrl(url());
|
||||
error.setLine(type.location.line);
|
||||
error.setColumn(type.location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
|
||||
error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName));
|
||||
errors.prepend(error);
|
||||
setError(errors);
|
||||
|
@ -384,8 +384,8 @@ void QQmlTypeData::done()
|
|||
QList<QQmlError> errors = type.typeData->errors();
|
||||
QQmlError error;
|
||||
error.setUrl(url());
|
||||
error.setLine(type.location.line);
|
||||
error.setColumn(type.location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
|
||||
error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName));
|
||||
errors.prepend(error);
|
||||
setError(errors);
|
||||
|
@ -414,7 +414,7 @@ void QQmlTypeData::done()
|
|||
QV4::ResolvedTypeReferenceMap resolvedTypeCache;
|
||||
QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
|
||||
{
|
||||
QQmlJS::DiagnosticMessage error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache);
|
||||
QQmlError error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache);
|
||||
if (error.isValid()) {
|
||||
setError(error);
|
||||
qDeleteAll(resolvedTypeCache);
|
||||
|
@ -461,7 +461,7 @@ void QQmlTypeData::done()
|
|||
{
|
||||
// Sanity check property bindings
|
||||
QQmlPropertyValidator validator(enginePrivate, m_importCache, m_compiledData);
|
||||
QVector<QQmlJS::DiagnosticMessage> errors = validator.validate();
|
||||
QVector<QQmlError> errors = validator.validate();
|
||||
if (!errors.isEmpty()) {
|
||||
setError(errors);
|
||||
return;
|
||||
|
@ -625,8 +625,8 @@ bool QQmlTypeData::loadFromSource()
|
|||
for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) {
|
||||
QQmlError e;
|
||||
e.setUrl(url());
|
||||
e.setLine(msg.line);
|
||||
e.setColumn(msg.column);
|
||||
e.setLine(qmlConvertSourceCoordinate<quint32, int>(msg.loc.startLine));
|
||||
e.setColumn(qmlConvertSourceCoordinate<quint32, int>(msg.loc.startColumn));
|
||||
e.setDescription(msg.message);
|
||||
errors << e;
|
||||
}
|
||||
|
@ -697,8 +697,8 @@ void QQmlTypeData::continueLoadFromIR()
|
|||
Q_ASSERT(errors.size());
|
||||
QQmlError error(errors.takeFirst());
|
||||
error.setUrl(m_importCache.baseUrl());
|
||||
error.setLine(import->location.line);
|
||||
error.setColumn(import->location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
|
||||
errors.prepend(error); // put it back on the list after filling out information.
|
||||
setError(errors);
|
||||
return;
|
||||
|
@ -724,8 +724,8 @@ void QQmlTypeData::allDependenciesDone()
|
|||
QQmlError error;
|
||||
error.setDescription(QQmlTypeLoader::tr("module \"%1\" is not installed").arg(import->uri));
|
||||
error.setUrl(m_importCache.baseUrl());
|
||||
error.setLine(import->location.line);
|
||||
error.setColumn(import->location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
|
||||
errors.prepend(error);
|
||||
}
|
||||
}
|
||||
|
@ -894,7 +894,7 @@ void QQmlTypeData::resolveTypes()
|
|||
loadImplicitImport();
|
||||
}
|
||||
|
||||
QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches(
|
||||
QQmlError QQmlTypeData::buildTypeResolutionCaches(
|
||||
QQmlRefPointer<QQmlTypeNameCache> *typeNameCache,
|
||||
QV4::ResolvedTypeReferenceMap *resolvedTypeCache
|
||||
) const
|
||||
|
@ -973,7 +973,7 @@ QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches(
|
|||
ref->doDynamicTypeCheck();
|
||||
resolvedTypeCache->insert(resolvedType.key(), ref.take());
|
||||
}
|
||||
QQmlJS::DiagnosticMessage noError;
|
||||
QQmlError noError;
|
||||
return noError;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ private:
|
|||
void restoreIR(QV4::CompiledData::CompilationUnit &&unit);
|
||||
void continueLoadFromIR();
|
||||
void resolveTypes();
|
||||
QQmlJS::DiagnosticMessage buildTypeResolutionCaches(
|
||||
QQmlError buildTypeResolutionCaches(
|
||||
QQmlRefPointer<QQmlTypeNameCache> *typeNameCache,
|
||||
QV4::ResolvedTypeReferenceMap *resolvedTypeCache
|
||||
) const;
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <private/qqmltypedata_p.h>
|
||||
#include <private/qqmltypeloaderqmldircontent_p.h>
|
||||
#include <private/qqmltypeloaderthread_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
|
||||
#include <QtQml/qqmlabstracturlinterceptor.h>
|
||||
#include <QtQml/qqmlengine.h>
|
||||
|
@ -696,8 +697,8 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob)
|
|||
Q_ASSERT(errors.size());
|
||||
QQmlError error(errors.takeFirst());
|
||||
error.setUrl(m_importCache.baseUrl());
|
||||
error.setLine(import->location.line);
|
||||
error.setColumn(import->location.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
|
||||
errors.prepend(error); // put it back on the list after filling out information.
|
||||
setError(errors);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <private/qqmltypeloaderqmldircontent_p.h>
|
||||
#include <private/qqmlsourcecoordinate_p.h>
|
||||
#include <QtQml/qqmlerror.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -59,8 +60,8 @@ QList<QQmlError> QQmlTypeLoaderQmldirContent::errors(const QString &uri) const
|
|||
for (const auto &parseError : parseErrors) {
|
||||
QQmlError error;
|
||||
error.setUrl(url);
|
||||
error.setLine(parseError.line);
|
||||
error.setColumn(parseError.column);
|
||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(parseError.loc.startLine));
|
||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(parseError.loc.startColumn));
|
||||
error.setDescription(parseError.message);
|
||||
errors.append(error);
|
||||
}
|
||||
|
@ -83,8 +84,8 @@ void QQmlTypeLoaderQmldirContent::setContent(const QString &location, const QStr
|
|||
void QQmlTypeLoaderQmldirContent::setError(const QQmlError &error)
|
||||
{
|
||||
QQmlJS::DiagnosticMessage parseError;
|
||||
parseError.line = error.line();
|
||||
parseError.column = error.column();
|
||||
parseError.loc.startLine = error.line();
|
||||
parseError.loc.startColumn = error.column();
|
||||
parseError.message = error.description();
|
||||
m_parser.setError(parseError);
|
||||
}
|
||||
|
|
|
@ -302,8 +302,8 @@ bool QQmlDirParser::parse(const QString &source)
|
|||
void QQmlDirParser::reportError(quint16 line, quint16 column, const QString &description)
|
||||
{
|
||||
QQmlJS::DiagnosticMessage error;
|
||||
error.line = line;
|
||||
error.column = column;
|
||||
error.loc.startLine = line;
|
||||
error.loc.startColumn = column;
|
||||
error.message = description;
|
||||
_errors.append(error);
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ bool QQmlDirParser::hasError() const
|
|||
void QQmlDirParser::setError(const QQmlJS::DiagnosticMessage &e)
|
||||
{
|
||||
_errors.clear();
|
||||
reportError(e.line, e.column, e.message);
|
||||
reportError(e.loc.startLine, e.loc.startColumn, e.message);
|
||||
}
|
||||
|
||||
QList<QQmlJS::DiagnosticMessage> QQmlDirParser::errors(const QString &uri) const
|
||||
|
|
|
@ -63,10 +63,10 @@ namespace {
|
|||
|
||||
for (const QQmlJS::DiagnosticMessage &e : errors) {
|
||||
QString errorString = QLatin1String("qmldir");
|
||||
if (e.line > 0) {
|
||||
errorString += QLatin1Char(':') + QString::number(e.line);
|
||||
if (e.column > 0)
|
||||
errorString += QLatin1Char(':') + QString::number(e.column);
|
||||
if (e.loc.startLine > 0) {
|
||||
errorString += QLatin1Char(':') + QString::number(e.loc.startLine);
|
||||
if (e.loc.startColumn > 0)
|
||||
errorString += QLatin1Char(':') + QString::number(e.loc.startColumn);
|
||||
}
|
||||
|
||||
errorString += QLatin1String(": ") + e.message;
|
||||
|
|
|
@ -216,7 +216,7 @@ QString AstDumper::qs(const QStringRef &s) {
|
|||
return qs(s.toString());
|
||||
}
|
||||
|
||||
QString AstDumper::loc(const AST::SourceLocation &s) {
|
||||
QString AstDumper::loc(const SourceLocation &s) {
|
||||
if (noLocations() || !s.isValid())
|
||||
return QLatin1String("\"\"");
|
||||
else {
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
QString qs(const char *s);
|
||||
QString qs(const QStringRef &s);
|
||||
|
||||
QString loc(const AST::SourceLocation &s);
|
||||
QString loc(const SourceLocation &s);
|
||||
|
||||
QString boolStr(bool v);
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ Error Error::augment(const QString &contextErrorMessage) const
|
|||
QString diagnosticErrorMessage(const QString &fileName, const QQmlJS::DiagnosticMessage &m)
|
||||
{
|
||||
QString message;
|
||||
message = fileName + QLatin1Char(':') + QString::number(m.line) + QLatin1Char(':');
|
||||
if (m.column > 0)
|
||||
message += QString::number(m.column) + QLatin1Char(':');
|
||||
message = fileName + QLatin1Char(':') + QString::number(m.loc.startLine) + QLatin1Char(':');
|
||||
if (m.loc.startColumn > 0)
|
||||
message += QString::number(m.loc.startColumn) + QLatin1Char(':');
|
||||
|
||||
if (m.isError())
|
||||
message += QLatin1String(" error: ");
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QVector>
|
||||
|
||||
using namespace QQmlJS::AST;
|
||||
using namespace QQmlJS;
|
||||
|
||||
struct Comment
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "commentastvisitor.h"
|
||||
|
||||
using namespace QQmlJS::AST;
|
||||
using namespace QQmlJS;
|
||||
|
||||
class DumpAstVisitor : protected Visitor
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImp
|
|||
const auto diagnosticMessages = parser.diagnosticMessages();
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
|
||||
qWarning().noquote() << QString::fromLatin1("%1:%2 : %3")
|
||||
.arg(filename).arg(m.line).arg(m.message);
|
||||
.arg(filename).arg(m.loc.startLine).arg(m.message);
|
||||
}
|
||||
|
||||
qWarning().noquote() << "Failed to parse" << filename;
|
||||
|
@ -112,7 +112,7 @@ bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImp
|
|||
const auto diagnosticMessages = parser.diagnosticMessages();
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
|
||||
qWarning().noquote() << QString::fromLatin1("<formatted>:%2 : %3")
|
||||
.arg(m.line).arg(m.message);
|
||||
.arg(m.loc.startLine).arg(m.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ QVariantList findQmlImportsInQmlCode(const QString &filePath, const QString &cod
|
|||
const auto diagnosticMessages = parser.diagnosticMessages();
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
|
||||
std::cerr << QDir::toNativeSeparators(filePath).toStdString() << ':'
|
||||
<< m.line << ':' << m.message.toStdString() << std::endl;
|
||||
<< m.loc.startLine << ':' << m.message.toStdString() << std::endl;
|
||||
}
|
||||
return QVariantList();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ static bool lint_file(const QString &filename, const bool silent, const bool war
|
|||
const auto diagnosticMessages = parser.diagnosticMessages();
|
||||
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
|
||||
qWarning().noquote() << QString::fromLatin1("%1:%2 : %3")
|
||||
.arg(filename).arg(m.line).arg(m.message);
|
||||
.arg(filename).arg(m.loc.startLine).arg(m.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void ScopeTree::insertJSIdentifier(const QString &id, QQmlJS::AST::VariableScope
|
|||
}
|
||||
|
||||
void ScopeTree::insertSignalIdentifier(const QString &id, const MetaMethod &method,
|
||||
const QQmlJS::AST::SourceLocation &loc,
|
||||
const QQmlJS::SourceLocation &loc,
|
||||
bool hasMultilineHandlerBody)
|
||||
{
|
||||
Q_ASSERT(m_scopeType == ScopeType::QMLScope);
|
||||
|
@ -77,7 +77,7 @@ void ScopeTree::insertPropertyIdentifier(const MetaProperty &property)
|
|||
}
|
||||
|
||||
void ScopeTree::addUnmatchedSignalHandler(const QString &handler,
|
||||
const QQmlJS::AST::SourceLocation &location)
|
||||
const QQmlJS::SourceLocation &location)
|
||||
{
|
||||
m_unmatchedSignalHandlers.append(qMakePair(handler, location));
|
||||
}
|
||||
|
@ -87,13 +87,13 @@ bool ScopeTree::isIdInCurrentScope(const QString &id) const
|
|||
return isIdInCurrentQMlScopes(id) || isIdInCurrentJSScopes(id);
|
||||
}
|
||||
|
||||
void ScopeTree::addIdToAccessed(const QString &id, const QQmlJS::AST::SourceLocation &location) {
|
||||
void ScopeTree::addIdToAccessed(const QString &id, const QQmlJS::SourceLocation &location) {
|
||||
m_currentFieldMember = new FieldMemberList {id, QString(), location, {}};
|
||||
m_accessedIdentifiers.push_back(std::unique_ptr<FieldMemberList>(m_currentFieldMember));
|
||||
}
|
||||
|
||||
void ScopeTree::accessMember(const QString &name, const QString &parentType,
|
||||
const QQmlJS::AST::SourceLocation &location)
|
||||
const QQmlJS::SourceLocation &location)
|
||||
{
|
||||
Q_ASSERT(m_currentFieldMember);
|
||||
auto *fieldMember = new FieldMemberList {name, parentType, location, {}};
|
||||
|
@ -115,7 +115,7 @@ bool ScopeTree::isVisualRootScope() const
|
|||
class IssueLocationWithContext
|
||||
{
|
||||
public:
|
||||
IssueLocationWithContext(const QString &code, const QQmlJS::AST::SourceLocation &location) {
|
||||
IssueLocationWithContext(const QString &code, const QQmlJS::SourceLocation &location) {
|
||||
int before = std::max(0,code.lastIndexOf('\n', location.offset));
|
||||
m_beforeText = code.midRef(before + 1, int(location.offset - (before + 1)));
|
||||
m_issueText = code.midRef(location.offset, location.length);
|
||||
|
@ -440,7 +440,7 @@ const ScopeTree *ScopeTree::currentQMLScope() const
|
|||
}
|
||||
|
||||
void ScopeTree::printContext(ColorOutput &colorOut, const QString &code,
|
||||
const QQmlJS::AST::SourceLocation &location) const
|
||||
const QQmlJS::SourceLocation &location) const
|
||||
{
|
||||
IssueLocationWithContext issueLocationWithContext {code, location};
|
||||
colorOut.write(issueLocationWithContext.beforeText().toString(), Normal);
|
||||
|
|
|
@ -68,7 +68,7 @@ enum class ScopeType
|
|||
struct MethodUsage
|
||||
{
|
||||
MetaMethod method;
|
||||
QQmlJS::AST::SourceLocation loc;
|
||||
QQmlJS::SourceLocation loc;
|
||||
bool hasMultilineHandlerBody;
|
||||
};
|
||||
|
||||
|
@ -112,16 +112,16 @@ public:
|
|||
|
||||
void insertJSIdentifier(const QString &id, QQmlJS::AST::VariableScope scope);
|
||||
void insertSignalIdentifier(const QString &id, const MetaMethod &method,
|
||||
const QQmlJS::AST::SourceLocation &loc, bool hasMultilineHandlerBody);
|
||||
const QQmlJS::SourceLocation &loc, bool hasMultilineHandlerBody);
|
||||
// inserts property as qml identifier as well as the corresponding
|
||||
void insertPropertyIdentifier(const MetaProperty &prop);
|
||||
void addUnmatchedSignalHandler(const QString &handler,
|
||||
const QQmlJS::AST::SourceLocation &location);
|
||||
const QQmlJS::SourceLocation &location);
|
||||
|
||||
bool isIdInCurrentScope(const QString &id) const;
|
||||
void addIdToAccessed(const QString &id, const QQmlJS::AST::SourceLocation &location);
|
||||
void addIdToAccessed(const QString &id, const QQmlJS::SourceLocation &location);
|
||||
void accessMember(const QString &name, const QString &parentType,
|
||||
const QQmlJS::AST::SourceLocation &location);
|
||||
const QQmlJS::SourceLocation &location);
|
||||
void resetMemberScope();
|
||||
|
||||
bool isVisualRootScope() const;
|
||||
|
@ -174,7 +174,7 @@ private:
|
|||
{
|
||||
QString m_name;
|
||||
QString m_parentType;
|
||||
QQmlJS::AST::SourceLocation m_location;
|
||||
QQmlJS::SourceLocation m_location;
|
||||
std::unique_ptr<FieldMemberList> m_child;
|
||||
};
|
||||
|
||||
|
@ -188,7 +188,7 @@ private:
|
|||
std::vector<std::unique_ptr<FieldMemberList>> m_accessedIdentifiers;
|
||||
FieldMemberList *m_currentFieldMember = nullptr;
|
||||
|
||||
QVector<QPair<QString, QQmlJS::AST::SourceLocation>> m_unmatchedSignalHandlers;
|
||||
QVector<QPair<QString, QQmlJS::SourceLocation>> m_unmatchedSignalHandlers;
|
||||
|
||||
QVector<ScopeTree::Ptr> m_childScopes;
|
||||
ScopeTree *m_parentScope;
|
||||
|
@ -211,7 +211,7 @@ private:
|
|||
bool isIdInjectedFromSignal(const QString &id) const;
|
||||
const ScopeTree *currentQMLScope() const;
|
||||
void printContext(ColorOutput &colorOut, const QString &code,
|
||||
const QQmlJS::AST::SourceLocation &location) const;
|
||||
const QQmlJS::SourceLocation &location) const;
|
||||
bool checkMemberAccess(
|
||||
const QString &code,
|
||||
FieldMemberList *members,
|
||||
|
|
|
@ -90,8 +90,8 @@ private:
|
|||
void readMetaObjectRevisions(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope);
|
||||
void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, MetaEnum *metaEnum);
|
||||
|
||||
void addError(const QQmlJS::AST::SourceLocation &loc, const QString &message);
|
||||
void addWarning(const QQmlJS::AST::SourceLocation &loc, const QString &message);
|
||||
void addError(const QQmlJS::SourceLocation &loc, const QString &message);
|
||||
void addWarning(const QQmlJS::SourceLocation &loc, const QString &message);
|
||||
|
||||
QString m_fileName;
|
||||
QString m_source;
|
||||
|
|
Loading…
Reference in New Issue