compiler-plugin / arrow.meta.quotes.expression / IfExpression

IfExpression

class IfExpression : Scope<KtIfExpression>

”"”if ($condition) $then else $else”””.if

A template destructuring Scope for a KtIfExpression.

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

val Meta.reformatIf: CliPlugin
   get() =
     "Reformat If Expression" {
       meta(
         ifExpression({ true }) { expression ->
           Transform.replace(
             replacing = expression,
             newDeclaration = when {
               `else`.value == null -> """if ($condition) $then""".`if`
               else -> """if ($condition) $then else $`else`""".`if`
             }
           )
         }
       )
     }

Constructors

<init> ”"”if ($condition) $then else $else”””.ifIfExpression(value: KtIfExpression?, condition: `[`Scope`](../../arrow.meta.quotes/-scope/index.html)`<KtExpression> = Scope(value?.condition), then: `[`Scope`](../../arrow.meta.quotes/-scope/index.html)`<KtExpression> = Scope(value?.then), else: `[`Scope`](../../arrow.meta.quotes/-scope/index.html)`<KtExpression> = Scope(value?.`else`))

Properties

condition val condition: Scope<KtExpression>
else val else: Scope<KtExpression>
then val then: Scope<KtExpression>
value val value: KtIfExpression?

Functions

identity fun ElementScope.identity(): IfExpression

Extension Functions

map fun <K : KtElement> Scope<K>.map(f: (K) -> K): Scope<K>
orEmpty fun <K : KtElement> Scope<K>?.orEmpty(): Scope<K>

Do you like Arrow?

Arrow Org
<