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

<init>

PropertyAccessor(value: KtPropertyAccessor?, modality: Name? = value?.modalityModifierType()?.value?.let(Name::identifier) ?: Name.identifier(""), visibility: Name? = value?.visibilityModifierType()?.value?.let(Name::identifier) ?: Name.identifier(""), bodyExpression: Scope<KtExpression> = Scope(value?.bodyExpression), name: Name? = value?.property?.nameAsName, (params): ScopedList<KtParameter> = ScopedList( prefix = "(", value = value?.valueParameters ?: emptyList(), postfix = ")", forceRenderSurroundings = true), returnType: ScopedList<KtTypeReference> = ScopedList(listOfNotNull(value?.property?.typeReference), prefix = " : "), initializer: ScopedList<KtExpression> = ScopedList(listOfNotNull(value?.property?.initializer), prefix = " = "))

””” var $name $returnType $initializer $visibility get $(params)$bodyExpression” ““.propertyAccessorGet

A template destructuring Scope for a KtPropertyAccessor

import arrow.meta.Meta
import arrow.meta.CliPlugin
import arrow.meta.invoke
import arrow.meta.phases.CompilerContext
import arrow.meta.quotes.Transform
import arrow.meta.quotes.propertyAccessor

val Meta.reformatPropertySetter: CliPlugin
 get() =
  "Reformat Property Setter" {
   meta(
    property(this, { true }) { e ->
     Transform.replace(
      replacing = e,
      newDeclaration = if (value != null && value.isGetter) {
                           """var $name $returnType $initializer
                                   $visibility get $`(params)`$bodyExpression""".propertyAccessorGet
                        } else if(value != null && value.isSetter) {
                           """var  $name $returnType $initializer
                                 $visibility set $`(params)` $bodyExpression""".propertyAccessorSet
                       } else {
                           empty<KtPropertyAccessor>()
                       }
      )
     }
    )
   }

Do you like Arrow?

Arrow Org
<