diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2009-05-11 08:10:23 (GMT) |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2009-05-11 08:18:05 (GMT) |
commit | 205885831029730ee8faf28dcc7083806cfd5205 (patch) | |
tree | 565912a0f722ac54c52f065bb3791f637e12dc64 /src/declarative | |
parent | 4b474ca66f17d9c6a97fbfa521fcfeb68aa977e1 (diff) | |
download | Qt-205885831029730ee8faf28dcc7083806cfd5205.zip Qt-205885831029730ee8faf28dcc7083806cfd5205.tar.gz Qt-205885831029730ee8faf28dcc7083806cfd5205.tar.bz2 |
Added positioning information to the dom as position+length.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qmldom.cpp | 72 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.h | 9 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser_p.h | 8 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 2 |
4 files changed, 91 insertions, 0 deletions
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 4e754a3..ae335df 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -398,6 +398,30 @@ void QmlDomProperty::setValue(const QmlDomValue &value) qWarning("QmlDomProperty::setValue(const QmlDomValue &): Not Implemented"); } +/*! + Returns the position in the input data where the property ID startd, or 0 if + the property is invalid. +*/ +int QmlDomProperty::position() const +{ + if (d && d->property) { + return d->property->location.range.offset; + } else + return 0; +} + +/*! + Returns the length in the input data from where the property ID started upto + the end of it, or 0 if the property is invalid. +*/ +int QmlDomProperty::length() const +{ + if (d && d->property) + return d->property->location.range.length; + else + return 0; +} + QmlDomObjectPrivate::QmlDomObjectPrivate() : object(0), isVirtualComponent(false) { @@ -732,6 +756,30 @@ QmlDomComponent QmlDomObject::toComponent() const return rv; } +/*! + Returns the position in the input data where the property assignment started +, or 0 if the property is invalid. +*/ +int QmlDomObject::position() const +{ + if (d && d->object) + return d->object->location.range.offset; + else + return 0; +} + +/*! + Returns the length in the input data from where the property assignment star +ted upto the end of it, or 0 if the property is invalid. +*/ +int QmlDomObject::length() const +{ + if (d && d->object) + return d->object->location.range.length; + else + return 0; +} + QmlDomBasicValuePrivate::QmlDomBasicValuePrivate() : value(0) { @@ -1254,6 +1302,30 @@ QmlDomList QmlDomValue::toList() const } /*! + Returns the position in the input data where the property value startd, or 0 + if the value is invalid. +*/ +int QmlDomValue::position() const +{ + if (type() == Invalid) + return 0; + else + return d->value->location.range.offset; +} + +/*! + Returns the length in the input data from where the property value started u +pto the end of it, or 0 if the value is invalid. +*/ +int QmlDomValue::length() const +{ + if (type() == Invalid) + return 0; + else + return d->value->location.range.length; +} + +/*! \class QmlDomList \internal \brief The QmlDomList class represents a list of values assigned to a QML property. diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index 8b503fa..04ce8b9 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -99,6 +99,9 @@ public: QmlDomValue value() const; void setValue(const QmlDomValue &); + int position() const; + int length() const; + private: friend class QmlDomObject; QSharedDataPointer<QmlDomPropertyPrivate> d; @@ -134,6 +137,9 @@ public: bool isComponent() const; QmlDomComponent toComponent() const; + int position() const; + int length() const; + private: friend class QmlDomDocument; friend class QmlDomComponent; @@ -236,6 +242,9 @@ public: QmlDomObject toObject() const; QmlDomList toList() const; + int position() const; + int length() const; + private: friend class QmlDomProperty; friend class QmlDomList; diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 31f8702..f0eb864 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -74,10 +74,18 @@ namespace QmlParser int column; }; + struct LocationRange + { + LocationRange() : offset(0), length(0) {} + quint32 offset; + quint32 length; + }; + struct LocationSpan { Location start; Location end; + LocationRange range; }; class Property; diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 169e2ea..36005c2 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -339,6 +339,8 @@ LocationSpan ProcessAST::location(AST::SourceLocation start, AST::SourceLocation rv.start.column = start.startColumn; rv.end.line = end.startLine; rv.end.column = end.startColumn + end.length - 1; + rv.range.offset = start.offset; + rv.range.length = end.offset + end.length - start.offset; return rv; } |