compiler-plugin / arrow.meta.quotes.nameddeclaration.stub.typeparameterlistowner / NamedFunction

NamedFunction

class NamedFunction : TypeParameterListOwner<KtNamedFunction>

””” $modality $visibility fun $(typeParameters) $receiver.$name $(args) : $returnType = { $body } “”“.namedFunction

A template destructuring Scope for a KtNamedFunction.

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

val Meta.reformatNamedFunction: CliPlugin
   get() =
     "Reformat Named Function" {
       meta(
         namedFunction(this, { true }) { typeParameterListOwner ->
           Transform.replace(
             replacing = typeParameterListOwner,
             newDeclaration = """ $modifiers fun $receiver $name $`(params)` $returnType = $body """.function
           )
         }
       )
     }

Constructors

| <init> | “”” $modality $visibility fun $(typeParameters) $receiver.$name $(args) : $returnType = { $body } “”“.namedFunctionNamedFunction(value: KtNamedFunction, modality: Name? = value.modalityModifierType()?.value?.let(Name::identifier), visibility: Name? = value.visibilityModifierType()?.value?.let(Name::identifier), modifiers: Scope<KtModifierList> = Scope(value.modifierList), (typeParameters): ScopedList<KtTypeParameter> = ScopedList(prefix = "<", value = value.typeParameters, postfix = ">"), receiver: ScopedList<KtTypeReference> = ScopedList(listOfNotNull(value.receiverTypeReference), postfix = "."), name: Name? = value.nameAsName, (params): ScopedList<KtParameter> = ScopedList( prefix = "(", value = value.valueParameters, postfix = ")", forceRenderSurroundings = true ), returnType: ScopedList<KtTypeReference> = ScopedList(listOfNotNull(value.typeReference), prefix = " : "), body: FunctionBody? = value.body()?.let { FunctionBody(it) }) |

Properties

(params) val (params): ScopedList<KtParameter>
(typeParameters) val (typeParameters): ScopedList<KtTypeParameter>
body val body: FunctionBody?
modality val modality: Name?
modifiers val modifiers: Scope<KtModifierList>
name val name: Name?
receiver val receiver: ScopedList<KtTypeReference>
returnType val returnType: ScopedList<KtTypeReference>
value val value: KtNamedFunction
visibility val visibility: Name?

Functions

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

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
<