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

WhenExpression

class WhenExpression : Scope<KtWhenExpression>

A template destructuring Scope for a KtWhenExpression.

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

val Meta.reformatWhen: CliPlugin
   get() =
     "Reformat When Expression" {
       meta(
         whenExpression({ true }) { expression ->
           Transform.replace(
             replacing = expression,
             newDeclaration =
               """|when $`(expression)` {
                  | $entries
                  |} """.`when`
           )
         }
       )
     }

Constructors

<init> A template destructuring Scope for a KtWhenExpression.WhenExpression(value: KtWhenExpression?, entries: ScopedList<KtWhenEntry> = ScopedList(value = value?.entries.orEmpty(), separator = "\n"), (expression): Scope<KtExpression> = WhenScope(value?.subjectExpression), else: Scope<KtExpression> = Scope(value?.elseExpression))

Properties

(expression) val (expression): Scope<KtExpression>
else val else: Scope<KtExpression>
entries val entries: ScopedList<KtWhenEntry>
value val value: KtWhenExpression?

Functions

identity fun ElementScope.identity(): Scope<KtWhenExpression>

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
<