DeveloperUtils / kotlin-function-arguments-helper

Intellij plugin that provides intention action for function calls
https://plugins.jetbrains.com/plugin/14168-kotlin-function-arguments-helper
Apache License 2.0
15 stars 6 forks source link

Fill secondary constructor `this()` arguments from sec constructor parameters #12

Open WorkingDevel opened 3 years ago

WorkingDevel commented 3 years ago

data class OrderStatus(
    val occurredAt: OffsetDateTime,
    /** one of SalesOrderStatus||ShipmentStatus */
    val status: String,
    val orderNumber: OrderNumber,
    val items: List<OrderItem>,
    /** just in ShipmentStatus */
    val shipmentNumber: String?,
    /** just in SalesOrderStatus */
    val payments: List<Payment>?
) {
    // for a sales order
    constructor(
        occurredAt: OffsetDateTime,
        status: SalesOrderStatus,
        orderNumber: OrderNumber,
        items: List<OrderItem>,
        payments: List<Payment>
    ) : this( // the following arguments should be generated by the plugin
        occurredAt = occurredAt,
        orderNumber = orderNumber,
        status = status.name, // type mismatch should be ignored, just match names
        items = items,
        shipmentNumber = null, // if not found in parameter list, just add not the argument, <null> it or add no value add all, just name it
        payments = payments
    )
}