compiler-plugin / arrow.meta.quotes.element / ClassBody / <init>

<init>

ClassBody(value: KtClassBody?, companionObjects: ScopedList<KtObjectDeclaration> = ScopedList(value?.allCompanionObjects ?: listOf(), separator = "\n"), anonymousInitializers: ScopedList<KtAnonymousInitializer> = ScopedList(value?.anonymousInitializers ?: listOf(), separator = "\n"), danglingAnnotations: ScopedList<KtAnnotationEntry> = ScopedList(value?.danglingAnnotations ?: listOf(), separator = "\n"), enumEntries: ScopedList<KtEnumEntry> = ScopedList(value?.enumEntries ?: listOf(), separator = "\n"), functions: ScopedList<KtNamedFunction> = ScopedList(value?.functions ?: listOf(), separator = "\n"), properties: ScopedList<KtProperty> = ScopedList(value?.properties ?: listOf(), separator = "\n"))

”””{ $properties $companionObjects $functions }””“.classBody

A template destructuring Scope for a KtClassBody.

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

val Meta.classBody: CliPlugin
   get() =
     "Reformat Class Body" {
         meta(
             classBody(this, { true }) { element ->
                 Transform.replace(
                     replacing = element,
                     newDeclaration = """
                         | {
                         |  $properties
                         |
                         |  $companionObjects
                         |
                         |  $functions
                         | }""".classBody
                 )
               }
             )
           }

Do you like Arrow?

Arrow Org
<