diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index 88792c9c029..e3d55efef18 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -81,7 +81,7 @@ public: virtual void visit(const NumberValue *value) { - if (const QmlEnumValue *enumValue = dynamic_cast(value)) { + if (const QmlEnumValue *enumValue = value_cast(value)) { if (StringLiteral *stringLiteral = cast(_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(lastPrototype->prototype())) { + value_cast(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(_lastValue)) { +// if (const Reference *ref = value_cast(_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(value); + const ObjectValue *objectValue = value_cast(value); if (! objectValue) { addMessage(ErrDoesNotHaveMembers, idPart->identifierToken, propertyName); return 0; diff --git a/src/libs/qmljs/qmljscontext.cpp b/src/libs/qmljs/qmljscontext.cpp index c52471d64d2..648702b1111 100644 --- a/src/libs/qmljs/qmljscontext.cpp +++ b/src/libs/qmljs/qmljscontext.cpp @@ -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(o)) { + if (const ASTObjectValue *astObjValue = value_cast(o)) { QString defaultProperty = astObjValue->defaultPropertyName(); if (!defaultProperty.isEmpty()) return defaultProperty; - } else if (const CppComponentValue *qmlValue = dynamic_cast(o)) { + } else if (const CppComponentValue *qmlValue = value_cast(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(value); + const Reference *reference = value_cast(value); if (!reference) return value; diff --git a/src/libs/qmljs/qmljsevaluate.cpp b/src/libs/qmljs/qmljsevaluate.cpp index bbb9f021ef7..501636e7e91 100644 --- a/src/libs/qmljs/qmljsevaluate.cpp +++ b/src/libs/qmljs/qmljsevaluate.cpp @@ -62,7 +62,7 @@ const Value *Evaluate::value(AST::Node *ast) { const Value *result = reference(ast); - if (const Reference *ref = value_cast(result)) { + if (const Reference *ref = value_cast(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(value); + const ObjectValue *base = value_cast(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(value); + base = value_cast(value); } } @@ -328,7 +328,7 @@ bool Evaluate::visit(AST::FieldMemberExpression *ast) bool Evaluate::visit(AST::NewMemberExpression *ast) { - if (const FunctionValue *ctor = value_cast(value(ast->base))) { + if (const FunctionValue *ctor = value_cast(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(value(ast->expression))) { + if (const FunctionValue *ctor = value_cast(value(ast->expression))) { _result = ctor->construct(); } return false; diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 6679001d28d..ae70d5d39e0 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -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(_prototype)); + Q_ASSERT(!_prototype || value_cast(_prototype)); return static_cast(_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(_prototype); + const ObjectValue *prototypeObject = value_cast(_prototype); if (! prototypeObject) { - if (const Reference *prototypeReference = value_cast(_prototype)) { - prototypeObject = value_cast(context->lookupReference(prototypeReference)); + if (const Reference *prototypeReference = value_cast(_prototype)) { + prototypeObject = value_cast(context->lookupReference(prototypeReference)); } } return prototypeObject; @@ -981,9 +1016,9 @@ bool PrototypeIterator::hasNext() if (!proto) return false; - m_next = value_cast(proto); + m_next = value_cast(proto); if (! m_next) - m_next = value_cast(m_context->lookupReference(proto)); + m_next = value_cast(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(object->lookupMember("valueOf", ContextPtr()))) { - _result = value_cast(valueOfMember->call(object)); // ### invoke convert-to-number? + if (const FunctionValue *valueOfMember = value_cast(object->lookupMember("valueOf", ContextPtr()))) { + _result = value_cast(valueOfMember->call(object)); // ### invoke convert-to-number? } } void ConvertToNumber::visit(const FunctionValue *object) { - if (const FunctionValue *valueOfMember = value_cast(object->lookupMember("valueOf", ContextPtr()))) { - _result = value_cast(valueOfMember->call(object)); // ### invoke convert-to-number? + if (const FunctionValue *valueOfMember = value_cast(object->lookupMember("valueOf", ContextPtr()))) { + _result = value_cast(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(object->lookupMember("toString", ContextPtr()))) { - _result = value_cast(toStringMember->call(object)); // ### invoke convert-to-string? + if (const FunctionValue *toStringMember = value_cast(object->lookupMember("toString", ContextPtr()))) { + _result = value_cast(toStringMember->call(object)); // ### invoke convert-to-string? } } void ConvertToString::visit(const FunctionValue *object) { - if (const FunctionValue *toStringMember = value_cast(object->lookupMember("toString", ContextPtr()))) { - _result = value_cast(toStringMember->call(object)); // ### invoke convert-to-string? + if (const FunctionValue *toStringMember = value_cast(object->lookupMember("toString", ContextPtr()))) { + _result = value_cast(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(); diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h index 513fe6b045f..283006adf46 100644 --- a/src/libs/qmljs/qmljsinterpreter.h +++ b/src/libs/qmljs/qmljsinterpreter.h @@ -75,6 +75,11 @@ class JSImportScope; class Context; typedef QSharedPointer ContextPtr; class ReferenceContext; +class CppComponentValue; +class ASTObjectValue; +class QmlEnumValue; +class QmlPrototypeReference; +class ASTPropertyReference; typedef QList 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 _RetTy value_cast(const Value *v); +template 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; diff --git a/src/libs/qmljs/qmljsscopebuilder.cpp b/src/libs/qmljs/qmljsscopebuilder.cpp index d960fab39aa..dda5496bc5d 100644 --- a/src/libs/qmljs/qmljsscopebuilder.cpp +++ b/src/libs/qmljs/qmljsscopebuilder.cpp @@ -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(prototype)) { + if (const CppComponentValue *qmlMetaObject = value_cast(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(targetValue)) { + if (const ObjectValue *target = value_cast(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(prototype)) { + if (const CppComponentValue *qmlMetaObject = value_cast(prototype)) { if (qmlMetaObject->className() == QLatin1String("PropertyChanges") && (qmlMetaObject->moduleName() == QLatin1String("Qt") || qmlMetaObject->moduleName() == QLatin1String("QtQuick"))) diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 93d65369334..8b34468efea 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -96,14 +96,14 @@ class PropertyMemberProcessor : public MemberProcessor public: virtual bool processProperty(const QString &name, const Value *value) { - const ASTPropertyReference *ref = dynamic_cast(value); + const ASTPropertyReference *ref = value_cast(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(value)) { + if (const CppComponentValue * ov = value_cast(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(ov); + const CppComponentValue * qmlValue = value_cast(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(ov); + const CppComponentValue * qmlValue = value_cast(ov); if (qmlValue) { if (versions) { list << qmlValue->moduleName() + '.' + qmlValue->className() + @@ -192,7 +192,7 @@ QList 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(ov->lookupMember(name, context)); + const CppComponentValue * qmlValue = value_cast(ov->lookupMember(name, context)); if (qmlValue) { QList dotProperties = getQmlTypes(qmlValue, context); foreach (const PropertyInfo &propertyInfo, dotProperties) { @@ -204,7 +204,7 @@ QList getQmlTypes(const CppComponentValue *ov, const ContextPtr &c } } if (isValueType(ov->propertyType(name))) { - const ObjectValue *dotObjectValue = dynamic_cast(ov->lookupMember(name, context)); + const ObjectValue *dotObjectValue = value_cast(ov->lookupMember(name, context)); if (dotObjectValue) { QList dotProperties = getObjectTypes(dotObjectValue, context); foreach (const PropertyInfo &propertyInfo, dotProperties) { @@ -224,7 +224,7 @@ QList getQmlTypes(const CppComponentValue *ov, const ContextPtr &c if (!local) { const ObjectValue* prototype = ov->prototype(context); - const CppComponentValue * qmlObjectValue = dynamic_cast(prototype); + const CppComponentValue * qmlObjectValue = value_cast(prototype); if (qmlObjectValue) { list << getQmlTypes(qmlObjectValue, context); @@ -240,7 +240,7 @@ QList getTypes(const ObjectValue *ov, const ContextPtr &context, b { QList list; - const CppComponentValue * qmlObjectValue = dynamic_cast(ov); + const CppComponentValue * qmlObjectValue = value_cast(ov); if (qmlObjectValue) { list << getQmlTypes(qmlObjectValue, context, local); @@ -264,7 +264,7 @@ QList getObjectTypes(const ObjectValue *ov, const ContextPtr &cont if (!local) { const ObjectValue* prototype = ov->prototype(context); - const CppComponentValue * qmlObjectValue = dynamic_cast(prototype); + const CppComponentValue * qmlObjectValue = value_cast(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(objectValue); + const CppComponentValue *qmlValue = value_cast(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(lookupResult))) + if ((value = value_cast(lookupResult))) return value; } @@ -759,7 +759,7 @@ QString NodeMetaInfoPrivate::packageName() const QString NodeMetaInfoPrivate::componentSource() const { if (isComponent()) { - const ASTObjectValue * astObjectValue = dynamic_cast(getObjectValue()); + const ASTObjectValue * astObjectValue = value_cast(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(getObjectValue()); + const ASTObjectValue * astObjectValue = value_cast(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(ov)) { + if (const CppComponentValue * qmlValue = value_cast(ov)) { description.minorVersion = qmlValue->componentVersion().minorVersion(); description.majorVersion = qmlValue->componentVersion().majorVersion(); if (!qmlValue->moduleName().isEmpty()) diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index be9b9f01531..ae3f345100f 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -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(value); + const CppComponentValue * qmlValue = value_cast(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(value); + objectValue = value_cast(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(proto)) { + if (const CppComponentValue *qmlIter = value_cast(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(containingObject)) { + if (const CppComponentValue * qmlObject = value_cast(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(containingObject); + const CppComponentValue * lhsCppComponent = value_cast(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(rhsValueObject); + const CppComponentValue *rhsCppComponentValue = value_cast(rhsValueObject); if (!rhsCppComponentValue) return QVariant(); diff --git a/src/plugins/qmljseditor/qmljscompletionassist.cpp b/src/plugins/qmljseditor/qmljscompletionassist.cpp index b5b0dd75775..1f448cca364 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.cpp +++ b/src/plugins/qmljseditor/qmljscompletionassist.cpp @@ -148,7 +148,7 @@ public: virtual void operator ()(const Value *base, const QString &name, const Value *) { - const CppComponentValue *qmlBase = dynamic_cast(base); + const CppComponentValue *qmlBase = value_cast(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(v); + newScopeType = value_cast(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(value)) { + value_cast(value)) { const QString &name = context->imports(document.data())->nameForImportedObject(enumValue->owner(), context.data()); foreach (const QString &key, enumValue->keys()) { QString completion; diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index b5d7965e258..557fbca3def 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -525,7 +525,7 @@ protected: if ((!_name.isEmpty()) && _name.at(0).isUpper()) { // a possible type _targetValue = _scopeChain->lookup(_name, &_scope); - if (value_cast(_targetValue)) + if (value_cast(_targetValue)) _typeKind = TypeKind; } } @@ -851,7 +851,7 @@ static void find_helper(QFutureInterface &future, FindReferences::Usage searchStarting(replacement, name, 0, 0, 0); if (findTarget.typeKind() == findTarget.TypeKind){ - const ObjectValue *typeValue = value_cast(findTarget.targetValue()); + const ObjectValue *typeValue = value_cast(findTarget.targetValue()); if (!typeValue) return; future.reportResult(searchStarting); diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp index bc005757dde..d2c5797c7e8 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.cpp +++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp @@ -300,7 +300,7 @@ void HoverHandler::prettyPrintTooltip(const QmlJS::Value *value, } } } else if (const QmlEnumValue *enumValue = - dynamic_cast(value)) { + value_cast(value)) { setToolTip(enumValue->name()); } diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp index b22db9abca0..8bd0b6fa773 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp @@ -138,7 +138,7 @@ protected: PrototypeIterator it(v, m_scopeChain.context()); while (it.hasNext()) { const ObjectValue *proto = it.next(); - const CppComponentValue *qmlProto = dynamic_cast(proto); + const CppComponentValue *qmlProto = value_cast(proto); if (!qmlProto) continue; if (qmlProto->metaObject() == m_statePrototype->metaObject()) diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index c83610d2cce..0ed04a52995 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -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(targetValue)) { + if (const ObjectValue *targetObject = value_cast(targetValue)) { return targetObject; } else { return 0; diff --git a/tests/auto/qml/codemodel/basic/tst_basic.cpp b/tests/auto/qml/codemodel/basic/tst_basic.cpp index d5640eb0860..5a50de55bca 100644 --- a/tests/auto/qml/codemodel/basic/tst_basic.cpp +++ b/tests/auto/qml/codemodel/basic/tst_basic.cpp @@ -144,17 +144,17 @@ void tst_Basic::basicObjectTests() QVERIFY(ovProperty); QCOMPARE(ovProperty->className(), QString("State")); - const CppComponentValue * qmlItemValue = dynamic_cast(ovItem); + const CppComponentValue * qmlItemValue = value_cast(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(ovState); + const CppComponentValue * qmlState2Value = value_cast(ovState); QCOMPARE(qmlState2Value->className(), QString("State")); const ObjectValue *ovImage = context->lookupType(doc.data(), QStringList() << "Image"); - const CppComponentValue * qmlImageValue = dynamic_cast(ovImage); + const CppComponentValue * qmlImageValue = value_cast(ovImage); QCOMPARE(qmlImageValue->className(), QString("Image")); QCOMPARE(qmlImageValue->propertyType("source"), QString("QUrl")); }