diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2009-05-29 11:20:11 (GMT) |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2009-05-29 11:20:11 (GMT) |
commit | fd255177af9d946e271d67000d3867b72cb5c682 (patch) | |
tree | fbd0e06f35122d6ded1b06897103179028e920d2 /src/declarative/qml | |
parent | 80518af09b464c88dfd419fa6087cffc1dc914b5 (diff) | |
download | Qt-fd255177af9d946e271d67000d3867b72cb5c682.zip Qt-fd255177af9d946e271d67000d3867b72cb5c682.tar.gz Qt-fd255177af9d946e271d67000d3867b72cb5c682.tar.bz2 |
Added range information for lists which contains the position and length
from the open bracket upto the close bracket.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmldom.cpp | 24 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 5 |
4 files changed, 33 insertions, 0 deletions
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 38436b4..0ebbbfb 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -1415,6 +1415,30 @@ void QmlDomList::setValues(const QList<QmlDomValue> &values) qWarning("QmlDomList::setValues(const QList<QmlDomValue> &): Not implemented"); } +/*! + Returns the position in the input data where the list started, or 0 if + the property is invalid. +*/ +int QmlDomList::position() const +{ + if (d && d->property) { + return d->property->listValueRange.offset; + } else + return 0; +} + +/*! + Returns the length in the input data from where the list started upto + the end of it, or 0 if the property is invalid. +*/ +int QmlDomList::length() const +{ + if (d && d->property) + return d->property->listValueRange.length; + else + return 0; +} + /*! \class QmlDomComponent diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index 04ce8b9..86eaecb 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -262,6 +262,9 @@ public: QList<QmlDomValue> values() const; void setValues(const QList<QmlDomValue> &); + int position() const; + int length() const; + private: friend class QmlDomValue; QSharedDataPointer<QmlDomValuePrivate> d; diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 020cae5..0fdd26b 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -276,6 +276,7 @@ namespace QmlParser bool isDefault; LocationSpan location; + LocationRange listValueRange; void dump(int = 0) const; }; diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 75c81a7..31a20be 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -651,6 +651,11 @@ bool ProcessAST::visit(AST::UiArrayBinding *node) accept(node->members); + // For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range: + Property* prop = currentProperty(); + prop->listValueRange.offset = node->lbracketToken.offset; + prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset; + while (propertyCount--) _stateStack.pop(); |