forked from qt-creator/qt-creator
QmlJS: Add more value_casts.
And switch all existing dynamic_casts to value_casts. Change-Id: I93b89358e4802080f40b332074c64f4e91a2bc4c Reviewed-on: http://codereview.qt-project.org/6311 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -81,7 +81,7 @@ public:
|
||||
|
||||
virtual void visit(const NumberValue *value)
|
||||
{
|
||||
if (const QmlEnumValue *enumValue = dynamic_cast<const QmlEnumValue *>(value)) {
|
||||
if (const QmlEnumValue *enumValue = value_cast<QmlEnumValue>(value)) {
|
||||
if (StringLiteral *stringLiteral = cast<StringLiteral *>(_ast)) {
|
||||
const QString valueName = stringLiteral->value.toString();
|
||||
|
||||
@@ -643,7 +643,7 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
|
||||
const ObjectValue *lastPrototype = prototypes.last();
|
||||
if (iter.error() == PrototypeIterator::ReferenceResolutionError) {
|
||||
if (const QmlPrototypeReference *ref =
|
||||
dynamic_cast<const QmlPrototypeReference *>(lastPrototype->prototype())) {
|
||||
value_cast<QmlPrototypeReference>(lastPrototype->prototype())) {
|
||||
addMessage(ErrCouldNotResolvePrototypeOf, typeErrorLocation,
|
||||
toString(ref->qmlTypeName()), lastPrototype->className());
|
||||
} else {
|
||||
@@ -778,7 +778,7 @@ bool Check::visit(IdentifierExpression *)
|
||||
// _lastValue = evaluator.reference(ast);
|
||||
// if (!_lastValue)
|
||||
// addMessage(ErrUnknownIdentifier, ast->identifierToken);
|
||||
// if (const Reference *ref = value_cast<const Reference *>(_lastValue)) {
|
||||
// if (const Reference *ref = value_cast<Reference>(_lastValue)) {
|
||||
// _lastValue = _context->lookupReference(ref);
|
||||
// if (!_lastValue)
|
||||
// error(ast->identifierToken, tr("could not resolve"));
|
||||
@@ -1293,7 +1293,7 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
|
||||
// member lookup
|
||||
const UiQualifiedId *idPart = id;
|
||||
while (idPart->next) {
|
||||
const ObjectValue *objectValue = value_cast<const ObjectValue *>(value);
|
||||
const ObjectValue *objectValue = value_cast<ObjectValue>(value);
|
||||
if (! objectValue) {
|
||||
addMessage(ErrDoesNotHaveMembers, idPart->identifierToken, propertyName);
|
||||
return 0;
|
||||
|
@@ -134,11 +134,11 @@ QString Context::defaultPropertyName(const ObjectValue *object) const
|
||||
PrototypeIterator iter(object, this);
|
||||
while (iter.hasNext()) {
|
||||
const ObjectValue *o = iter.next();
|
||||
if (const ASTObjectValue *astObjValue = dynamic_cast<const ASTObjectValue *>(o)) {
|
||||
if (const ASTObjectValue *astObjValue = value_cast<ASTObjectValue>(o)) {
|
||||
QString defaultProperty = astObjValue->defaultPropertyName();
|
||||
if (!defaultProperty.isEmpty())
|
||||
return defaultProperty;
|
||||
} else if (const CppComponentValue *qmlValue = dynamic_cast<const CppComponentValue *>(o)) {
|
||||
} else if (const CppComponentValue *qmlValue = value_cast<CppComponentValue>(o)) {
|
||||
return qmlValue->defaultPropertyName();
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ ReferenceContext::ReferenceContext(const ContextPtr &context)
|
||||
|
||||
const Value *ReferenceContext::lookupReference(const Value *value)
|
||||
{
|
||||
const Reference *reference = value_cast<const Reference *>(value);
|
||||
const Reference *reference = value_cast<Reference>(value);
|
||||
if (!reference)
|
||||
return value;
|
||||
|
||||
|
@@ -62,7 +62,7 @@ const Value *Evaluate::value(AST::Node *ast)
|
||||
{
|
||||
const Value *result = reference(ast);
|
||||
|
||||
if (const Reference *ref = value_cast<const Reference *>(result)) {
|
||||
if (const Reference *ref = value_cast<Reference>(result)) {
|
||||
if (_referenceContext)
|
||||
result = _referenceContext->lookupReference(ref);
|
||||
else
|
||||
@@ -176,7 +176,7 @@ bool Evaluate::visit(AST::UiQualifiedId *ast)
|
||||
_result = value;
|
||||
|
||||
} else {
|
||||
const ObjectValue *base = value_cast<const ObjectValue *>(value);
|
||||
const ObjectValue *base = value_cast<ObjectValue>(value);
|
||||
|
||||
for (AST::UiQualifiedId *it = ast->next; base && it; it = it->next) {
|
||||
const QString &name = it->name.toString();
|
||||
@@ -187,7 +187,7 @@ bool Evaluate::visit(AST::UiQualifiedId *ast)
|
||||
if (! it->next)
|
||||
_result = value;
|
||||
else
|
||||
base = value_cast<const ObjectValue *>(value);
|
||||
base = value_cast<ObjectValue>(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ bool Evaluate::visit(AST::FieldMemberExpression *ast)
|
||||
|
||||
bool Evaluate::visit(AST::NewMemberExpression *ast)
|
||||
{
|
||||
if (const FunctionValue *ctor = value_cast<const FunctionValue *>(value(ast->base))) {
|
||||
if (const FunctionValue *ctor = value_cast<FunctionValue>(value(ast->base))) {
|
||||
_result = ctor->construct();
|
||||
}
|
||||
return false;
|
||||
@@ -336,7 +336,7 @@ bool Evaluate::visit(AST::NewMemberExpression *ast)
|
||||
|
||||
bool Evaluate::visit(AST::NewExpression *ast)
|
||||
{
|
||||
if (const FunctionValue *ctor = value_cast<const FunctionValue *>(value(ast->expression))) {
|
||||
if (const FunctionValue *ctor = value_cast<FunctionValue>(value(ast->expression))) {
|
||||
_result = ctor->construct();
|
||||
}
|
||||
return false;
|
||||
|
@@ -193,6 +193,11 @@ static QString generatedSlotName(const QString &base)
|
||||
return slotName;
|
||||
}
|
||||
|
||||
const CppComponentValue *CppComponentValue::asCppComponentValue() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void CppComponentValue::processMembers(MemberProcessor *processor) const
|
||||
{
|
||||
// process the meta enums
|
||||
@@ -337,7 +342,7 @@ const Value *CppComponentValue::valueForCppName(const QString &typeName) const
|
||||
|
||||
const CppComponentValue *CppComponentValue::prototype() const
|
||||
{
|
||||
Q_ASSERT(!_prototype || dynamic_cast<const CppComponentValue *>(_prototype));
|
||||
Q_ASSERT(!_prototype || value_cast<CppComponentValue>(_prototype));
|
||||
return static_cast<const CppComponentValue *>(_prototype);
|
||||
}
|
||||
|
||||
@@ -522,6 +527,11 @@ QmlEnumValue::~QmlEnumValue()
|
||||
{
|
||||
}
|
||||
|
||||
const QmlEnumValue *QmlEnumValue::asQmlEnumValue() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
QString QmlEnumValue::name() const
|
||||
{
|
||||
return _owner->metaObject()->enumerator(_enumIndex).name();
|
||||
@@ -669,6 +679,31 @@ const AnchorLineValue *Value::asAnchorLineValue() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CppComponentValue *Value::asCppComponentValue() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ASTObjectValue *Value::asAstObjectValue() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const QmlEnumValue *Value::asQmlEnumValue() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const QmlPrototypeReference *Value::asQmlPrototypeReference() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ASTPropertyReference *Value::asAstPropertyReference() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -853,10 +888,10 @@ const Value *ObjectValue::prototype() const
|
||||
|
||||
const ObjectValue *ObjectValue::prototype(const Context *context) const
|
||||
{
|
||||
const ObjectValue *prototypeObject = value_cast<const ObjectValue *>(_prototype);
|
||||
const ObjectValue *prototypeObject = value_cast<ObjectValue>(_prototype);
|
||||
if (! prototypeObject) {
|
||||
if (const Reference *prototypeReference = value_cast<const Reference *>(_prototype)) {
|
||||
prototypeObject = value_cast<const ObjectValue *>(context->lookupReference(prototypeReference));
|
||||
if (const Reference *prototypeReference = value_cast<Reference>(_prototype)) {
|
||||
prototypeObject = value_cast<ObjectValue>(context->lookupReference(prototypeReference));
|
||||
}
|
||||
}
|
||||
return prototypeObject;
|
||||
@@ -981,9 +1016,9 @@ bool PrototypeIterator::hasNext()
|
||||
if (!proto)
|
||||
return false;
|
||||
|
||||
m_next = value_cast<const ObjectValue *>(proto);
|
||||
m_next = value_cast<ObjectValue>(proto);
|
||||
if (! m_next)
|
||||
m_next = value_cast<const ObjectValue *>(m_context->lookupReference(proto));
|
||||
m_next = value_cast<ObjectValue>(m_context->lookupReference(proto));
|
||||
if (!m_next) {
|
||||
m_error = ReferenceResolutionError;
|
||||
return false;
|
||||
@@ -1480,15 +1515,15 @@ void ConvertToNumber::visit(const StringValue *)
|
||||
|
||||
void ConvertToNumber::visit(const ObjectValue *object)
|
||||
{
|
||||
if (const FunctionValue *valueOfMember = value_cast<const FunctionValue *>(object->lookupMember("valueOf", ContextPtr()))) {
|
||||
_result = value_cast<const NumberValue *>(valueOfMember->call(object)); // ### invoke convert-to-number?
|
||||
if (const FunctionValue *valueOfMember = value_cast<FunctionValue>(object->lookupMember("valueOf", ContextPtr()))) {
|
||||
_result = value_cast<NumberValue>(valueOfMember->call(object)); // ### invoke convert-to-number?
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertToNumber::visit(const FunctionValue *object)
|
||||
{
|
||||
if (const FunctionValue *valueOfMember = value_cast<const FunctionValue *>(object->lookupMember("valueOf", ContextPtr()))) {
|
||||
_result = value_cast<const NumberValue *>(valueOfMember->call(object)); // ### invoke convert-to-number?
|
||||
if (const FunctionValue *valueOfMember = value_cast<FunctionValue>(object->lookupMember("valueOf", ContextPtr()))) {
|
||||
_result = value_cast<NumberValue>(valueOfMember->call(object)); // ### invoke convert-to-number?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1541,15 +1576,15 @@ void ConvertToString::visit(const StringValue *value)
|
||||
|
||||
void ConvertToString::visit(const ObjectValue *object)
|
||||
{
|
||||
if (const FunctionValue *toStringMember = value_cast<const FunctionValue *>(object->lookupMember("toString", ContextPtr()))) {
|
||||
_result = value_cast<const StringValue *>(toStringMember->call(object)); // ### invoke convert-to-string?
|
||||
if (const FunctionValue *toStringMember = value_cast<FunctionValue>(object->lookupMember("toString", ContextPtr()))) {
|
||||
_result = value_cast<StringValue>(toStringMember->call(object)); // ### invoke convert-to-string?
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertToString::visit(const FunctionValue *object)
|
||||
{
|
||||
if (const FunctionValue *toStringMember = value_cast<const FunctionValue *>(object->lookupMember("toString", ContextPtr()))) {
|
||||
_result = value_cast<const StringValue *>(toStringMember->call(object)); // ### invoke convert-to-string?
|
||||
if (const FunctionValue *toStringMember = value_cast<FunctionValue>(object->lookupMember("toString", ContextPtr()))) {
|
||||
_result = value_cast<StringValue>(toStringMember->call(object)); // ### invoke convert-to-string?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1705,6 +1740,11 @@ ASTObjectValue::~ASTObjectValue()
|
||||
{
|
||||
}
|
||||
|
||||
const ASTObjectValue *ASTObjectValue::asAstObjectValue() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
bool ASTObjectValue::getSourceLocation(QString *fileName, int *line, int *column) const
|
||||
{
|
||||
*fileName = _doc->fileName();
|
||||
@@ -1856,6 +1896,11 @@ QmlPrototypeReference::~QmlPrototypeReference()
|
||||
{
|
||||
}
|
||||
|
||||
const QmlPrototypeReference *QmlPrototypeReference::asQmlPrototypeReference() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
UiQualifiedId *QmlPrototypeReference::qmlTypeName() const
|
||||
{
|
||||
return _qmlTypeName;
|
||||
@@ -1878,6 +1923,11 @@ ASTPropertyReference::~ASTPropertyReference()
|
||||
{
|
||||
}
|
||||
|
||||
const ASTPropertyReference *ASTPropertyReference::asAstPropertyReference() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
bool ASTPropertyReference::getSourceLocation(QString *fileName, int *line, int *column) const
|
||||
{
|
||||
*fileName = _doc->fileName();
|
||||
|
@@ -75,6 +75,11 @@ class JSImportScope;
|
||||
class Context;
|
||||
typedef QSharedPointer<const Context> ContextPtr;
|
||||
class ReferenceContext;
|
||||
class CppComponentValue;
|
||||
class ASTObjectValue;
|
||||
class QmlEnumValue;
|
||||
class QmlPrototypeReference;
|
||||
class ASTPropertyReference;
|
||||
|
||||
typedef QList<const Value *> ValueList;
|
||||
|
||||
@@ -124,13 +129,18 @@ public:
|
||||
virtual const Reference *asReference() const;
|
||||
virtual const ColorValue *asColorValue() const;
|
||||
virtual const AnchorLineValue *asAnchorLineValue() const;
|
||||
virtual const CppComponentValue *asCppComponentValue() const;
|
||||
virtual const ASTObjectValue *asAstObjectValue() const;
|
||||
virtual const QmlEnumValue *asQmlEnumValue() const;
|
||||
virtual const QmlPrototypeReference *asQmlPrototypeReference() const;
|
||||
virtual const ASTPropertyReference *asAstPropertyReference() const;
|
||||
|
||||
virtual void accept(ValueVisitor *) const = 0;
|
||||
|
||||
virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
|
||||
};
|
||||
|
||||
template <typename _RetTy> _RetTy value_cast(const Value *v);
|
||||
template <typename _RetTy> const _RetTy *value_cast(const Value *v);
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const NullValue *value_cast(const Value *v)
|
||||
{
|
||||
@@ -210,6 +220,36 @@ template <> Q_INLINE_TEMPLATE const AnchorLineValue *value_cast(const Value *v)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const CppComponentValue *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asCppComponentValue();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const ASTObjectValue *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asAstObjectValue();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const QmlEnumValue *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asQmlEnumValue();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const QmlPrototypeReference *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asQmlPrototypeReference();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
template <> Q_INLINE_TEMPLATE const ASTPropertyReference *value_cast(const Value *v)
|
||||
{
|
||||
if (v) return v->asAstPropertyReference();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Value nodes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -394,14 +434,14 @@ private:
|
||||
Error m_error;
|
||||
};
|
||||
|
||||
class CppComponentValue;
|
||||
|
||||
class QMLJS_EXPORT QmlEnumValue: public NumberValue
|
||||
{
|
||||
public:
|
||||
QmlEnumValue(const CppComponentValue *owner, int index);
|
||||
virtual ~QmlEnumValue();
|
||||
|
||||
virtual const QmlEnumValue *asQmlEnumValue() const;
|
||||
|
||||
QString name() const;
|
||||
QStringList keys() const;
|
||||
const CppComponentValue *owner() const;
|
||||
@@ -423,6 +463,8 @@ public:
|
||||
ValueOwner *valueOwner);
|
||||
virtual ~CppComponentValue();
|
||||
|
||||
virtual const CppComponentValue *asCppComponentValue() const;
|
||||
|
||||
virtual void processMembers(MemberProcessor *processor) const;
|
||||
const Value *valueForCppName(const QString &typeName) const;
|
||||
|
||||
@@ -701,6 +743,8 @@ public:
|
||||
QmlPrototypeReference(AST::UiQualifiedId *qmlTypeName, const Document *doc, ValueOwner *valueOwner);
|
||||
virtual ~QmlPrototypeReference();
|
||||
|
||||
virtual const QmlPrototypeReference *asQmlPrototypeReference() const;
|
||||
|
||||
AST::UiQualifiedId *qmlTypeName() const;
|
||||
|
||||
private:
|
||||
@@ -755,6 +799,8 @@ public:
|
||||
ASTPropertyReference(AST::UiPublicMember *ast, const Document *doc, ValueOwner *valueOwner);
|
||||
virtual ~ASTPropertyReference();
|
||||
|
||||
virtual const ASTPropertyReference *asAstPropertyReference() const;
|
||||
|
||||
AST::UiPublicMember *ast() const { return _ast; }
|
||||
QString onChangedSlotName() const { return _onChangedSlotName; }
|
||||
|
||||
@@ -804,6 +850,8 @@ public:
|
||||
ValueOwner *valueOwner);
|
||||
virtual ~ASTObjectValue();
|
||||
|
||||
virtual const ASTObjectValue *asAstObjectValue() const;
|
||||
|
||||
bool getSourceLocation(QString *fileName, int *line, int *column) const;
|
||||
virtual void processMembers(MemberProcessor *processor) const;
|
||||
|
||||
|
@@ -185,7 +185,7 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
|
||||
iter.next();
|
||||
while (iter.hasNext()) {
|
||||
const ObjectValue *prototype = iter.next();
|
||||
if (const CppComponentValue *qmlMetaObject = dynamic_cast<const CppComponentValue *>(prototype)) {
|
||||
if (const CppComponentValue *qmlMetaObject = value_cast<CppComponentValue>(prototype)) {
|
||||
if ((qmlMetaObject->className() == QLatin1String("ListElement")
|
||||
|| qmlMetaObject->className() == QLatin1String("Connections")
|
||||
) && (qmlMetaObject->moduleName() == QLatin1String("Qt")
|
||||
@@ -211,7 +211,7 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
|
||||
Evaluate evaluator(_scopeChain);
|
||||
const Value *targetValue = evaluator(scriptBinding->statement);
|
||||
|
||||
if (const ObjectValue *target = value_cast<const ObjectValue *>(targetValue)) {
|
||||
if (const ObjectValue *target = value_cast<ObjectValue>(targetValue)) {
|
||||
qmlScopeObjects.prepend(target);
|
||||
} else {
|
||||
qmlScopeObjects.clear();
|
||||
@@ -259,7 +259,7 @@ const ObjectValue *ScopeBuilder::isPropertyChangesObject(const ContextPtr &conte
|
||||
PrototypeIterator iter(object, context);
|
||||
while (iter.hasNext()) {
|
||||
const ObjectValue *prototype = iter.next();
|
||||
if (const CppComponentValue *qmlMetaObject = dynamic_cast<const CppComponentValue *>(prototype)) {
|
||||
if (const CppComponentValue *qmlMetaObject = value_cast<CppComponentValue>(prototype)) {
|
||||
if (qmlMetaObject->className() == QLatin1String("PropertyChanges")
|
||||
&& (qmlMetaObject->moduleName() == QLatin1String("Qt")
|
||||
|| qmlMetaObject->moduleName() == QLatin1String("QtQuick")))
|
||||
|
@@ -96,14 +96,14 @@ class PropertyMemberProcessor : public MemberProcessor
|
||||
public:
|
||||
virtual bool processProperty(const QString &name, const Value *value)
|
||||
{
|
||||
const ASTPropertyReference *ref = dynamic_cast<const ASTPropertyReference*>(value);
|
||||
const ASTPropertyReference *ref = value_cast<ASTPropertyReference>(value);
|
||||
if (ref) {
|
||||
QString type = "unknown";
|
||||
if (!ref->ast()->memberType.isEmpty())
|
||||
type = ref->ast()->memberType.toString();
|
||||
m_properties.append(qMakePair(name, type));
|
||||
} else {
|
||||
if (const CppComponentValue * ov = dynamic_cast<const CppComponentValue *>(value)) {
|
||||
if (const CppComponentValue * ov = value_cast<CppComponentValue>(value)) {
|
||||
QString qualifiedTypeName = ov->moduleName().isEmpty() ? ov->className() : ov->moduleName() + '.' + ov->className();
|
||||
m_properties.append(qMakePair(name, qualifiedTypeName));
|
||||
} else {
|
||||
@@ -140,7 +140,7 @@ const CppComponentValue *findQmlPrototype(const ObjectValue *ov, const ContextPt
|
||||
if (!ov)
|
||||
return 0;
|
||||
|
||||
const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov);
|
||||
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(ov);
|
||||
if (qmlValue)
|
||||
return qmlValue;
|
||||
|
||||
@@ -154,7 +154,7 @@ QStringList prototypes(const ObjectValue *ov, const ContextPtr &context, bool ve
|
||||
return list;
|
||||
ov = ov->prototype(context);
|
||||
while (ov) {
|
||||
const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov);
|
||||
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(ov);
|
||||
if (qmlValue) {
|
||||
if (versions) {
|
||||
list << qmlValue->moduleName() + '.' + qmlValue->className() +
|
||||
@@ -192,7 +192,7 @@ QList<PropertyInfo> getQmlTypes(const CppComponentValue *ov, const ContextPtr &c
|
||||
QString name = property.first;
|
||||
if (!ov->isWritable(name) && ov->isPointer(name)) {
|
||||
//dot property
|
||||
const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov->lookupMember(name, context));
|
||||
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(ov->lookupMember(name, context));
|
||||
if (qmlValue) {
|
||||
QList<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context);
|
||||
foreach (const PropertyInfo &propertyInfo, dotProperties) {
|
||||
@@ -204,7 +204,7 @@ QList<PropertyInfo> getQmlTypes(const CppComponentValue *ov, const ContextPtr &c
|
||||
}
|
||||
}
|
||||
if (isValueType(ov->propertyType(name))) {
|
||||
const ObjectValue *dotObjectValue = dynamic_cast<const ObjectValue *>(ov->lookupMember(name, context));
|
||||
const ObjectValue *dotObjectValue = value_cast<ObjectValue>(ov->lookupMember(name, context));
|
||||
if (dotObjectValue) {
|
||||
QList<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context);
|
||||
foreach (const PropertyInfo &propertyInfo, dotProperties) {
|
||||
@@ -224,7 +224,7 @@ QList<PropertyInfo> getQmlTypes(const CppComponentValue *ov, const ContextPtr &c
|
||||
if (!local) {
|
||||
const ObjectValue* prototype = ov->prototype(context);
|
||||
|
||||
const CppComponentValue * qmlObjectValue = dynamic_cast<const CppComponentValue *>(prototype);
|
||||
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype);
|
||||
|
||||
if (qmlObjectValue) {
|
||||
list << getQmlTypes(qmlObjectValue, context);
|
||||
@@ -240,7 +240,7 @@ QList<PropertyInfo> getTypes(const ObjectValue *ov, const ContextPtr &context, b
|
||||
{
|
||||
QList<PropertyInfo> list;
|
||||
|
||||
const CppComponentValue * qmlObjectValue = dynamic_cast<const CppComponentValue *>(ov);
|
||||
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(ov);
|
||||
|
||||
if (qmlObjectValue) {
|
||||
list << getQmlTypes(qmlObjectValue, context, local);
|
||||
@@ -264,7 +264,7 @@ QList<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &cont
|
||||
if (!local) {
|
||||
const ObjectValue* prototype = ov->prototype(context);
|
||||
|
||||
const CppComponentValue * qmlObjectValue = dynamic_cast<const CppComponentValue *>(prototype);
|
||||
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype);
|
||||
|
||||
if (qmlObjectValue) {
|
||||
list << getQmlTypes(qmlObjectValue, context);
|
||||
@@ -434,7 +434,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in
|
||||
} else {
|
||||
const ObjectValue *objectValue = getObjectValue();
|
||||
if (objectValue) {
|
||||
const CppComponentValue *qmlValue = dynamic_cast<const CppComponentValue *>(objectValue);
|
||||
const CppComponentValue *qmlValue = value_cast<CppComponentValue>(objectValue);
|
||||
if (qmlValue) {
|
||||
m_majorVersion = qmlValue->componentVersion().majorVersion();
|
||||
m_minorVersion = qmlValue->componentVersion().minorVersion();
|
||||
@@ -476,7 +476,7 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons
|
||||
if (import.info.path() != module)
|
||||
continue;
|
||||
const Value *lookupResult = import.object->lookupMember(type, context());
|
||||
if ((value = dynamic_cast<const CppComponentValue *>(lookupResult)))
|
||||
if ((value = value_cast<CppComponentValue>(lookupResult)))
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -759,7 +759,7 @@ QString NodeMetaInfoPrivate::packageName() const
|
||||
QString NodeMetaInfoPrivate::componentSource() const
|
||||
{
|
||||
if (isComponent()) {
|
||||
const ASTObjectValue * astObjectValue = dynamic_cast<const ASTObjectValue *>(getObjectValue());
|
||||
const ASTObjectValue * astObjectValue = value_cast<ASTObjectValue>(getObjectValue());
|
||||
if (astObjectValue)
|
||||
return astObjectValue->document()->source().mid(astObjectValue->typeName()->identifierToken.begin(),
|
||||
astObjectValue->initializer()->rbraceToken.end());
|
||||
@@ -770,7 +770,7 @@ QString NodeMetaInfoPrivate::componentSource() const
|
||||
QString NodeMetaInfoPrivate::componentFileName() const
|
||||
{
|
||||
if (isComponent()) {
|
||||
const ASTObjectValue * astObjectValue = dynamic_cast<const ASTObjectValue *>(getObjectValue());
|
||||
const ASTObjectValue * astObjectValue = value_cast<ASTObjectValue>(getObjectValue());
|
||||
if (astObjectValue) {
|
||||
QString fileName;
|
||||
int line;
|
||||
@@ -831,7 +831,7 @@ void NodeMetaInfoPrivate::setupPrototypes()
|
||||
description.className = ov->className();
|
||||
description.minorVersion = -1;
|
||||
description.majorVersion = -1;
|
||||
if (const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov)) {
|
||||
if (const CppComponentValue * qmlValue = value_cast<CppComponentValue>(ov)) {
|
||||
description.minorVersion = qmlValue->componentVersion().minorVersion();
|
||||
description.majorVersion = qmlValue->componentVersion().majorVersion();
|
||||
if (!qmlValue->moduleName().isEmpty())
|
||||
|
@@ -344,7 +344,7 @@ public:
|
||||
const ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode);
|
||||
defaultPropertyName = m_context->defaultPropertyName(value);
|
||||
|
||||
const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(value);
|
||||
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(value);
|
||||
if (qmlValue) {
|
||||
typeName = fixUpPackeNameForQt(qmlValue->moduleName()) + QLatin1String(".") + qmlValue->className();
|
||||
|
||||
@@ -452,7 +452,7 @@ public:
|
||||
if (prefix.isEmpty())
|
||||
idPart = idPart->next;
|
||||
for (; idPart; idPart = idPart->next) {
|
||||
objectValue = value_cast<const ObjectValue *>(value);
|
||||
objectValue = value_cast<ObjectValue>(value);
|
||||
if (! objectValue) {
|
||||
// if (idPart->name)
|
||||
// qDebug() << idPart->name->asString() << "has no property named"
|
||||
@@ -500,7 +500,7 @@ public:
|
||||
const ObjectValue *proto = iter.next();
|
||||
if (proto->lookupMember(name, m_context) == m_context->valueOwner()->arrayPrototype())
|
||||
return true;
|
||||
if (const CppComponentValue *qmlIter = dynamic_cast<const CppComponentValue *>(proto)) {
|
||||
if (const CppComponentValue *qmlIter = value_cast<CppComponentValue>(proto)) {
|
||||
if (qmlIter->isListProperty(name))
|
||||
return true;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ public:
|
||||
if (containingObject)
|
||||
containingObject->lookupMember(name, m_context, &containingObject);
|
||||
|
||||
if (const CppComponentValue * qmlObject = dynamic_cast<const CppComponentValue *>(containingObject)) {
|
||||
if (const CppComponentValue * qmlObject = value_cast<CppComponentValue>(containingObject)) {
|
||||
const QString typeName = qmlObject->propertyType(name);
|
||||
if (qmlObject->getEnum(typeName).isValid()) {
|
||||
return QVariant(cleanedValue);
|
||||
@@ -569,7 +569,7 @@ public:
|
||||
|
||||
if (containingObject)
|
||||
containingObject->lookupMember(name, m_context, &containingObject);
|
||||
const CppComponentValue * lhsCppComponent = dynamic_cast<const CppComponentValue *>(containingObject);
|
||||
const CppComponentValue * lhsCppComponent = value_cast<CppComponentValue>(containingObject);
|
||||
if (!lhsCppComponent)
|
||||
return QVariant();
|
||||
const QString lhsPropertyTypeName = lhsCppComponent->propertyType(name);
|
||||
@@ -593,7 +593,7 @@ public:
|
||||
if (rhsValueObject)
|
||||
rhsValueObject->lookupMember(rhsValueName, m_context, &rhsValueObject);
|
||||
|
||||
const CppComponentValue *rhsCppComponentValue = dynamic_cast<const CppComponentValue *>(rhsValueObject);
|
||||
const CppComponentValue *rhsCppComponentValue = value_cast<CppComponentValue>(rhsValueObject);
|
||||
if (!rhsCppComponentValue)
|
||||
return QVariant();
|
||||
|
||||
|
@@ -148,7 +148,7 @@ public:
|
||||
|
||||
virtual void operator ()(const Value *base, const QString &name, const Value *)
|
||||
{
|
||||
const CppComponentValue *qmlBase = dynamic_cast<const CppComponentValue *>(base);
|
||||
const CppComponentValue *qmlBase = value_cast<CppComponentValue>(base);
|
||||
|
||||
QString itemText = name;
|
||||
QString postfix;
|
||||
@@ -547,7 +547,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
|
||||
}
|
||||
const Value *v = newScopeType->lookupMember(it->name.toString(), context);
|
||||
v = context->lookupReference(v);
|
||||
newScopeType = value_cast<const ObjectValue *>(v);
|
||||
newScopeType = value_cast<ObjectValue>(v);
|
||||
}
|
||||
if (!newScopeType)
|
||||
break;
|
||||
@@ -642,7 +642,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
|
||||
const Value *value =
|
||||
getPropertyValue(qmlScopeType, contextFinder.bindingPropertyName(), context);
|
||||
if (const QmlEnumValue *enumValue =
|
||||
dynamic_cast<const QmlEnumValue *>(value)) {
|
||||
value_cast<QmlEnumValue>(value)) {
|
||||
const QString &name = context->imports(document.data())->nameForImportedObject(enumValue->owner(), context.data());
|
||||
foreach (const QString &key, enumValue->keys()) {
|
||||
QString completion;
|
||||
|
@@ -525,7 +525,7 @@ protected:
|
||||
if ((!_name.isEmpty()) && _name.at(0).isUpper()) {
|
||||
// a possible type
|
||||
_targetValue = _scopeChain->lookup(_name, &_scope);
|
||||
if (value_cast<const ObjectValue*>(_targetValue))
|
||||
if (value_cast<ObjectValue>(_targetValue))
|
||||
_typeKind = TypeKind;
|
||||
}
|
||||
}
|
||||
@@ -851,7 +851,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
FindReferences::Usage searchStarting(replacement, name, 0, 0, 0);
|
||||
|
||||
if (findTarget.typeKind() == findTarget.TypeKind){
|
||||
const ObjectValue *typeValue = value_cast<const ObjectValue*>(findTarget.targetValue());
|
||||
const ObjectValue *typeValue = value_cast<ObjectValue>(findTarget.targetValue());
|
||||
if (!typeValue)
|
||||
return;
|
||||
future.reportResult(searchStarting);
|
||||
|
@@ -300,7 +300,7 @@ void HoverHandler::prettyPrintTooltip(const QmlJS::Value *value,
|
||||
}
|
||||
}
|
||||
} else if (const QmlEnumValue *enumValue =
|
||||
dynamic_cast<const QmlEnumValue *>(value)) {
|
||||
value_cast<QmlEnumValue>(value)) {
|
||||
setToolTip(enumValue->name());
|
||||
}
|
||||
|
||||
|
@@ -138,7 +138,7 @@ protected:
|
||||
PrototypeIterator it(v, m_scopeChain.context());
|
||||
while (it.hasNext()) {
|
||||
const ObjectValue *proto = it.next();
|
||||
const CppComponentValue *qmlProto = dynamic_cast<const CppComponentValue *>(proto);
|
||||
const CppComponentValue *qmlProto = value_cast<CppComponentValue>(proto);
|
||||
if (!qmlProto)
|
||||
continue;
|
||||
if (qmlProto->metaObject() == m_statePrototype->metaObject())
|
||||
|
@@ -76,7 +76,7 @@ static inline const ObjectValue * getPropertyChangesTarget(Node *node, const Sco
|
||||
&& ! scriptBinding->qualifiedId->next) {
|
||||
Evaluate evaluator(&scopeChain);
|
||||
const Value *targetValue = evaluator(scriptBinding->statement);
|
||||
if (const ObjectValue *targetObject = value_cast<const ObjectValue *>(targetValue)) {
|
||||
if (const ObjectValue *targetObject = value_cast<ObjectValue>(targetValue)) {
|
||||
return targetObject;
|
||||
} else {
|
||||
return 0;
|
||||
|
@@ -144,17 +144,17 @@ void tst_Basic::basicObjectTests()
|
||||
QVERIFY(ovProperty);
|
||||
QCOMPARE(ovProperty->className(), QString("State"));
|
||||
|
||||
const CppComponentValue * qmlItemValue = dynamic_cast<const CppComponentValue *>(ovItem);
|
||||
const CppComponentValue * qmlItemValue = value_cast<CppComponentValue>(ovItem);
|
||||
QVERIFY(qmlItemValue);
|
||||
QCOMPARE(qmlItemValue->defaultPropertyName(), QString("data"));
|
||||
QCOMPARE(qmlItemValue->propertyType("state"), QString("string"));
|
||||
|
||||
const ObjectValue *ovState = context->lookupType(doc.data(), QStringList() << "State");
|
||||
const CppComponentValue * qmlState2Value = dynamic_cast<const CppComponentValue *>(ovState);
|
||||
const CppComponentValue * qmlState2Value = value_cast<CppComponentValue>(ovState);
|
||||
QCOMPARE(qmlState2Value->className(), QString("State"));
|
||||
|
||||
const ObjectValue *ovImage = context->lookupType(doc.data(), QStringList() << "Image");
|
||||
const CppComponentValue * qmlImageValue = dynamic_cast<const CppComponentValue *>(ovImage);
|
||||
const CppComponentValue * qmlImageValue = value_cast<CppComponentValue>(ovImage);
|
||||
QCOMPARE(qmlImageValue->className(), QString("Image"));
|
||||
QCOMPARE(qmlImageValue->propertyType("source"), QString("QUrl"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user