Commit 5e28dad5 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Updated the QML/JS front-end.

Reviewed-by: Christian Kamm
parent 1fb5ffa0
s/private\/qdeclarative/qml/g
s/qdeclarative/qml/g
s/QDECLARATIVE/QML/g
s/QDeclarative/Qml/g
......
......@@ -170,10 +170,9 @@ bool QmlDirParser::parse()
const int dotIndex = version.indexOf(QLatin1Char('.'));
if (dotIndex == -1) {
qWarning() << "expected '.'"; // ### use reportError
reportError(lineNumber, -1, QLatin1String("expected '.'"));
} else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
qWarning() << "unexpected '.'"; // ### use reportError
reportError(lineNumber, -1, QLatin1String("unexpected '.'"));
} else {
bool validVersionNumber = false;
const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber);
......@@ -189,8 +188,8 @@ bool QmlDirParser::parse()
}
}
} else {
// ### use reportError
qWarning() << "a component declaration requires 3 arguments, but" << (sectionCount + 1) << "were provided";
reportError(lineNumber, -1,
QString::fromUtf8("a component declaration requires 3 arguments, but %1 were provided").arg(sectionCount + 1));
}
}
......
......@@ -49,8 +49,27 @@ QT_BEGIN_NAMESPACE
/*!
\class QmlError
\since 4.7
\brief The QmlError class encapsulates a QML error
\since 4.7
\brief The QmlError class encapsulates a QML error.
QmlError includes a textual description of the error, as well
as location information (the file, line, and column). The toString()
method creates a single-line, human-readable string containing all of
this information, for example:
\code
file:///home/user/test.qml:7:8: Invalid property assignment: double expected
\endcode
You can use qDebug() or qWarning() to output errors to the console. This method
will attempt to open the file indicated by the error
and include additional contextual information.
\code
file:///home/user/test.qml:7:8: Invalid property assignment: double expected
y: "hello"
^
\endcode
\sa QmlView::errors(), QmlComponent::errors()
*/
class QmlErrorPrivate
{
......@@ -69,7 +88,7 @@ QmlErrorPrivate::QmlErrorPrivate()
}
/*!
Create an empty error object.
Creates an empty error object.
*/
QmlError::QmlError()
: d(0)
......@@ -77,7 +96,7 @@ QmlError::QmlError()
}
/*!
Create a copy of \a other.
Creates a copy of \a other.
*/
QmlError::QmlError(const QmlError &other)
: d(0)
......@@ -86,7 +105,7 @@ QmlError::QmlError(const QmlError &other)
}
/*!
Assign \a other to this error object.
Assigns \a other to this error object.
*/
QmlError &QmlError::operator=(const QmlError &other)
{
......@@ -112,7 +131,7 @@ QmlError::~QmlError()
}
/*!
Return true if this error is valid, otherwise false.
Returns true if this error is valid, otherwise false.
*/
bool QmlError::isValid() const
{
......@@ -120,7 +139,7 @@ bool QmlError::isValid() const
}
/*!
Return the url for the file that caused this error.
Returns the url for the file that caused this error.
*/
QUrl QmlError::url() const
{
......@@ -129,7 +148,7 @@ QUrl QmlError::url() const
}
/*!
Set the \a url for the file that caused this error.
Sets the \a url for the file that caused this error.
*/
void QmlError::setUrl(const QUrl &url)
{
......@@ -138,7 +157,7 @@ void QmlError::setUrl(const QUrl &url)
}
/*!
Return the error description.
Returns the error description.
*/
QString QmlError::description() const
{
......@@ -147,7 +166,7 @@ QString QmlError::description() const
}
/*!
Set the error \a description.
Sets the error \a description.
*/
void QmlError::setDescription(const QString &description)
{
......@@ -156,7 +175,7 @@ void QmlError::setDescription(const QString &description)
}
/*!
Return the error line number.
Returns the error line number.
*/
int QmlError::line() const
{
......@@ -165,7 +184,7 @@ int QmlError::line() const
}
/*!
Set the error \a line number.
Sets the error \a line number.
*/
void QmlError::setLine(int line)
{
......@@ -174,7 +193,7 @@ void QmlError::setLine(int line)
}
/*!
Return the error column number.
Returns the error column number.
*/
int QmlError::column() const
{
......@@ -183,7 +202,7 @@ int QmlError::column() const
}
/*!
Set the error \a column number.
Sets the error \a column number.
*/
void QmlError::setColumn(int column)
{
......@@ -192,14 +211,20 @@ void QmlError::setColumn(int column)
}
/*!
Return the error as a human readable string.
Returns the error as a human readable string.
*/
QString QmlError::toString() const
{
QString rv;
rv = url().toString() + QLatin1Char(':') + QString::number(line());
if(column() != -1)
rv += QLatin1Char(':') + QString::number(column());
if (url().isEmpty()) {
rv = QLatin1String("<Unknown File>");
} else if (line() != -1) {
rv = url().toString() + QLatin1Char(':') + QString::number(line());
if(column() != -1)
rv += QLatin1Char(':') + QString::number(column());
} else {
rv = url().toString();
}
rv += QLatin1String(": ") + description();
......@@ -210,7 +235,7 @@ QString QmlError::toString() const
\relates QmlError
\fn QDebug operator<<(QDebug debug, const QmlError &error)
Output a human readable version of \a error to \a debug.
Outputs a human readable version of \a error to \a debug.
*/
QDebug operator<<(QDebug debug, const QmlError &error)
......@@ -225,7 +250,9 @@ QDebug operator<<(QDebug debug, const QmlError &error)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QTextStream stream(data, QIODevice::ReadOnly);
#ifndef QT_NO_TEXTCODEC
stream.setCodec("UTF-8");
#endif
const QString code = stream.readAll();
const QStringList lines = code.split(QLatin1Char('\n'));
......
......@@ -1376,7 +1376,7 @@ case $rule_number: {
} break;
./
PropertyName: T_IDENTIFIER %prec REDUCE_HERE ;
PropertyName: T_IDENTIFIER %prec SHIFT_THERE ;
/.
case $rule_number: {
AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
......
......@@ -224,6 +224,9 @@ public:
inline Node()
: kind(Kind_Undefined) {}
// NOTE: node destructors are never called,
// instead we block free the memory
// (see the NodePool class)
virtual ~Node() {}
virtual ExpressionNode *expressionCast();
......@@ -247,7 +250,6 @@ class QML_PARSER_EXPORT ExpressionNode: public Node
{
public:
ExpressionNode() {}
virtual ~ExpressionNode() {}
virtual ExpressionNode *expressionCast();
......@@ -259,7 +261,6 @@ class QML_PARSER_EXPORT Statement: public Node
{
public:
Statement() {}
virtual ~Statement() {}
virtual Statement *statementCast();
......@@ -272,7 +273,7 @@ class QML_PARSER_EXPORT UiFormal: public Node
public:
QMLJS_DECLARE_AST_NODE(UiFormal)
explicit UiFormal(NameId *name, NameId *alias = 0)
UiFormal(NameId *name, NameId *alias = 0)
: name(name), alias(alias)
{ }
......@@ -379,7 +380,6 @@ public:
QMLJS_DECLARE_AST_NODE(ThisExpression)
ThisExpression() { kind = K; }
virtual ~ThisExpression() {}
virtual void accept0(Visitor *visitor);
......@@ -401,8 +401,6 @@ public:
IdentifierExpression(NameId *n):
name (n) { kind = K; }
virtual ~IdentifierExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -422,7 +420,6 @@ public:
QMLJS_DECLARE_AST_NODE(NullExpression)
NullExpression() { kind = K; }
virtual ~NullExpression() {}
virtual void accept0(Visitor *visitor);
......@@ -442,7 +439,6 @@ public:
QMLJS_DECLARE_AST_NODE(TrueLiteral)
TrueLiteral() { kind = K; }
virtual ~TrueLiteral() {}
virtual void accept0(Visitor *visitor);
......@@ -462,7 +458,6 @@ public:
QMLJS_DECLARE_AST_NODE(FalseLiteral)
FalseLiteral() { kind = K; }
virtual ~FalseLiteral() {}
virtual void accept0(Visitor *visitor);
......@@ -483,7 +478,6 @@ public:
NumericLiteral(double v):
value(v) { kind = K; }
virtual ~NumericLiteral() {}
virtual void accept0(Visitor *visitor);
......@@ -506,8 +500,6 @@ public:
StringLiteral(NameId *v):
value (v) { kind = K; }
virtual ~StringLiteral() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -529,8 +521,6 @@ public:
RegExpLiteral(NameId *p, int f):
pattern (p), flags (f) { kind = K; }
virtual ~RegExpLiteral() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -562,8 +552,6 @@ public:
elements (elts), elision (e)
{ kind = K; }
virtual ~ArrayLiteral() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -591,8 +579,6 @@ public:
ObjectLiteral(PropertyNameAndValueList *plist):
properties (plist) { kind = K; }
virtual ~ObjectLiteral() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -624,8 +610,6 @@ public:
previous->next = this;
}
virtual ~ElementList() {}
inline ElementList *finish ()
{
ElementList *front = next;
......@@ -657,8 +641,6 @@ public:
previous->next = this;
}
virtual ~Elision() {}
virtual void accept0(Visitor *visitor);
inline Elision *finish ()
......@@ -690,8 +672,6 @@ public:
previous->next = this;
}
virtual ~PropertyNameAndValueList() {}
virtual void accept0(Visitor *visitor);
inline PropertyNameAndValueList *finish ()
......@@ -715,7 +695,6 @@ public:
QMLJS_DECLARE_AST_NODE(PropertyName)
PropertyName() { kind = K; }
virtual ~PropertyName() {}
// attributes
SourceLocation propertyNameToken;
......@@ -729,8 +708,6 @@ public:
IdentifierPropertyName(NameId *n):
id (n) { kind = K; }
virtual ~IdentifierPropertyName() {}
virtual void accept0(Visitor *visitor);
// attributes
......@@ -744,7 +721,6 @@ public:
StringLiteralPropertyName(NameId *n):
id (n) { kind = K; }
virtual ~StringLiteralPropertyName() {}
virtual void accept0(Visitor *visitor);
......@@ -759,7 +735,6 @@ public:
NumericLiteralPropertyName(double n):
id (n) { kind = K; }
virtual ~NumericLiteralPropertyName() {}
virtual void accept0(Visitor *visitor);
......@@ -776,8 +751,6 @@ public:
base (b), expression (e)
{ kind = K; }
virtual ~ArrayMemberExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -802,8 +775,6 @@ public:
base (b), name (n)
{ kind = K; }
virtual ~FieldMemberExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -828,8 +799,6 @@ public:
base (b), arguments (a)
{ kind = K; }
virtual ~NewMemberExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -854,8 +823,6 @@ public:
NewExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~NewExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -878,8 +845,6 @@ public:
base (b), arguments (a)
{ kind = K; }
virtual ~CallExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -912,8 +877,6 @@ public:
previous->next = this;
}
virtual ~ArgumentList() {}
virtual void accept0(Visitor *visitor);
inline ArgumentList *finish ()
......@@ -937,8 +900,6 @@ public:
PostIncrementExpression(ExpressionNode *b):
base (b) { kind = K; }
virtual ~PostIncrementExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -960,8 +921,6 @@ public:
PostDecrementExpression(ExpressionNode *b):
base (b) { kind = K; }
virtual ~PostDecrementExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -982,7 +941,6 @@ public:
DeleteExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~DeleteExpression() {}
virtual void accept0(Visitor *visitor);
......@@ -1005,8 +963,6 @@ public:
VoidExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~VoidExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1028,8 +984,6 @@ public:
TypeOfExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~TypeOfExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1051,8 +1005,6 @@ public:
PreIncrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~PreIncrementExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1074,8 +1026,6 @@ public:
PreDecrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~PreDecrementExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1097,8 +1047,6 @@ public:
UnaryPlusExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~UnaryPlusExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1120,8 +1068,6 @@ public:
UnaryMinusExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~UnaryMinusExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1143,8 +1089,6 @@ public:
TildeExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~TildeExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1166,8 +1110,6 @@ public:
NotExpression(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~NotExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1190,8 +1132,6 @@ public:
left (l), op (o), right (r)
{ kind = K; }
virtual ~BinaryExpression() {}
virtual BinaryExpression *binaryExpressionCast();
virtual void accept0(Visitor *visitor);
......@@ -1218,8 +1158,6 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
virtual ~ConditionalExpression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1244,8 +1182,6 @@ public:
Expression(ExpressionNode *l, ExpressionNode *r):
left (l), right (r) { kind = K; }
virtual ~Expression() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1268,8 +1204,6 @@ public:
Block(StatementList *slist):
statements (slist) { kind = K; }
virtual ~Block() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1301,8 +1235,6 @@ public:
previous->next = this;
}
virtual ~StatementList() {}
virtual void accept0(Visitor *visitor);
inline StatementList *finish ()
......@@ -1326,8 +1258,6 @@ public:
declarations (vlist)
{ kind = K; }
virtual ~VariableStatement() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1351,8 +1281,6 @@ public:
name (n), expression (e), readOnly(false)
{ kind = K; }
virtual ~VariableDeclaration() {}
virtual void accept0(Visitor *visitor);
// attributes
......@@ -1379,8 +1307,6 @@ public:
previous->next = this;
}
virtual ~VariableDeclarationList() {}
virtual void accept0(Visitor *visitor);
inline VariableDeclarationList *finish (bool readOnly)
......@@ -1407,7 +1333,6 @@ public:
QMLJS_DECLARE_AST_NODE(EmptyStatement)
EmptyStatement() { kind = K; }
virtual ~EmptyStatement() {}
virtual void accept0(Visitor *visitor);
......@@ -1429,8 +1354,6 @@ public:
ExpressionStatement(ExpressionNode *e):
expression (e) { kind = K; }
virtual ~ExpressionStatement() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1453,8 +1376,6 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
virtual ~IfStatement() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1487,8 +1408,6 @@ public:
statement (stmt), expression (e)
{ kind = K; }
virtual ~DoWhileStatement() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1516,8 +1435,6 @@ public:
expression (e), statement (stmt)
{ kind = K; }
virtual ~WhileStatement() {}
virtual void accept0(Visitor *visitor);
virtual SourceLocation firstSourceLocation() const
......@@ -1543,8 +1460,6 @@ public:
initialiser (i), condition (c), expression (e), statement (stmt)
{ kind = K; <