Пример #1
0
bool ChangePropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{
    if (m_sheduledInHierarchy) {
        const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode());
        if (nodeLocation < 0)
            return true;
        bool result = false;

        if (m_property.isDefaultProperty()) {
            result = refactoring.addToObjectMemberList(nodeLocation, m_valueText);

            if (!result) {
                qDebug() << "*** ChangePropertyRewriteAction::execute failed in addToObjectMemberList("
                         << nodeLocation << ','
                         << m_valueText << ") **"
                         << info();
            }
        } else if (m_propertyType == QmlRefactoring::ArrayBinding) {
            result = refactoring.addToArrayMemberList(nodeLocation, m_property.name(), m_valueText);

            if (!result) {
                qDebug() << "*** ChangePropertyRewriteAction::execute failed in addToArrayMemberList("
                         << nodeLocation << ','
                         << m_property.name() << ','
                         << m_valueText << ") **"
                         << info();
            }
        } else {
            result = refactoring.changeProperty(nodeLocation, m_property.name(), m_valueText, m_propertyType);

            if (!result) {
                qDebug() << "*** ChangePropertyRewriteAction::execute failed in changeProperty("
                         << nodeLocation << ','
                         << m_property.name() << ','
                         << m_valueText << ','
                         << qPrintable(toString(m_propertyType)) << ") **"
                         << info();
            }
        }

        return result;
    } else {
        return true;
    }
}
Пример #2
0
bool AddPropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{
    const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode());
    bool result = false;

    if (m_property.isDefaultProperty()) {
        result = refactoring.addToObjectMemberList(nodeLocation, m_valueText);

        if (!result) {
            qDebug() << "*** AddPropertyRewriteAction::execute failed in addToObjectMemberList("
                    << nodeLocation << ','
                    << m_valueText << ") **"
                    << info();
        }
    } else if (m_property.isNodeListProperty() && m_property.toNodeListProperty().toModelNodeList().size() > 1) {
        result = refactoring.addToArrayMemberList(nodeLocation, m_property.name(), m_valueText);

        if (!result) {
            qDebug() << "*** AddPropertyRewriteAction::execute failed in addToArrayMemberList("
                    << nodeLocation << ','
                    << m_property.name() << ','
                    << m_valueText << ") **"
                    << info();
        }
    } else {
        result = refactoring.addProperty(nodeLocation, m_property.name(), m_valueText, m_propertyType);

        if (!result) {
            qDebug() << "*** AddPropertyRewriteAction::execute failed in addProperty("
                    << nodeLocation << ','
                    << m_property.name() << ','
                    << m_valueText << ","
                    << qPrintable(toString(m_propertyType)) << ") **"
                    << info();
        }
    }

    return result;
}