summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2009-06-04 13:35:22 (GMT)
committerErik Verbruggen <erik.verbruggen@nokia.com>2009-06-04 13:35:22 (GMT)
commit30971fa4ffaeb4c2a3a1267cca73311fb9834241 (patch)
tree0c92a4f4add811e6b0b9f1cf6f736400a17d9542
parenta800e1d5e7fa69a3bfa21d74c5db47f5a41ed65c (diff)
downloadQt-30971fa4ffaeb4c2a3a1267cca73311fb9834241.zip
Qt-30971fa4ffaeb4c2a3a1267cca73311fb9834241.tar.gz
Qt-30971fa4ffaeb4c2a3a1267cca73311fb9834241.tar.bz2
Added offsets of automatically inserted semicolons to the DOM and the
QML script parser.
-rw-r--r--src/declarative/qml/qmldom.cpp10
-rw-r--r--src/declarative/qml/qmldom.h3
-rw-r--r--src/declarative/qml/qmldom_p.h1
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp11
-rw-r--r--src/declarative/qml/qmlscriptparser_p.h4
5 files changed, 29 insertions, 0 deletions
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 0ebbbfb..e06afb5 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -194,6 +194,8 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
d->imports += QUrl(td->data.imports().at(i).uri);
}
+ d->automaticSemicolonOffsets = td->data.automaticSemicolonOffsets();
+
if (td->data.tree()) {
if (compilerDump()) {
qWarning() << "-AST------------------------------------------------------------------------------";
@@ -251,6 +253,14 @@ QmlDomObject QmlDomDocument::rootObject() const
return rv;
}
+QList<int> QmlDomDocument::automaticSemicolonOffsets() const
+{
+ if (d)
+ return d->automaticSemicolonOffsets;
+ else
+ return QList<int>();
+}
+
QmlDomPropertyPrivate::QmlDomPropertyPrivate()
: property(0)
{
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index 86eaecb..442a4fc 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -78,6 +78,9 @@ public:
QByteArray save() const;
QmlDomObject rootObject() const;
+
+ QList<int> automaticSemicolonOffsets() const;
+
private:
QSharedDataPointer<QmlDomDocumentPrivate> d;
};
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
index 74edd47..441269c 100644
--- a/src/declarative/qml/qmldom_p.h
+++ b/src/declarative/qml/qmldom_p.h
@@ -62,6 +62,7 @@ public:
QList<QmlError> errors;
QList<QUrl> imports;
QmlParser::Object *root;
+ QList<int> automaticSemicolonOffsets;
};
class QmlDomObjectPrivate : public QSharedData
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 31a20be..5207292 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -178,6 +178,8 @@ protected:
virtual bool visit(AST::UiArrayBinding *node);
virtual bool visit(AST::UiSourceElement *node);
+ virtual bool visit(AST::ExpressionStatement *node);
+
void accept(AST::Node *node);
QString asString(AST::UiQualifiedId *node) const;
@@ -638,6 +640,14 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
return true;
}
+bool ProcessAST::visit(AST::ExpressionStatement *node)
+{
+ if (!node->semicolonToken.isValid())
+ _parser->addAutomaticSemicolonOffset(node->semicolonToken.offset);
+
+ return true;
+}
+
// UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiObjectMemberList T_RBRACKET ;
bool ProcessAST::visit(AST::UiArrayBinding *node)
{
@@ -825,6 +835,7 @@ void QmlScriptParser::clear()
_nameSpacePaths.clear();
_typeNames.clear();
_errors.clear();
+ _automaticSemicolonOffsets.clear();
if (data) {
delete data;
diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h
index 3993194..b057e2b 100644
--- a/src/declarative/qml/qmlscriptparser_p.h
+++ b/src/declarative/qml/qmlscriptparser_p.h
@@ -82,6 +82,9 @@ public:
QList<QmlError> errors() const;
+ QList<int> automaticSemicolonOffsets() const { return _automaticSemicolonOffsets; }
+ void addAutomaticSemicolonOffset(int offset) { _automaticSemicolonOffsets.append(offset); }
+
// ### private:
int findOrCreateTypeId(const QString &name);
void setTree(QmlParser::Object *tree);
@@ -100,6 +103,7 @@ public:
QStringList _typeNames;
QString _scriptFile;
QmlScriptParserJsASTData *data;
+ QList<int> _automaticSemicolonOffsets;
};
QT_END_NAMESPACE