compiler-plugin / arrow.meta.quotes.expression.loopexpression / ForExpression

ForExpression

class ForExpression : LoopExpression<KtForExpression>

”"”for ($(param) in $loopRange) $body”””.for

A template destructuring Scope for a KtForExpression.

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

val Meta.reformatFor: CliPlugin
   get() =
   "Reformat For Expression" {
     meta(
       forExpression(this, { true }) { loopExpression ->
         Transform.replace(
           replacing = loopExpression,
           newDeclaration = if (destructuringDeclaration.entries.isEmpty()) {
                               """for ($`(param)` in $loopRange) $body""".`for`
                            } else {
                               """for ((${destructuringDeclaration.entries}) in $loopRange) $body""".`for`
                            }
         )
       }
     )
   }

Constructors

<init> ”"”for ($(param) in $loopRange) $body”””.forForExpression(value: KtForExpression, (param): Parameter = Parameter(value.loopParameter), loopRange: Scope<KtExpression> = Scope(value.loopRange), destructuringDeclaration: DestructuringDeclaration = DestructuringDeclaration(value.destructuringDeclaration))

Properties

(param) val (param): Parameter
destructuringDeclaration val destructuringDeclaration: DestructuringDeclaration
loopRange val loopRange: Scope<KtExpression>
value val value: KtForExpression

Functions

identity fun ElementScope.identity(): ForExpression

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
<