compiler-plugin / arrow.meta.quotes.element / ClassBody

ClassBody

class ClassBody : Scope<KtClassBody>

”””{ $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
                 )
               }
             )
           }

Constructors

<init> ”””{ $properties $companionObjects $functions }””“.classBodyClassBody(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

anonymousInitializers val anonymousInitializers: ScopedList<KtAnonymousInitializer>
companionObjects val companionObjects: ScopedList<KtObjectDeclaration>
danglingAnnotations val danglingAnnotations: ScopedList<KtAnnotationEntry>
enumEntries val enumEntries: ScopedList<KtEnumEntry>
functions val functions: ScopedList<KtNamedFunction>
properties val properties: ScopedList<KtProperty>
value val value: KtClassBody?

Functions

identity fun ElementScope.identity(): Scope<KtClassBody>
toString fun toString(): String

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
<