compiler-plugin / arrow.meta.quotes.expression.expressionwithlabel / ReturnExpression

ReturnExpression

class ReturnExpression : ExpressionWithLabel<KtReturnExpression>

”"”return”””.return

A template destructuring Scope for a KtReturnExpression.

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

val Meta.reformatReturn: CliPlugin
   get() =
     "Reformat Return Expression" {
       meta(
         returnExpression(this, { true }) { expressionWithLabel ->
           Transform.replace(
             replacing = expressionWithLabel,
             newDeclaration = when {
               `return`.value != null -> """return $`return`""".`return`
               targetLabel.value != null -> """return$targetLabel""".`return`
               else -> """return""".`return`
             }
           )
         }
       )
     }

Constructors

<init> ”"”return”””.returnReturnExpression(value: KtReturnExpression, targetLabel: Scope<KtSimpleNameExpression> = Scope(value.getTargetLabel()), return: Scope<KtExpression> = Scope(value.returnedExpression))

Properties

return val return: Scope<KtExpression>
targetLabel val targetLabel: Scope<KtSimpleNameExpression>
value val value: KtReturnExpression

Functions

identity fun ElementScope.identity(): ReturnExpression

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
<