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:
Christian Kamm
2011-10-10 10:55:37 +02:00
parent 572b3a180b
commit 7ed717ca62
14 changed files with 161 additions and 63 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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());
}

View File

@@ -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())

View File

@@ -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;