compiler-plugin / arrow.meta.quotes.declaration / DestructuringDeclaration / <init>

<init>

DestructuringDeclaration(value: KtDestructuringDeclaration?, valOrVar: Name? = when { value?.isVar == true -> "var" value?.isVar != true -> "val" else -> "" }.let(Name::identifier), entries: ScopedList<KtDestructuringDeclarationEntry> = ScopedList(value?.entries.orEmpty()), initializer: Scope<KtExpression> = Scope(value?.initializer))

””“$valOrVar ($entries) = $initializer “”“.destructuringDeclaration

A template destructuring Scope for a KtDestructuringDeclaration.

import arrow.meta.Meta
import arrow.meta.CliPlugin
import arrow.meta.invoke
import arrow.meta.quotes.Transform
import arrow.meta.quotes.destructuringDeclaration

val Meta.reformatDestructuringDeclaration: CliPlugin
   get() =
     "Reformat Destructuring Declaration" {
       meta(
         destructuringDeclaration(this, { true }) { declaration ->
           Transform.replace(
             replacing = declaration,
             newDeclaration = """$valOrVar ($entries) = $initializer """.destructuringDeclaration
           )
         }
       )
     }

Do you like Arrow?

Arrow Org
<