compiler-plugin / arrow.meta.quotes.declaration / PropertyAccessor
class PropertyAccessor :
Scope
<KtPropertyAccessor>
””” 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>()
}
)
}
)
}
| <init> | “”” var $name $returnType $initializer $visibility get $(params)
$bodyExpression” ““.propertyAccessorGet 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 = " = "))
|
(params) | val (params): ScopedList <KtParameter> |
bodyExpression | val bodyExpression: Scope <KtExpression> |
initializer | val initializer: ScopedList <KtExpression> |
modality | val modality: Name? |
name | val name: Name? |
returnType | val returnType: ScopedList <KtTypeReference> |
value | val value: KtPropertyAccessor? |
visibility | val visibility: Name? |
identity | fun ElementScope .identity(): Scope <KtPropertyAccessor> |
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?
✖